318 |
|
|
319 |
/* XXX: do not use static buffers. */ |
/* XXX: do not use static buffers. */ |
320 |
memset (tmpbuf, 0, sizeof (tmpbuf)); |
memset (tmpbuf, 0, sizeof (tmpbuf)); |
321 |
strncpy (tmpbuf, _url, 512); |
strncpy (tmpbuf, _url, sizeof (tmpbuf)-1); |
322 |
|
|
323 |
p = "http://"; |
p = "http://"; |
324 |
if (strlen (_url) < 10 || strncmp (_url, p, 7)) |
if (strlen (_url) < 10 || strncmp (_url, p, 7)) |
345 |
char *p; |
char *p; |
346 |
char *fmt = "%s: %s"; |
char *fmt = "%s: %s"; |
347 |
|
|
348 |
p = (char*) malloc (strlen (name)+strlen (val)+strlen (fmt)+1); |
p = (char*) malloc (strlen (name)+strlen (val)+strlen (fmt)+4); |
349 |
sprintf (p, fmt, name, val); |
sprintf (p, fmt, name, val); |
350 |
addHeader (&req_headers, p); |
addHeader (&req_headers, p); |
351 |
free_if_malloc (p); |
free_if_malloc (p); |
392 |
} |
} |
393 |
|
|
394 |
if (*_url == '/') |
if (*_url == '/') |
395 |
url++; |
_url++; |
396 |
if (_url == NULL) |
if (_url == NULL) |
397 |
_url = ""; |
_url = ""; |
398 |
|
|
403 |
n = 0; |
n = 0; |
404 |
for (h = req_headers; h; h = h->next) |
for (h = req_headers; h; h = h->next) |
405 |
n += strlen (h->d) + 2 + 1; |
n += strlen (h->d) + 2 + 1; |
|
|
|
406 |
h_head = "%s /%s HTTP/1.%d\r\n"; |
h_head = "%s /%s HTTP/1.%d\r\n"; |
407 |
p = (char*)calloc (1, strlen (id[method]) + strlen (h_head) |
n += strlen (id[method]) + strlen (h_head) |
408 |
+ strlen (url) + n + 2 + 1 + 4); |
+ strlen (_url) + n + 2 + 1 + 4; |
409 |
|
p = (char*)calloc (1, n+1); |
410 |
if (!p) |
if (!p) |
411 |
BUG (0); |
BUG (0); |
412 |
sprintf (p, h_head, id[method], url, ver); |
sprintf (p, h_head, id[method], _url, ver); |
413 |
for (h = req_headers; h; h = h->next) { |
for (h = req_headers; h; h = h->next) { |
414 |
strcat (p, h->d); |
strcat (p, h->d); |
415 |
strcat (p, "\r\n"); |
strcat (p, "\r\n"); |
416 |
} |
} |
417 |
strcat (p, "\r\n"); |
strcat (p, "\r\n"); |
|
printf ("p='%s'\n", p); |
|
418 |
n = send (fd, p, strlen (p), 0); |
n = send (fd, p, strlen (p), 0); |
419 |
free_if_malloc (p); |
free_if_malloc (p); |
420 |
return n > 0? 0 : WPTERR_GENERAL; |
return n > 0? 0 : WPTERR_GENERAL; |
543 |
/* Destroy HTTP object. */ |
/* Destroy HTTP object. */ |
544 |
wHTTP::~wHTTP (void) |
wHTTP::~wHTTP (void) |
545 |
{ |
{ |
|
|
|
546 |
http_head_t h; |
http_head_t h; |
547 |
|
|
548 |
while (resp_headers) { |
while (resp_headers) { |