diff options
author | Andrey Uzunov <andrey.uzunov@gmail.com> | 2013-10-10 00:34:52 +0000 |
---|---|---|
committer | Andrey Uzunov <andrey.uzunov@gmail.com> | 2013-10-10 00:34:52 +0000 |
commit | 0cec4cbb396dedb52e543743058fb8b68b0aaafb (patch) | |
tree | 8f455d6eb29ab43147d437b5008887985e6ed8c2 | |
parent | ab4fa1fdbc51ec4d952b097f076ca0fdfcb10934 (diff) | |
download | libmicrohttpd-0cec4cbb396dedb52e543743058fb8b68b0aaafb.tar.gz libmicrohttpd-0cec4cbb396dedb52e543743058fb8b68b0aaafb.zip |
spdy2http: handle servers which dont use CR
-rw-r--r-- | src/spdy2http/proxy.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/spdy2http/proxy.c b/src/spdy2http/proxy.c index 8f3565f2..56c7d929 100644 --- a/src/spdy2http/proxy.c +++ b/src/spdy2http/proxy.c | |||
@@ -452,6 +452,7 @@ response_callback (void *cls, | |||
452 | 452 | ||
453 | if(!proxy->http_body_size)//nothing to write now | 453 | if(!proxy->http_body_size)//nothing to write now |
454 | { | 454 | { |
455 | PRINT_VERBOSE2("nothing to write now? %i", proxy->done); | ||
455 | if(proxy->done) *more = false; | 456 | if(proxy->done) *more = false; |
456 | return 0; | 457 | return 0; |
457 | } | 458 | } |
@@ -503,7 +504,6 @@ response_done_callback(void *cls, | |||
503 | 504 | ||
504 | if(SPDY_RESPONSE_RESULT_SUCCESS != status) | 505 | if(SPDY_RESPONSE_RESULT_SUCCESS != status) |
505 | { | 506 | { |
506 | PRINT_VERBOSE2("answer was NOT sent, %i\n",status); | ||
507 | free(proxy->http_body); | 507 | free(proxy->http_body); |
508 | proxy->http_body = NULL; | 508 | proxy->http_body = NULL; |
509 | } | 509 | } |
@@ -540,7 +540,7 @@ curl_header_cb(void *ptr, size_t size, size_t nmemb, void *userp) | |||
540 | //trailer | 540 | //trailer |
541 | if(NULL != proxy->response) return 0; | 541 | if(NULL != proxy->response) return 0; |
542 | 542 | ||
543 | if('\r' == line[0]) | 543 | if('\r' == line[0] || '\n' == line[0]) |
544 | { | 544 | { |
545 | //all headers were already handled; prepare spdy frames | 545 | //all headers were already handled; prepare spdy frames |
546 | if(NULL == (proxy->response = SPDY_build_response_with_callback(proxy->status, | 546 | if(NULL == (proxy->response = SPDY_build_response_with_callback(proxy->status, |
@@ -589,16 +589,16 @@ curl_header_cb(void *ptr, size_t size, size_t nmemb, void *userp) | |||
589 | pos = i+1; | 589 | pos = i+1; |
590 | 590 | ||
591 | //status (number) | 591 | //status (number) |
592 | for(i=pos; i<realsize && ' '!=line[i] && '\r'!=line[i]; ++i); | 592 | for(i=pos; i<realsize && ' '!=line[i] && '\r'!=line[i] && '\n'!=line[i]; ++i); |
593 | if(NULL == (status = strndup(&(line[pos]), i - pos))) | 593 | if(NULL == (status = strndup(&(line[pos]), i - pos))) |
594 | DIE("No memory"); | 594 | DIE("No memory"); |
595 | proxy->status = atoi(status); | 595 | proxy->status = atoi(status); |
596 | free(status); | 596 | free(status); |
597 | if(i<realsize && '\r'!=line[i]) | 597 | if(i<realsize && '\r'!=line[i] && '\n'!=line[i]) |
598 | { | 598 | { |
599 | //status (message) | 599 | //status (message) |
600 | pos = i+1; | 600 | pos = i+1; |
601 | for(i=pos; i<realsize && '\r'!=line[i]; ++i); | 601 | for(i=pos; i<realsize && '\r'!=line[i] && '\n'!=line[i]; ++i); |
602 | if(NULL == (proxy->status_msg = strndup(&(line[pos]), i - pos))) | 602 | if(NULL == (proxy->status_msg = strndup(&(line[pos]), i - pos))) |
603 | DIE("No memory"); | 603 | DIE("No memory"); |
604 | } | 604 | } |
@@ -608,7 +608,7 @@ curl_header_cb(void *ptr, size_t size, size_t nmemb, void *userp) | |||
608 | 608 | ||
609 | //other lines | 609 | //other lines |
610 | //header name | 610 | //header name |
611 | for(i=pos; i<realsize && ':'!=line[i] && '\r'!=line[i]; ++i) | 611 | for(i=pos; i<realsize && ':'!=line[i] && '\r'!=line[i] && '\n'!=line[i]; ++i) |
612 | line[i] = tolower(line[i]); //spdy requires lower case | 612 | line[i] = tolower(line[i]); //spdy requires lower case |
613 | if(NULL == (name = strndup(line, i - pos))) | 613 | if(NULL == (name = strndup(line, i - pos))) |
614 | DIE("No memory"); | 614 | DIE("No memory"); |
@@ -621,7 +621,7 @@ curl_header_cb(void *ptr, size_t size, size_t nmemb, void *userp) | |||
621 | free(name); | 621 | free(name); |
622 | return realsize; | 622 | return realsize; |
623 | } | 623 | } |
624 | if(i == realsize || '\r'==line[i]) | 624 | if(i == realsize || '\r'==line[i] || '\n'==line[i]) |
625 | { | 625 | { |
626 | //no value. is it possible? | 626 | //no value. is it possible? |
627 | if(SPDY_YES != SPDY_name_value_add(proxy->headers, name, "")) | 627 | if(SPDY_YES != SPDY_name_value_add(proxy->headers, name, "")) |
@@ -632,7 +632,7 @@ curl_header_cb(void *ptr, size_t size, size_t nmemb, void *userp) | |||
632 | //header value | 632 | //header value |
633 | pos = i+1; | 633 | pos = i+1; |
634 | while(pos<realsize && isspace(line[pos])) ++pos; //remove leading space | 634 | while(pos<realsize && isspace(line[pos])) ++pos; //remove leading space |
635 | for(i=pos; i<realsize && '\r'!=line[i]; ++i); | 635 | for(i=pos; i<realsize && '\r'!=line[i] && '\n'!=line[i]; ++i); |
636 | if(NULL == (value = strndup(&(line[pos]), i - pos))) | 636 | if(NULL == (value = strndup(&(line[pos]), i - pos))) |
637 | DIE("No memory"); | 637 | DIE("No memory"); |
638 | PRINT_VERBOSE2("Adding header: '%s': '%s'", name, value); | 638 | PRINT_VERBOSE2("Adding header: '%s': '%s'", name, value); |