aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Uzunov <andrey.uzunov@gmail.com>2013-12-08 22:05:57 +0000
committerAndrey Uzunov <andrey.uzunov@gmail.com>2013-12-08 22:05:57 +0000
commitd7a7a47de56eebd2d1bd31fa74240dfda9929649 (patch)
tree2bdcc9979a04e0551dd406ac24584d59098a1e12
parent38fad29b451f60898f2bbbaccc39dc97b86f5fe2 (diff)
downloadlibmicrohttpd-d7a7a47de56eebd2d1bd31fa74240dfda9929649.tar.gz
libmicrohttpd-d7a7a47de56eebd2d1bd31fa74240dfda9929649.zip
mhd2spdy: minor bugs fixed
-rw-r--r--src/examples/mhd2spdy_http.c7
-rw-r--r--src/examples/mhd2spdy_spdy.c31
2 files changed, 28 insertions, 10 deletions
diff --git a/src/examples/mhd2spdy_http.c b/src/examples/mhd2spdy_http.c
index 8116b326..8d0482ba 100644
--- a/src/examples/mhd2spdy_http.c
+++ b/src/examples/mhd2spdy_http.c
@@ -172,6 +172,7 @@ http_cb_request (void *cls,
172 struct SPDY_Headers spdy_headers; 172 struct SPDY_Headers spdy_headers;
173 bool with_body = false; 173 bool with_body = false;
174 struct HTTP_URI *http_uri; 174 struct HTTP_URI *http_uri;
175 const char *header_value;
175 176
176 if (NULL == ptr || NULL == *ptr) 177 if (NULL == ptr || NULL == *ptr)
177 return MHD_NO; 178 return MHD_NO;
@@ -250,9 +251,11 @@ http_cb_request (void *cls,
250 251
251 proxy->url = http_uri->uri; 252 proxy->url = http_uri->uri;
252 253
254 header_value = MHD_lookup_connection_value(connection,
255 MHD_HEADER_KIND, MHD_HTTP_HEADER_CONTENT_LENGTH);
256
253 with_body = 0 == strcmp (method, MHD_HTTP_METHOD_POST) 257 with_body = 0 == strcmp (method, MHD_HTTP_METHOD_POST)
254 && 0 != strcmp ("0", 258 && (NULL == header_value || 0 != strcmp ("0", header_value));
255 MHD_lookup_connection_value(connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_CONTENT_LENGTH));
256 259
257 PRINT_INFO2("body will be sent %i", with_body); 260 PRINT_INFO2("body will be sent %i", with_body);
258 261
diff --git a/src/examples/mhd2spdy_spdy.c b/src/examples/mhd2spdy_spdy.c
index 2630df6d..95ec43c8 100644
--- a/src/examples/mhd2spdy_spdy.c
+++ b/src/examples/mhd2spdy_spdy.c
@@ -727,7 +727,7 @@ spdy_connect(const struct URI *uri,
727 spdylay_session_callbacks callbacks; 727 spdylay_session_callbacks callbacks;
728 int fd; 728 int fd;
729 SSL *ssl=NULL; 729 SSL *ssl=NULL;
730 struct SPDY_Connection * connection; 730 struct SPDY_Connection * connection = NULL;
731 int rv; 731 int rv;
732 732
733 spdy_setup_spdylay_callbacks(&callbacks); 733 spdy_setup_spdylay_callbacks(&callbacks);
@@ -757,11 +757,7 @@ spdy_connect(const struct URI *uri,
757 { 757 {
758 PRINT_INFO("Closing SSL"); 758 PRINT_INFO("Closing SSL");
759 //no spdy on the other side 759 //no spdy on the other side
760 SSL_shutdown(ssl); 760 goto free_and_fail;
761 close(fd);
762 SSL_free(ssl);
763
764 return NULL;
765 } 761 }
766 } 762 }
767 else 763 else
@@ -770,12 +766,13 @@ spdy_connect(const struct URI *uri,
770 } 766 }
771 767
772 if(NULL == (connection = au_malloc(sizeof(struct SPDY_Connection)))) 768 if(NULL == (connection = au_malloc(sizeof(struct SPDY_Connection))))
773 return NULL; 769 goto free_and_fail;
774 770
775 connection->is_tls = is_tls; 771 connection->is_tls = is_tls;
776 connection->ssl = ssl; 772 connection->ssl = ssl;
777 connection->want_io = IO_NONE; 773 connection->want_io = IO_NONE;
778 connection->host = strdup(uri->host); 774 if(NULL == (connection->host = strdup(uri->host)))
775 goto free_and_fail;
779 776
780 /* Here make file descriptor non-block */ 777 /* Here make file descriptor non-block */
781 spdy_socket_make_non_block(fd); 778 spdy_socket_make_non_block(fd);
@@ -791,6 +788,24 @@ spdy_connect(const struct URI *uri,
791 connection->fd = fd; 788 connection->fd = fd;
792 789
793 return connection; 790 return connection;
791
792 //for GOTO
793 free_and_fail:
794 if(NULL != connection)
795 {
796 free(connection->host);
797 free(connection);
798 }
799
800 if(is_tls)
801 SSL_shutdown(ssl);
802
803 close(fd);
804
805 if(is_tls)
806 SSL_free(ssl);
807
808 return NULL;
794} 809}
795 810
796 811