~ubuntu-branches/ubuntu/dapper/monit/dapper

« back to all changes in this revision

Viewing changes to protocols/http.c

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Alfredsson
  • Date: 2005-11-11 21:04:32 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051111210432-uqstfeqxun0vvn1j
Tags: 1:4.6-1
New upstream release (Closes: #306259, #308369, #315638)

Show diffs side-by-side

added added

removed removed

Lines of Context:
73
73
 *
74
74
 *  @author Jan-Henrik Haukeland, <hauk@tildeslash.com>
75
75
 *  @author Martin Pala, <martinp@tildeslash.com>
76
 
 *  @version \$Id: http.c,v 1.42 2005/03/23 22:57:34 hauk Exp $
 
76
 *  @version \$Id: http.c,v 1.47 2005/08/05 09:38:10 chopp Exp $
77
77
 *  @file
78
78
 */
79
79
 
274
274
static int do_regex(Http_T *H, Request_T R) {
275
275
 
276
276
  int n;
 
277
  int size= 0;
277
278
  int rv= TRUE;
278
 
  unsigned char *buf= NULL;
 
279
  int length= 0;
 
280
  char *buf= NULL;
279
281
#ifdef HAVE_REGEX_H
280
282
  int regex_return;
281
283
#else
295
297
    H->content_length= HTTP_CONTENT_MAX;
296
298
  else if(H->content_length > HTTP_CONTENT_MAX)
297
299
    H->content_length= HTTP_CONTENT_MAX;
298
 
    
299
 
  buf= xmalloc(H->content_length);
300
 
 
301
 
  n= socket_read(H->s, buf, H->content_length);
302
 
  if(n<=0) {
 
300
  
 
301
  n= 0;
 
302
  size= 0;
 
303
  length= H->content_length;
 
304
  buf= xmalloc(H->content_length + 1);
 
305
  
 
306
  do {
 
307
      n= socket_read(H->s, &buf[size], length);
 
308
      if(n<=0)
 
309
        break;
 
310
      size+= n;
 
311
      length-= n;
 
312
  } while(length>0);
 
313
  
 
314
  if(size==0) {
303
315
    rv= FALSE;
304
316
    log("HTTP: error receiving data -- %s\n", STRERROR);
305
317
    goto error;
306
318
  }
307
 
  buf[n]= 0;
 
319
  buf[size]= 0;
308
320
 
309
321
#ifdef HAVE_REGEX_H
310
322
 
373
385
/* -------------------------------------------------------- State management */
374
386
 
375
387
 
 
388
/*
 
389
 * Follow redirect responses from the server. 
 
390
 */
376
391
static int do_redirect(Http_T *H) {
377
392
 
378
393
  char host[STRLEN];
379
394
  char auth[STRLEN]= {0};
380
395
  Port_T P= socket_get_Port(H->s);
381
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
  
382
406
  if(!*H->location) {
383
407
    DEBUG("HTTP error: Missing Location header in response\n");
384
408
    return FALSE;