297 |
H->content_length= HTTP_CONTENT_MAX; |
H->content_length= HTTP_CONTENT_MAX; |
298 |
else if(H->content_length > HTTP_CONTENT_MAX) |
else if(H->content_length > HTTP_CONTENT_MAX) |
299 |
H->content_length= HTTP_CONTENT_MAX; |
H->content_length= HTTP_CONTENT_MAX; |
300 |
|
|
301 |
n= 0; |
n= 0; |
302 |
size= 0; |
size= 0; |
303 |
length= H->content_length; |
length= H->content_length; |
304 |
buf= xmalloc(H->content_length); |
buf= xmalloc(H->content_length); |
305 |
|
|
306 |
do { |
do { |
307 |
n= socket_read(H->s, &buf[size], length); |
n= socket_read(H->s, &buf[size], length); |
308 |
if(n<=0) |
if(n<=0) |
310 |
size+= n; |
size+= n; |
311 |
length-= n; |
length-= n; |
312 |
} while(length>0); |
} while(length>0); |
313 |
|
|
314 |
if(size==0) { |
if(size==0) { |
315 |
rv= FALSE; |
rv= FALSE; |
316 |
log("HTTP: error receiving data -- %s\n", STRERROR); |
log("HTTP: error receiving data -- %s\n", STRERROR); |
386 |
|
|
387 |
|
|
388 |
/* |
/* |
389 |
* Follow redirect responses from the server. FIXME: there is a |
* Follow redirect responses from the server. |
|
* BIG shortcoming here since the code only follow redirects on the |
|
|
* same server. What we need to do is to open a new socket against |
|
|
* the server in the location header. This may provide problems since |
|
|
* the socket is owned by the caller. Anyway, do investigate this further. |
|
390 |
*/ |
*/ |
391 |
static int do_redirect(Http_T *H) { |
static int do_redirect(Http_T *H) { |
392 |
|
|
394 |
char auth[STRLEN]= {0}; |
char auth[STRLEN]= {0}; |
395 |
Port_T P= socket_get_Port(H->s); |
Port_T P= socket_get_Port(H->s); |
396 |
|
|
397 |
|
|
398 |
|
/* |
399 |
|
* FIXME: there is a |
400 |
|
* BIG shortcoming here since the code only follow redirects on the |
401 |
|
* same server. What we need to do is to open a new socket against |
402 |
|
* the server in the location header. This may provide problems since |
403 |
|
* the socket is owned by the caller. Anyway, do investigate this further. |
404 |
|
*/ |
405 |
|
|
406 |
if(!*H->location) { |
if(!*H->location) { |
407 |
DEBUG("HTTP error: Missing Location header in response\n"); |
DEBUG("HTTP error: Missing Location header in response\n"); |
408 |
return FALSE; |
return FALSE; |