Commit a828a63e authored by Cecilie Fritzvold's avatar Cecilie Fritzvold

Improved handling of pass for POST requests.


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@2123 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 656f54bb
...@@ -261,9 +261,10 @@ Fetch(struct sess *sp) ...@@ -261,9 +261,10 @@ Fetch(struct sess *sp)
int mklen, is_head; int mklen, is_head;
struct http_conn htc[1]; struct http_conn htc[1];
int i; int i;
int content_length; int content_length, content_written;
char hdr[20]; int read;
char *ptr; char *ptr, *endp;
char *p = NULL;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
...@@ -293,12 +294,21 @@ Fetch(struct sess *sp) ...@@ -293,12 +294,21 @@ Fetch(struct sess *sp)
/* If a POST request was passed to fetch, we must send /* If a POST request was passed to fetch, we must send
* any pipelined bytes to the backend as well */ * any pipelined bytes to the backend as well */
if (!strcmp(http_GetReq(sp->http), "POST")) { if(http_GetHdr(sp->http, H_Content_Length, &ptr)) {
sprintf(hdr, "%ccontent-length:", 15); endp = ptr + strlen(ptr);
assert(http_GetHdr(sp->http, hdr, &ptr)); content_length = (int)strtol(ptr, &endp, 10);
content_length = atoi(ptr); content_written = 0;
if (sp->htc->pipeline.b != NULL && content_length > 0) while (content_written < content_length) {
WRK_Write(w, sp->htc->pipeline.b, content_length); p = malloc(content_length);
read = HTC_Read(sp->htc, p, content_length);
content_written += WRK_Write(w, p, read);
if (WRK_Flush(w)) {
VBE_UpdateHealth(sp, vc, -1);
VBE_ClosedFd(sp->wrk, vc);
return (__LINE__);
}
free(p);
}
} }
if (WRK_Flush(w)) { if (WRK_Flush(w)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment