Skip to content

Commit

Permalink
git-svn-id: svn://cherokee-project.com/cherokee/trunk@2469 5dc97367-9…
Browse files Browse the repository at this point in the history
…7f1-0310-9951-d761b3857238
  • Loading branch information
alobbs committed Nov 25, 2008
1 parent 8f8dd8a commit d4a389c
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 19 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
@@ -1,5 +1,13 @@
2008-11-25 Alvaro Lopez Ortega <alvaro@octality.com> 2008-11-25 Alvaro Lopez Ortega <alvaro@octality.com>


* cherokee/http.c, cherokee/handler_cgi_base.c,
cherokee/handler_proxy.c, cherokee/connection.c: A few small (but
quite visible) bugs have been fixed.

* qa/154-DirRedirection., qa/155-DirRedirection2.py,
qa/123-ImplicitRedit.py, qa/173-Chunked-SCGI.py: These QA tests
have been slightly adapted so they can be run thru a proxy.

* cherokee/Makefile.MingW.in: Removed. * cherokee/Makefile.MingW.in: Removed.


2008-11-25 Taher Shihadeh <taher@unixwars.com> 2008-11-25 Taher Shihadeh <taher@unixwars.com>
Expand Down
22 changes: 15 additions & 7 deletions cherokee/connection.c
Expand Up @@ -616,8 +616,9 @@ build_response_header (cherokee_connection_t *conn, cherokee_buffer_t *buffer)
ret_t ret_t
cherokee_connection_build_header (cherokee_connection_t *conn) cherokee_connection_build_header (cherokee_connection_t *conn)
{ {
ret_t ret; ret_t ret;

cherokee_boolean_t try_chunked = false;

/* If the handler requires not to add headers, exit. /* If the handler requires not to add headers, exit.
*/ */
if (HANDLER_SUPPORTS (conn->handler, hsupport_skip_headers)) if (HANDLER_SUPPORTS (conn->handler, hsupport_skip_headers))
Expand All @@ -644,11 +645,18 @@ cherokee_connection_build_header (cherokee_connection_t *conn)
*/ */
if ((conn->keepalive != 0) && if ((conn->keepalive != 0) &&
(http_method_with_body (conn->error_code))) (http_method_with_body (conn->error_code)))
{ {
if ((! HANDLER_SUPPORTS (conn->handler, hsupport_length)) || if (HANDLER_SUPPORTS (conn->handler, hsupport_maybe_length)) {
((HANDLER_SUPPORTS (conn->handler, hsupport_maybe_length)) && if (! strcasestr (conn->header_buffer.buf, "Content-Length: ")) {
(! strcasestr (conn->header_buffer.buf, "Content-Length: ")))) try_chunked = true;
{ }
} else if (! HANDLER_SUPPORTS (conn->handler, hsupport_length)) {
try_chunked = true;
}

if (try_chunked) {
/* Turn chunked encoding on, if possible
*/
conn->chunked_encoding = ((CONN_SRV(conn)->chunked_encoding) && conn->chunked_encoding = ((CONN_SRV(conn)->chunked_encoding) &&
(conn->header.version == http_version_11)); (conn->header.version == http_version_11));


Expand Down
2 changes: 1 addition & 1 deletion cherokee/handler_cgi_base.c
Expand Up @@ -315,7 +315,7 @@ cherokee_handler_cgi_base_build_basic_env (
} }
} }


/* Content-Type and Content-Length (if available) /* Content-Type
*/ */
cherokee_buffer_clean (tmp); cherokee_buffer_clean (tmp);
ret = cherokee_header_copy_unknown (&conn->header, "Content-Type", 12, tmp); ret = cherokee_header_copy_unknown (&conn->header, "Content-Type", 12, tmp);
Expand Down
25 changes: 19 additions & 6 deletions cherokee/handler_proxy.c
Expand Up @@ -250,6 +250,7 @@ build_request (cherokee_handler_proxy_t *hdl,
const char *str; const char *str;
char *begin; char *begin;
char *end; char *end;
cuint_t header_len;
char *header_end; char *header_end;
cherokee_list_t *i; cherokee_list_t *i;
char *ptr; char *ptr;
Expand Down Expand Up @@ -313,6 +314,13 @@ build_request (cherokee_handler_proxy_t *hdl,
{ {
cherokee_buffer_add_str (buf, "Connection: Keep-Alive" CRLF); cherokee_buffer_add_str (buf, "Connection: Keep-Alive" CRLF);
hdl->pconn->keepalive_in = true; hdl->pconn->keepalive_in = true;

ret = cherokee_header_get_known (&conn->header, header_keepalive, &ptr, &ptr_len);
if (ret == ret_ok) {
cherokee_buffer_add_str (buf, "Keep-Alive: ");
cherokee_buffer_add (buf, ptr, ptr_len);
cherokee_buffer_add_str (buf, CRLF);
}
} else { } else {
cherokee_buffer_add_str (buf, "Connection: Close" CRLF); cherokee_buffer_add_str (buf, "Connection: Close" CRLF);
hdl->pconn->keepalive_in = false; hdl->pconn->keepalive_in = false;
Expand All @@ -328,8 +336,10 @@ build_request (cherokee_handler_proxy_t *hdl,
str++; str++;


/* Add the client headers */ /* Add the client headers */
cherokee_header_get_length (&conn->header, &header_len);

begin = (char *)str; begin = (char *)str;
header_end = conn->incoming_header.buf + conn->incoming_header.len; header_end = conn->incoming_header.buf + (header_len - 2);


while ((begin < header_end)) { while ((begin < header_end)) {
char chr_end; char chr_end;
Expand Down Expand Up @@ -462,11 +472,14 @@ send_post (cherokee_handler_proxy_t *hdl)
return ret_ok; return ret_ok;


case ret_eagain: case ret_eagain:
/* if (eagain_fd != -1) { */ if (eagain_fd != -1) {
/* cherokee_thread_deactive_to_polling (HANDLER_THREAD(hdl), */ ret = cherokee_thread_deactive_to_polling (HANDLER_THREAD(hdl),
/* conn, eagain_fd, */ conn, eagain_fd,
/* mode, false); */ mode, false);
/* } */ if (ret != ret_ok) {
return ret_eof;
}
}
return ret_eagain; return ret_eagain;


default: default:
Expand Down
2 changes: 1 addition & 1 deletion cherokee/http.c
Expand Up @@ -44,7 +44,7 @@ cherokee_http_method_to_string (cherokee_http_method_t method, const char **str,
entry (http_post, "POST"); entry (http_post, "POST");
entry (http_head, "HEAD"); entry (http_head, "HEAD");
entry (http_put, "PUT"); entry (http_put, "PUT");
entry (http_options, "PUT"); entry (http_options, "OPTIONS");
entry (http_delete, "DELETE"); entry (http_delete, "DELETE");
entry (http_trace, "TRACE"); entry (http_trace, "TRACE");
entry (http_connect, "CONNECT"); entry (http_connect, "CONNECT");
Expand Down
2 changes: 1 addition & 1 deletion qa/123-ImplicitRedit.py
Expand Up @@ -16,7 +16,7 @@ def __init__ (self):


self.request = "GET /implicit_redir1 HTTP/1.0\r\n" self.request = "GET /implicit_redir1 HTTP/1.0\r\n"
self.expected_error = 301 self.expected_error = 301
self.expected_content = "Location: /implicit_redir1/" self.expected_content = ["Location: ", "/implicit_redir1/\r\n"]


def Prepare (self, www): def Prepare (self, www):
d = self.Mkdir (www, "implicit_redir1_DIR") d = self.Mkdir (www, "implicit_redir1_DIR")
Expand Down
2 changes: 1 addition & 1 deletion qa/154-DirRedirection.py
Expand Up @@ -17,7 +17,7 @@ def __init__ (self):
self.name = "common-dirlist: redir to add final /" self.name = "common-dirlist: redir to add final /"
self.request = "GET /%s HTTP/1.0\r\n" % (REQ) self.request = "GET /%s HTTP/1.0\r\n" % (REQ)
self.expected_error = 301 self.expected_error = 301
self.expected_content = "Location: /%s/" % (REQ) self.expected_content = ["Location: ", "/%s/\r\n" % (REQ)]


def Prepare (self, www): def Prepare (self, www):
dr = self.Mkdir (www, DIR) dr = self.Mkdir (www, DIR)
Expand Down
2 changes: 1 addition & 1 deletion qa/155-DirRedirection2.py
Expand Up @@ -19,7 +19,7 @@ def __init__ (self):
self.name = "common-dirlist: redir to add final / 2" self.name = "common-dirlist: redir to add final / 2"
self.request = "GET /%s HTTP/1.0\r\n" % (REQ) self.request = "GET /%s HTTP/1.0\r\n" % (REQ)
self.expected_error = 301 self.expected_error = 301
self.expected_content = "Location: /%s/" % (REQ) self.expected_content = ["Location: ", "/%s/\r\n" % (REQ)]


def Prepare (self, www): def Prepare (self, www):
self.Mkdir (www, DIR2) self.Mkdir (www, DIR2)
Expand Down
2 changes: 1 addition & 1 deletion qa/173-Chunked-SCGI.py
Expand Up @@ -16,7 +16,7 @@
class TestHandler (SCGIHandler): class TestHandler (SCGIHandler):
def handle_request (self): def handle_request (self):
self.handle_post() self.handle_post()
self.output.write('Content-Length: %d\\r\\n') # self.output.write('Content-Length: %d\\r\\n')
self.output.write('Content-Type: text/plain\\r\\n\\r\\n') self.output.write('Content-Type: text/plain\\r\\n\\r\\n')
self.output.write('%s') self.output.write('%s')
Expand Down

0 comments on commit d4a389c

Please sign in to comment.