diff options
author | snowdrop | 2004-10-28 10:30:41 +0000 |
---|---|---|
committer | snowdrop | 2004-10-28 10:30:41 +0000 |
commit | d24d6ab7bbfda8e302af3a5cf8be62299d543c1a (patch) | |
tree | d5da54889ad987c216d6767e39c65607b4b678e5 /nanohttp/nanohttp-request.c | |
parent | ebde083c541b5d202014c41450a3519f4d08e3c9 (diff) | |
download | csoap-d24d6ab7bbfda8e302af3a5cf8be62299d543c1a.tar.gz csoap-d24d6ab7bbfda8e302af3a5cf8be62299d543c1a.tar.bz2 |
changed hstatus_t to herror_t and chagend the API function to return herror_t. Added herror_*() functions and fixed a bug in the socket receive comm.
Diffstat (limited to 'nanohttp/nanohttp-request.c')
-rwxr-xr-x | nanohttp/nanohttp-request.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/nanohttp/nanohttp-request.c b/nanohttp/nanohttp-request.c index 0eb5a22..7661592 100755 --- a/nanohttp/nanohttp-request.c +++ b/nanohttp/nanohttp-request.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: nanohttp-request.c,v 1.2 2004/10/20 14:17:41 snowdrop Exp $ +* $Id: nanohttp-request.c,v 1.3 2004/10/28 10:30:46 snowdrop Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -217,10 +217,11 @@ hrequest_free(hrequest_t * req) } -hrequest_t * -hrequest_new_from_socket(hsocket_t sock) +herror_t +hrequest_new_from_socket(hsocket_t sock, hrequest_t **out) { - int i=0, status; + int i=0, readed;
+ herror_t status; hrequest_t *req; char buffer[MAX_HEADER_SIZE+1]; attachments_t *mimeMessage; @@ -228,11 +229,11 @@ hrequest_new_from_socket(hsocket_t sock) /* Read header */ while (i<MAX_HEADER_SIZE) { - status = hsocket_read(sock, &(buffer[i]), 1, 1); - if (status == -1) + status = hsocket_read(sock, &(buffer[i]), 1, 1, &readed); + if (status != H_OK) { log_error1("Socket read error"); - return NULL; + return status; } buffer[i+1] = '\0'; /* for strmp */ @@ -248,11 +249,7 @@ hrequest_new_from_socket(hsocket_t sock) /* Create response */ req = _hrequest_parse_header(buffer); - if (req == NULL) - { - log_error1("Header parse error"); - return NULL; - } + /* Create input stream */ req->in = http_input_stream_new(sock, req->header); @@ -266,7 +263,7 @@ hrequest_new_from_socket(hsocket_t sock) { /* TODO (#1#): Handle error */ hrequest_free(req); - return NULL; + return status; } else { @@ -275,8 +272,8 @@ hrequest_new_from_socket(hsocket_t sock) } } - - return req; + *out = req; + return H_OK; } |