Browse Source

fixed handling of OPTIONS * and /

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-merge-1.4.x@579 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.2
Jan Kneschke 17 years ago
parent
commit
a31377ace4
  1. 15
      src/connections.c
  2. 14
      src/response.c

15
src/connections.c

@ -303,9 +303,18 @@ static int connection_handle_write_prepare(server *srv, connection *con) {
case HTTP_METHOD_GET:
case HTTP_METHOD_POST:
case HTTP_METHOD_HEAD:
case HTTP_METHOD_OPTIONS:
case HTTP_METHOD_PUT:
break;
case HTTP_METHOD_OPTIONS:
if (con->uri.path->ptr[0] != '*') {
response_header_insert(srv, con, CONST_STR_LEN("Allow"), CONST_STR_LEN("OPTIONS, GET, HEAD, POST"));
con->http_status = 200;
con->file_finished = 1;
chunkqueue_reset(con->write_queue);
}
break;
default:
switch(con->http_status) {
case 400: /* bad request */
@ -395,7 +404,7 @@ static int connection_handle_write_prepare(server *srv, connection *con) {
/* fall through */
case 207:
case 200: /* class: header + body */
break;
break;
case 206: /* write_queue is already prepared */
case 302:
@ -452,7 +461,7 @@ static int connection_handle_write_prepare(server *srv, connection *con) {
if (con->request.http_method == HTTP_METHOD_HEAD) {
chunkqueue_reset(con->write_queue);
}
http_response_write_header(srv, con);
return 0;

14
src/response.c

@ -216,9 +216,15 @@ handler_t http_response_prepare(server *srv, connection *con) {
buffer_copy_string_buffer(srv->tmp_buf, con->uri.path_raw);
buffer_urldecode_path(srv->tmp_buf);
buffer_path_simplify(con->uri.path, srv->tmp_buf);
if (con->request.http_method == HTTP_METHOD_OPTIONS &&
con->uri.path_raw->ptr[0] == '*' && con->uri.path_raw->ptr[1] == '\0') {
/* OPTIONS * ... */
buffer_copy_string_buffer(con->uri.path, con->uri.path_raw);
} else {
buffer_copy_string_buffer(srv->tmp_buf, con->uri.path_raw);
buffer_urldecode_path(srv->tmp_buf);
buffer_path_simplify(con->uri.path, srv->tmp_buf);
}
if (con->conf.log_request_handling) {
log_error_write(srv, __FILE__, __LINE__, "s", "-- sanatising URI");
@ -249,7 +255,7 @@ handler_t http_response_prepare(server *srv, connection *con) {
}
if (con->request.http_method == HTTP_METHOD_OPTIONS &&
con->uri.path->ptr[0] == '*') {
con->uri.path->ptr[0] == '*' && con->uri.path_raw->ptr[1] == '\0') {
/* option requests are handled directly without checking of the path */
response_header_insert(srv, con, CONST_STR_LEN("Allow"), CONST_STR_LEN("OPTIONS, GET, HEAD, POST"));

Loading…
Cancel
Save