version 1.34, 2001/06/23 22:48:44 |
version 1.35, 2001/10/03 18:49:39 |
|
|
errx(1, "Can't allocate memory."); |
errx(1, "Can't allocate memory."); |
if ((p = strchr(h, '%')) != NULL) |
if ((p = strchr(h, '%')) != NULL) |
*p = '\0'; |
*p = '\0'; |
snprintf(buf, sizeof(buf), |
/* |
"GET /%s HTTP/1.0\r\nHost: [%s]%s%s\r\n\r\n", |
* Send port number only if it's specified and does not equal |
path, h, port ? ":" : "", port ? port : ""); |
* 80. Some broken HTTP servers get confused if you explicitly |
|
* send them the port number. |
|
*/ |
|
if (port && strcmp(port, "80") != 0) |
|
snprintf(buf, sizeof(buf), |
|
"GET /%s HTTP/1.0\r\nHost: [%s]:%s\r\n\r\n", |
|
path, h, port); |
|
else |
|
snprintf(buf, sizeof(buf), |
|
"GET /%s HTTP/1.0\r\nHost: [%s]\r\n\r\n", |
|
path, h); |
free(h); |
free(h); |
} else { |
} else { |
snprintf(buf, sizeof(buf), |
if (port && strcmp(port, "80") != 0) |
"GET /%s HTTP/1.0\r\nHost: %s%s%s\r\n\r\n", |
snprintf(buf, sizeof(buf), |
path, host, port ? ":" : "", port ? port : ""); |
"GET /%s HTTP/1.0\r\nHost: %s:%s\r\n\r\n", |
|
path, host, port); |
|
else |
|
snprintf(buf, sizeof(buf), |
|
"GET /%s HTTP/1.0\r\nHost: %s\r\n\r\n", |
|
path, host); |
} |
} |
} |
} |
len = strlen(buf); |
len = strlen(buf); |
|
if (debug) |
|
fprintf(ttyout, "Sending request:\n%s", buf); |
if (write(s, buf, len) < len) { |
if (write(s, buf, len) < len) { |
warn("Writing HTTP request"); |
warn("Writing HTTP request"); |
goto cleanup_url_get; |
goto cleanup_url_get; |