Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Reject all expectations but 100.

  • Loading branch information...
commit 988f5d8d6d623f69a45fa0f9ae25baf9c52f32cc 1 parent 3c4b0cf
@Tordek Tordek authored
Showing with 17 additions and 2 deletions.
  1. +8 −2 src/connection.c
  2. +8 −0 src/response.c
  3. +1 −0  src/response.h
View
10 src/connection.c
@@ -254,8 +254,14 @@ int connection_http_to_handler(Connection *conn)
bstring expects = Request_get(conn->req, &HTTP_EXPECT);
- if (expects != NULL && biseqcstr(expects, "100-continue")) {
- Response_send_status(conn, &HTTP_100);
+ if (expects != NULL) {
+ if (biseqcstr(expects, "100-continue")) {
+ Response_send_status(conn, &HTTP_100);
+ } else {
+ Response_send_status(conn, &HTTP_417);
+ log_info("Client requested unsupported expectation: %s.", bdata(expects));
+ goto error;
+ }
}
// we don't need the header anymore, so commit the buffer and deal with the body
View
8 src/response.c
@@ -110,6 +110,14 @@ struct tagbstring HTTP_412 = bsStatic("HTTP/1.1 412 Precondition Failed\r\n"
"\r\n\r\n"
"Precondition Failed");
+struct tagbstring HTTP_417 = bsStatic("HTTP/1.1 417 Expectation Failed\r\n"
+ "Content-Type: text/plain\r\n"
+ "Connection: close\r\n"
+ "Content-Length: 18\r\n"
+ "Server: " VERSION "\r\n"
+ "\r\n"
+ "Expectation Failed");
+
struct tagbstring HTTP_304 = bsStatic("HTTP/1.1 304 Not Modified\r\n"
"Connection: close\r\n"
View
1  src/response.h
@@ -45,6 +45,7 @@ extern struct tagbstring HTTP_404;
extern struct tagbstring HTTP_405;
extern struct tagbstring HTTP_412;
extern struct tagbstring HTTP_413;
+extern struct tagbstring HTTP_417;
extern struct tagbstring HTTP_500;
extern struct tagbstring HTTP_501;
extern struct tagbstring HTTP_502;
Please sign in to comment.
Something went wrong with that request. Please try again.