356
char *newhost = strstr(url, "://");
360
newhost = strdup(newhost);
361
t = newhost + strcspn(newhost, "@/?");
364
t = newhost + strcspn(newhost, "@/?");
356
char *newhost = strstr(url, "://");
360
newhost = strdup(newhost);
361
t = newhost + strcspn(newhost, "@/?");
364
t = newhost + strcspn(newhost, "@/?");
371
if(version[0] == '-' || !version[0] || version[0] == '0') {
372
/* HTTP/0.9, no headers, no version */
371
if (version[0] == '-' || !version[0] || version[0] == '0') {
372
/* HTTP/0.9, no headers, no version */
373
373
snprintf(msg, BUFSIZ, "%s %s\r\n", method, url);
375
375
snprintf(msg, BUFSIZ, "%s %s HTTP/%s\r\n", method, url, version);
378
snprintf(buf, BUFSIZ, "Host: %s\r\n", host);
383
snprintf(buf, BUFSIZ, "Pragma: no-cache\r\n");
387
snprintf(buf, BUFSIZ, "Content-length: %d\r\n", (int) sb.st_size);
390
if (opt_noaccept == 0) {
391
snprintf(buf, BUFSIZ, "Accept: */*\r\n");
395
snprintf(buf, BUFSIZ, "If-Modified-Since: %s\r\n", mkrfc1123(ims));
398
if (max_forwards > -1) {
399
snprintf(buf, BUFSIZ, "Max-Forwards: %d\r\n", max_forwards);
403
const char *user = proxy_user;
404
const char *password = proxy_password;
407
password = getpass("Proxy password: ");
410
fprintf(stderr, "ERROR: Proxy password missing\n");
413
snprintf(buf, BUFSIZ, "%s:%s", user, password);
414
snprintf(buf, BUFSIZ, "Proxy-Authorization: Basic %s\r\n", base64_encode(buf));
418
const char *user = www_user;
419
const char *password = www_password;
422
password = getpass("WWW password: ");
425
fprintf(stderr, "ERROR: WWW password missing\n");
428
snprintf(buf, BUFSIZ, "%s:%s", user, password);
429
snprintf(buf, BUFSIZ, "Authorization: Basic %s\r\n", base64_encode(buf));
433
/* HTTP/1.0 may need keep-alive */
434
if (strcmp(version, "1.0") == 0) {
436
if (strchr(url, ':'))
437
snprintf(buf, BUFSIZ, "Proxy-Connection: keep-alive\r\n");
439
strcat(msg, "Connection: keep-alive\r\n");
443
strcat(msg, "Connection: close\r\n");
447
strcat(msg, extra_hdrs);
378
snprintf(buf, BUFSIZ, "Host: %s\r\n", host);
383
snprintf(buf, BUFSIZ, "Pragma: no-cache\r\n");
387
snprintf(buf, BUFSIZ, "Content-length: %d\r\n", (int) sb.st_size);
390
if (opt_noaccept == 0) {
391
snprintf(buf, BUFSIZ, "Accept: */*\r\n");
395
snprintf(buf, BUFSIZ, "If-Modified-Since: %s\r\n", mkrfc1123(ims));
398
if (max_forwards > -1) {
399
snprintf(buf, BUFSIZ, "Max-Forwards: %d\r\n", max_forwards);
403
const char *user = proxy_user;
404
const char *password = proxy_password;
407
password = getpass("Proxy password: ");
410
fprintf(stderr, "ERROR: Proxy password missing\n");
413
snprintf(buf, BUFSIZ, "%s:%s", user, password);
414
snprintf(buf, BUFSIZ, "Proxy-Authorization: Basic %s\r\n", base64_encode(buf));
418
const char *user = www_user;
419
const char *password = www_password;
422
password = getpass("WWW password: ");
425
fprintf(stderr, "ERROR: WWW password missing\n");
428
snprintf(buf, BUFSIZ, "%s:%s", user, password);
429
snprintf(buf, BUFSIZ, "Authorization: Basic %s\r\n", base64_encode(buf));
433
/* HTTP/1.0 may need keep-alive */
434
if (strcmp(version, "1.0") == 0) {
436
if (strchr(url, ':'))
437
snprintf(buf, BUFSIZ, "Proxy-Connection: keep-alive\r\n");
439
strcat(msg, "Connection: keep-alive\r\n");
443
strcat(msg, "Connection: close\r\n");
447
strcat(msg, extra_hdrs);