From df58dad240fe368c261263e248d3520d3e0be1a3 Mon Sep 17 00:00:00 2001 From: m0gg Date: Thu, 30 Nov 2006 14:23:58 +0000 Subject: Code cleanup --- nanohttp/Makefile.am | 10 ++- nanohttp/nanohttp-client.c | 8 +- nanohttp/nanohttp-client.h | 12 ++- nanohttp/nanohttp-server.c | 72 ++++++++---------- nanohttp/nanohttp-server.h | 14 +++- nanohttp/nanohttp-socket.c | 178 +++++++++++++++++++++++---------------------- nanohttp/nanohttp-socket.h | 9 ++- nanohttp/nanohttp-ssl.c | 132 ++++++++++++++++++++------------- nanohttp/nanohttp-ssl.h | 8 +- nanohttp/nanohttp-stream.c | 10 +-- 10 files changed, 252 insertions(+), 201 deletions(-) (limited to 'nanohttp') diff --git a/nanohttp/Makefile.am b/nanohttp/Makefile.am index dae7909..f52cce0 100644 --- a/nanohttp/Makefile.am +++ b/nanohttp/Makefile.am @@ -1,3 +1,6 @@ +# +# $Revision: 1.15 $ +# lib_LTLIBRARIES=libnanohttp.la libnanohttp_ladir=$(includedir)/nanohttp-@nanohttp_release@/nanohttp @@ -8,10 +11,9 @@ libnanohttp_la_SOURCES=nanohttp-common.c nanohttp-socket.c nanohttp-client.c nanohttp-logging.c nanohttp-admin.c nanohttp-error.c libnanohttp_la_HEADERS=nanohttp-common.h nanohttp-socket.h nanohttp-client.h \ - nanohttp-server.h nanohttp-stream.h nanohttp-mime.h \ - nanohttp-request.h nanohttp-response.h \ - nanohttp-base64.h nanohttp-logging.h nanohttp-admin.h \ - nanohttp-error.h + nanohttp-server.h nanohttp-stream.h nanohttp-mime.h \ + nanohttp-request.h nanohttp-response.h nanohttp-logging.h \ + nanohttp-error.h nanohttp-base64.h nanohttp-admin.h if BUILD_WITH_SSL libnanohttp_la_SOURCES+=nanohttp-ssl.c diff --git a/nanohttp/nanohttp-client.c b/nanohttp/nanohttp-client.c index 2392d81..1c4c6d7 100644 --- a/nanohttp/nanohttp-client.c +++ b/nanohttp/nanohttp-client.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: nanohttp-client.c,v 1.47 2006/11/28 23:45:57 m0gg Exp $ +* $Id: nanohttp-client.c,v 1.48 2006/11/30 14:23:59 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -318,12 +318,12 @@ httpc_send_header(httpc_conn_t * conn) if (walker->key && walker->value) { sprintf(buffer, "%s: %s\r\n", walker->key, walker->value); - if ((status = hsocket_send(conn->sock, buffer)) != H_OK) + if ((status = hsocket_send_string(conn->sock, buffer)) != H_OK) return status; } } - return hsocket_send(conn->sock, "\r\n"); + return hsocket_send_string(conn->sock, "\r\n"); } /*-------------------------------------------------- @@ -429,7 +429,7 @@ _httpc_talk_to_server(hreq_method_t method, httpc_conn_t * conn, } log_verbose1("Sending request..."); - if ((status = hsocket_send(conn->sock, buffer)) != H_OK) + if ((status = hsocket_send_string(conn->sock, buffer)) != H_OK) { log_error2("Cannot send request (%s)", herror_message(status)); hsocket_close(conn->sock); diff --git a/nanohttp/nanohttp-client.h b/nanohttp/nanohttp-client.h index b74130d..6e5d4c9 100644 --- a/nanohttp/nanohttp-client.h +++ b/nanohttp/nanohttp-client.h @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: nanohttp-client.h,v 1.27 2006/11/24 17:28:07 m0gg Exp $ + * $Id: nanohttp-client.h,v 1.28 2006/11/30 14:24:00 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -24,6 +24,16 @@ #ifndef __nanohttp_client_h #define __nanohttp_client_h +/* XXX: Clean up nanohttp to make this unnecessary */ +#ifndef __NHTTP_INTERNAL +#include +#include +#include +#include +#include +#include +#endif + typedef struct httpc_conn { struct hsocket_t *sock; diff --git a/nanohttp/nanohttp-server.c b/nanohttp/nanohttp-server.c index 4c31421..87d740c 100644 --- a/nanohttp/nanohttp-server.c +++ b/nanohttp/nanohttp-server.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: nanohttp-server.c,v 1.71 2006/11/28 23:45:57 m0gg Exp $ +* $Id: nanohttp-server.c,v 1.72 2006/11/30 14:24:00 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -122,7 +122,6 @@ static volatile int _httpd_run = 1; static struct hsocket_t _httpd_socket; static int _httpd_port = 10000; static int _httpd_max_connections = 20; -static int _httpd_timeout = 10; static hservice_t *_httpd_services_default = NULL; static hservice_t *_httpd_services_head = NULL; @@ -143,20 +142,36 @@ static sigset_t thrsigset; static pthread_mutex_t _httpd_connection_lock; #endif -/** - * - * Set Sleep function platform depended - * - */ #ifdef WIN32 -static void _sys_sleep(int secs) +BOOL WINAPI +_httpd_term(DWORD sig) +{ + /* log_debug2 ("Got signal %d", sig); */ + if (sig == _httpd_terminate_signal) + _httpd_run = 0; + + return TRUE; +} + +static void _httpd_sys_sleep(int secs) { Sleep(secs*1000); return; } #else -static inline void _sys_sleep(int secs) +static void +_httpd_term(int sig) +{ + log_debug2("Got signal %d", sig); + + if (sig == _httpd_terminate_signal) + _httpd_run = 0; + + return; +} + +static inline void _httpd_sys_sleep(int secs) { sleep(secs); @@ -185,7 +200,7 @@ _httpd_parse_arguments(int argc, char **argv) } else if (!strcmp(argv[i - 1], NHTTPD_ARG_TIMEOUT)) { - _httpd_timeout = atoi(argv[i]); + hsocket_set_timeout(atoi(argv[i])); } } @@ -337,13 +352,13 @@ httpd_get_port(void) int httpd_get_timeout(void) { - return _httpd_timeout; + return hsocket_get_timeout(); } void -httpd_set_timeout(int t) +httpd_set_timeout(int secs) { - _httpd_timeout = t; + hsocket_set_timeout(secs); return; } @@ -447,7 +462,7 @@ httpd_send_header(httpd_conn_t * res, int code, const char *text) strcat(header, "\r\n"); /* send header */ - if ((status = hsocket_nsend(res->sock, header, strlen(header))) != H_OK) + if ((status = hsocket_send(res->sock, header, strlen(header))) != H_OK) return status; res->out = http_output_stream_new(res->sock, res->header); @@ -834,29 +849,6 @@ httpd_add_headers(httpd_conn_t * conn, const hpair_t * values) return; } -#ifdef WIN32 -BOOL WINAPI -httpd_term(DWORD sig) -{ - /* log_debug2 ("Got signal %d", sig); */ - if (sig == _httpd_terminate_signal) - _httpd_run = 0; - - return TRUE; -} -#else -void -httpd_term(int sig) -{ - log_debug2("Got signal %d", sig); - - if (sig == _httpd_terminate_signal) - _httpd_run = 0; - - return; -} -#endif - /* * ----------------------------------------------------- * FUNCTION: _httpd_register_signal_handler @@ -868,13 +860,13 @@ _httpd_register_signal_handler(void) log_verbose2("registering termination signal handler (SIGNAL:%d)", _httpd_terminate_signal); #ifdef WIN32 - if (SetConsoleCtrlHandler((PHANDLER_ROUTINE) httpd_term, TRUE) == FALSE) + if (SetConsoleCtrlHandler((PHANDLER_ROUTINE) _httpd_term, TRUE) == FALSE) { log_error1("Unable to install console event handler!"); } #else - signal(_httpd_terminate_signal, httpd_term); + signal(_httpd_terminate_signal, _httpd_term); #endif return; @@ -905,7 +897,7 @@ _httpd_wait_for_empty_conn(void) if (i >= _httpd_max_connections) { - _sys_sleep(1); + _httpd_sys_sleep(1); i = -1; } else if (_httpd_connection[i].flag == CONNECTION_FREE) diff --git a/nanohttp/nanohttp-server.h b/nanohttp/nanohttp-server.h index e85c64a..1b74344 100644 --- a/nanohttp/nanohttp-server.h +++ b/nanohttp/nanohttp-server.h @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: nanohttp-server.h,v 1.25 2006/11/28 23:45:57 m0gg Exp $ + * $Id: nanohttp-server.h,v 1.26 2006/11/30 14:24:00 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -24,6 +24,16 @@ #ifndef __nanohttp_server_h #define __nanohttp_server_h +/* XXX: Clean up nanohttp to make this unnecessary */ +#ifndef __NHTTP_INTERNAL +#include +#include +#include +#include +#include +#include +#endif + /** * * nanohttp command line flags @@ -110,7 +120,7 @@ extern "C" extern short httpd_get_port(void); extern int httpd_get_timeout(void); - extern void httpd_set_timeout(int t); + extern void httpd_set_timeout(int secs); extern const char *httpd_get_protocol(void); extern int httpd_get_conncount(void); diff --git a/nanohttp/nanohttp-socket.c b/nanohttp/nanohttp-socket.c index 4869cd7..e2ecf3a 100644 --- a/nanohttp/nanohttp-socket.c +++ b/nanohttp/nanohttp-socket.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: nanohttp-socket.c,v 1.66 2006/11/27 12:47:27 m0gg Exp $ +* $Id: nanohttp-socket.c,v 1.68 2006/11/30 14:25:07 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -90,10 +90,51 @@ typedef int ssize_t; #endif #include "nanohttp-ssl.h" #endif -#include "nanohttp-request.h" -#include "nanohttp-server.h" + +static int _hsocket_timeout = 10; #ifdef WIN32 +static herror_t +_hsocket_sys_accept(struct hsocket_t * sock, struct hsocket_t * dest) +{ + struct hsocket_t sockfd; + int asize; + + asize = sizeof(struct sockaddr_in); + while (1) + { + sockfd.sock = accept(sock->sock, (struct sockaddr *) &(dest->addr), &asize); + if (sockfd.sock == INVALID_SOCKET) + { + if (WSAGetLastError() != WSAEWOULDBLOCK) + return herror_new("hsocket_accept", HSOCKET_ERROR_ACCEPT, "Socket error (%s)", strerror(errno)); + } + else + { + break; + } + } + + dest->sock = sockfd.sock; + + return H_OK; +} + +static void +_hsocket_sys_close(struct hsocket_t * sock) +{ + char junk[10]; + + /* shutdown(sock,SD_RECEIVE); */ + + shutdown(sock->sock, SD_SEND); + while (recv(sock->sock, junk, sizeof(junk), 0) > 0); + /* nothing */ + closesocket(sock->sock); + + return; +} + static void _hsocket_module_sys_init(int argc, char **argv) { @@ -116,11 +157,38 @@ _hsocket_module_sys_init(int argc, char **argv) { return; } + static inline void _hsocket_module_sys_destroy(void) { return; } + +static herror_t +_hsocket_sys_accept(struct hsocket_t * sock, struct hsocket_t * dest) +{ + socklen_t len; + + len = sizeof(struct sockaddr_in); + + if ((dest->sock = accept(sock->sock, (struct sockaddr *) &(dest->addr), &len)) == -1) + { + log_warn2("accept failed (%s)", strerror(errno)); + return herror_new("hsocket_accept", HSOCKET_ERROR_ACCEPT, "Cannot accept network connection (%s)", strerror(errno)); + } + + return H_OK; +} + +static inline void +_hsocket_sys_close(struct hsocket_t * sock) +{ + shutdown(sock->sock, SHUT_RDWR); + + close(sock->sock); + + return; +} #endif herror_t @@ -246,53 +314,6 @@ hsocket_bind(struct hsocket_t *dsock, unsigned short port) return H_OK; } -#ifdef WIN32 -static herror_t -_hsocket_sys_accept(struct hsocket_t * sock, struct hsocket_t * dest) -{ - int asize; - struct hsocket_t sockfd; - - asize = sizeof(struct sockaddr_in); - while (1) - { - sockfd.sock = accept(sock->sock, (struct sockaddr *) &(dest->addr), &asize); - if (sockfd.sock == INVALID_SOCKET) - { - if (WSAGetLastError() != WSAEWOULDBLOCK) - return herror_new("hsocket_accept", HSOCKET_ERROR_ACCEPT, - "Socket error (%s)", strerror(errno)); - } - else - { - break; - } - } - - dest->sock = sockfd.sock; - - return H_OK; -} -#else -static herror_t -_hsocket_sys_accept(struct hsocket_t * sock, struct hsocket_t * dest) -{ - socklen_t len; - - len = sizeof(struct sockaddr_in); - - if ((dest->sock = accept(sock->sock, (struct sockaddr *) &(dest->addr), &len)) == -1) - { - log_warn2("accept failed (%s)", strerror(errno)); - return herror_new("hsocket_accept", HSOCKET_ERROR_ACCEPT, - "Cannot accept network connection (%s)", - strerror(errno)); - } - - return H_OK; -} -#endif - herror_t hsocket_accept(struct hsocket_t * sock, struct hsocket_t * dest) { @@ -337,34 +358,6 @@ hsocket_listen(struct hsocket_t * sock) return H_OK; } -#ifdef WIN32 -static void -_hsocket_sys_close(struct hsocket_t * sock) -{ - char junk[10]; - - /* shutdown(sock,SD_RECEIVE); */ - - shutdown(sock->sock, SD_SEND); - while (recv(sock->sock, junk, sizeof(junk), 0) > 0); - /* nothing */ - closesocket(sock->sock); - - return; -} -#else -static inline void -_hsocket_sys_close(struct hsocket_t * sock) -{ - - shutdown(sock->sock, SHUT_RDWR); - - close(sock->sock); - - return; -} -#endif - void hsocket_close(struct hsocket_t * sock) { @@ -385,7 +378,7 @@ hsocket_close(struct hsocket_t * sock) } herror_t -hsocket_nsend(struct hsocket_t * sock, const unsigned char * bytes, int n) +hsocket_send(struct hsocket_t * sock, const unsigned char * bytes, int n) { #ifdef HAVE_SSL herror_t status; @@ -393,9 +386,8 @@ hsocket_nsend(struct hsocket_t * sock, const unsigned char * bytes, int n) size_t total = 0; size_t size; - log_verbose2("Starting to send on sock=%p", &sock); if (sock->sock < 0) - return herror_new("hsocket_nsend", HSOCKET_ERROR_NOT_INITIALIZED, + return herror_new("hsocket_send", HSOCKET_ERROR_NOT_INITIALIZED, "hsocket not initialized"); /* log_verbose2( "SENDING %s", bytes ); */ @@ -410,7 +402,7 @@ hsocket_nsend(struct hsocket_t * sock, const unsigned char * bytes, int n) } #else if ((size = send(sock->sock, bytes + total, n, 0)) == -1) - return herror_new("hsocket_nsend", HSOCKET_ERROR_SEND, "send failed (%s)", strerror(errno)); + return herror_new("hsocket_send", HSOCKET_ERROR_SEND, "send failed (%s)", strerror(errno)); #endif sock->bytes_received += size; @@ -424,9 +416,9 @@ hsocket_nsend(struct hsocket_t * sock, const unsigned char * bytes, int n) } herror_t -hsocket_send(struct hsocket_t * sock, const char *str) +hsocket_send_string(struct hsocket_t * sock, const char *str) { - return hsocket_nsend(sock, str, strlen(str)); + return hsocket_send(sock, str, strlen(str)); } int @@ -438,13 +430,13 @@ hsocket_select_recv(int sock, char *buf, size_t len) FD_ZERO(&fds); FD_SET(sock, &fds); - timeout.tv_sec = httpd_get_timeout(); + timeout.tv_sec = _hsocket_timeout; timeout.tv_usec = 0; if (select(sock + 1, &fds, NULL, NULL, &timeout) == 0) { errno = ETIMEDOUT; - log_verbose2("Socket %d timeout", sock); + log_verbose2("Socket %d timed out", sock); return -1; } @@ -498,3 +490,17 @@ hsocket_read(struct hsocket_t * sock, unsigned char * buffer, int total, int for } while (1); } + +int +hsocket_get_timeout(void) +{ + return _hsocket_timeout; +} + +void +hsocket_set_timeout(int secs) +{ + _hsocket_timeout = secs; + + return; +} diff --git a/nanohttp/nanohttp-socket.h b/nanohttp/nanohttp-socket.h index db2bf31..b71f38d 100644 --- a/nanohttp/nanohttp-socket.h +++ b/nanohttp/nanohttp-socket.h @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: nanohttp-socket.h,v 1.33 2006/11/26 20:13:06 m0gg Exp $ + * $Id: nanohttp-socket.h,v 1.34 2006/11/30 14:24:00 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -175,7 +175,7 @@ extern herror_t hsocket_accept(struct hsocket_t *sock, struct hsocket_t *dest); * - HSOCKET_ERROR_NOT_INITIALIZED * - HSOCKET_ERROR_SEND */ -extern herror_t hsocket_nsend(struct hsocket_t *sock, const unsigned char *bytes, int size); +extern herror_t hsocket_send(struct hsocket_t *sock, const unsigned char *bytes, int size); /** * @@ -189,7 +189,7 @@ extern herror_t hsocket_nsend(struct hsocket_t *sock, const unsigned char *bytes * - HSOCKET_ERROR_SEND * */ -extern herror_t hsocket_send(struct hsocket_t *sock, const char *str); +extern herror_t hsocket_send_string(struct hsocket_t *sock, const char *str); extern int hsocket_select_recv(int sock, char *buf, size_t len); @@ -210,6 +210,9 @@ extern int hsocket_select_recv(int sock, char *buf, size_t len); */ extern herror_t hsocket_read(struct hsocket_t * sock, unsigned char *buffer, int size, int force, int *readed); +extern int hsocket_get_timeout(void); +extern void hsocket_set_timeout(int secs); + #ifdef __cplusplus } #endif diff --git a/nanohttp/nanohttp-ssl.c b/nanohttp/nanohttp-ssl.c index 8b8fb5d..a5f32e3 100644 --- a/nanohttp/nanohttp-ssl.c +++ b/nanohttp/nanohttp-ssl.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: nanohttp-ssl.c,v 1.33 2006/11/27 12:47:27 m0gg Exp $ +* $Id: nanohttp-ssl.c,v 1.34 2006/11/30 14:24:00 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2001-2005 Rochester Institute of Technology @@ -84,12 +84,11 @@ #include "nanohttp-ssl.h" -static char *certificate = NULL; -static char *certpass = ""; -static char *ca_list = NULL; -static SSL_CTX *context = NULL; - -static int enabled = 0; +static char *_hssl_certificate = NULL; +static char *_hssl_certpass = NULL; +static char *_hssl_ca_list = NULL; +static SSL_CTX *_hssl_context = NULL; +static int _hssl_enabled = 0; static int _hssl_dummy_verify_cert(X509 * cert) @@ -99,7 +98,7 @@ _hssl_dummy_verify_cert(X509 * cert) /* connect to anyone */ - log_verbose1("Validating certificate."); + log_verbose1("_Not_ validating certificate."); return 1; } @@ -176,12 +175,15 @@ _hssl_password_callback(char *buf, int num, int rwflag, void *userdata) { int ret; - ret = strlen(certpass); + if (!_hssl_certpass) + return 0; + + ret = strlen(_hssl_certpass); if (num < ret + 1) return 0; - strcpy(buf, certpass); + strcpy(buf, _hssl_certpass); return ret; } @@ -221,25 +223,34 @@ hssl_set_hssl_verify_cert(int func(X509 * cert)) } void -hssl_set_certificate(char *c) +hssl_set_certificate(const char *filename) { - certificate = c; + if (_hssl_certificate) + free(_hssl_certificate); + + _hssl_certificate = strdup(filename); return; } void -hssl_set_certpass(char *c) +hssl_set_certpass(const char *password) { - certpass = c; + if (_hssl_certpass) + free(_hssl_certpass); + + _hssl_certpass = strdup(password); return; } void -hssl_set_ca(char *c) +hssl_set_ca_list(const char *filename) { - ca_list = c; + if (_hssl_ca_list) + free(_hssl_ca_list); + + _hssl_ca_list = strdup(filename); return; } @@ -247,7 +258,7 @@ hssl_set_ca(char *c) void hssl_enable(void) { - enabled = 1; + _hssl_enabled = 1; return; } @@ -257,23 +268,23 @@ _hssl_parse_arguments(int argc, char **argv) { int i; - for (i = 1; i < argc; i++) + for (i=1; inum, out, outl);; } @@ -463,12 +491,12 @@ hssl_server_ssl(struct hsocket_t *sock) int ret; BIO *sbio; - if (!enabled) + if (!_hssl_enabled) return H_OK; log_verbose2("Starting SSL initialization for socket %d", sock->sock); - if (!(ssl = SSL_new(context))) + if (!(ssl = SSL_new(_hssl_context))) { log_warn1("SSL_new failed"); return herror_new("hssl_server_ssl", HSSL_ERROR_SERVER, @@ -530,7 +558,7 @@ hssl_read(struct hsocket_t * sock, char *buf, size_t len, size_t * received) if (sock->ssl) { if ((count = SSL_read(sock->ssl, buf, len)) < 1) - return herror_new("SSL_read", HSOCKET_ERROR_RECEIVE, + return herror_new("hssl_read", HSOCKET_ERROR_RECEIVE, "SSL_read failed (%s)", _hssl_get_error(sock->ssl, count)); } @@ -556,7 +584,7 @@ hssl_write(struct hsocket_t * sock, const char *buf, size_t len, size_t * sent) if (sock->ssl) { if ((count = SSL_write(sock->ssl, buf, len)) == -1) - return herror_new("SSL_write", HSOCKET_ERROR_SEND, + return herror_new("hssl_write", HSOCKET_ERROR_SEND, "SSL_write failed (%s)", _hssl_get_error(sock->ssl, count)); } diff --git a/nanohttp/nanohttp-ssl.h b/nanohttp/nanohttp-ssl.h index 6df53e7..8902ea3 100644 --- a/nanohttp/nanohttp-ssl.h +++ b/nanohttp/nanohttp-ssl.h @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: nanohttp-ssl.h,v 1.22 2006/11/27 12:47:27 m0gg Exp $ +* $Id: nanohttp-ssl.h,v 1.23 2006/11/30 14:24:00 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2001-2005 Rochester Institute of Technology @@ -51,9 +51,9 @@ extern herror_t hssl_module_init(int argc, char **argv); */ extern void hssl_module_destroy(void); -extern void hssl_set_certificate(char *c); -extern void hssl_set_certpass(char *c); -extern void hssl_set_ca(char *c); +extern void hssl_set_certificate(const char *filename); +extern void hssl_set_certpass(const char *password); +extern void hssl_set_ca_list(const char *filename); /** * diff --git a/nanohttp/nanohttp-stream.c b/nanohttp/nanohttp-stream.c index 59888d1..b121e57 100755 --- a/nanohttp/nanohttp-stream.c +++ b/nanohttp/nanohttp-stream.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: nanohttp-stream.c,v 1.17 2006/11/25 15:06:58 m0gg Exp $ +* $Id: nanohttp-stream.c,v 1.18 2006/11/30 14:24:00 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003-2004 Ferhat Ayaz @@ -570,19 +570,19 @@ http_output_stream_write(struct http_output_stream_t * stream, if (stream->type == HTTP_TRANSFER_CHUNKED) { sprintf(chunked, "%x\r\n", size); - if ((status = hsocket_send(stream->sock, chunked)) != H_OK) + if ((status = hsocket_send_string(stream->sock, chunked)) != H_OK) return status; } if (size > 0) { - if ((status = hsocket_nsend(stream->sock, bytes, size)) != H_OK) + if ((status = hsocket_send(stream->sock, bytes, size)) != H_OK) return status; } if (stream->type == HTTP_TRANSFER_CHUNKED) { - if ((status = hsocket_send(stream->sock, "\r\n")) != H_OK) + if ((status = hsocket_send_string(stream->sock, "\r\n")) != H_OK) return status; } @@ -608,7 +608,7 @@ http_output_stream_flush(struct http_output_stream_t * stream) if (stream->type == HTTP_TRANSFER_CHUNKED) { - if ((status = hsocket_send(stream->sock, "0\r\n\r\n")) != H_OK) + if ((status = hsocket_send_string(stream->sock, "0\r\n\r\n")) != H_OK) return status; } -- cgit v1.1-32-gdbae