From 9b582c4a2767fdadbf5e8e9ea7ebeb269f623f22 Mon Sep 17 00:00:00 2001 From: snowdrop Date: Wed, 17 Dec 2003 12:55:02 +0000 Subject: added connection close recv. fixed chunked encoding --- nanohttp/nanohttp-socket.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'nanohttp/nanohttp-socket.c') diff --git a/nanohttp/nanohttp-socket.c b/nanohttp/nanohttp-socket.c index 9974e76..9aaca65 100644 --- a/nanohttp/nanohttp-socket.c +++ b/nanohttp/nanohttp-socket.c @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: nanohttp-socket.c,v 1.3 2003/12/16 14:12:58 snowdrop Exp $ + * $Id: nanohttp-socket.c,v 1.4 2003/12/17 12:55:02 snowdrop Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -380,15 +380,25 @@ int hbufsocket_read(hbufsocket_t *bufsock, char *buffer, int size) size -= tmpsize; free(bufsock->buffer); - status = recv(bufsock->sock, bufsock->buffer, size, 0); - if (status > 0) { + /* + status = recv(bufsock->sock, bufsock->buffer, size, 0); + if (status > 0) { bufsock->bufsize = size; bufsock->cur = size; strncpy(&buffer[tmpsize], bufsock->buffer, size); + } else { + return status; + } + */ + status = hsocket_read(bufsock->sock, &buffer[tmpsize], size, 1); + if (status == size) { + bufsock->buffer = (char*)malloc(size+1); + strncpy(bufsock->buffer, &buffer[tmpsize], size); + bufsock->cur = size; } else { return status; } - + return HSOCKET_OK; } } -- cgit v1.1-32-gdbae