Lines Matching +full:proxy +full:- +full:from +full:- +full:env
82 #define INVALID_SOCKET (-1)
120 char *inptr; /* the next byte to read from network */
126 int ContentLength; /* specified content length from HTTP header */
129 char *authHeader; /* contents of {WWW,Proxy}-Authenticate header */
130 char *encoding; /* encoding extracted from the contentType */
131 char *mimeType; /* Mime-Type extracted from the contentType */
134 int usesGzip; /* "Content-Encoding: gzip" was detected */
139 static char *proxy = NULL; /* the proxy name if any */ variable
140 static int proxyPort; /* the proxy port if any */
186 * Currently it just checks for proxy information
191 const char *env; in xmlNanoHTTPInit() local
204 if (proxy == NULL) { in xmlNanoHTTPInit()
206 env = getenv("no_proxy"); in xmlNanoHTTPInit()
207 if (env && ((env[0] == '*') && (env[1] == 0))) in xmlNanoHTTPInit()
209 env = getenv("http_proxy"); in xmlNanoHTTPInit()
210 if (env != NULL) { in xmlNanoHTTPInit()
211 xmlNanoHTTPScanProxy(env); in xmlNanoHTTPInit()
214 env = getenv("HTTP_PROXY"); in xmlNanoHTTPInit()
215 if (env != NULL) { in xmlNanoHTTPInit()
216 xmlNanoHTTPScanProxy(env); in xmlNanoHTTPInit()
232 if (proxy != NULL) { in xmlNanoHTTPCleanup()
233 xmlFree(proxy); in xmlNanoHTTPCleanup()
234 proxy = NULL; in xmlNanoHTTPCleanup()
259 * Clear any existing data from the context in xmlNanoHTTPScanURL()
261 if (ctxt->protocol != NULL) { in xmlNanoHTTPScanURL()
262 xmlFree(ctxt->protocol); in xmlNanoHTTPScanURL()
263 ctxt->protocol = NULL; in xmlNanoHTTPScanURL()
265 if (ctxt->hostname != NULL) { in xmlNanoHTTPScanURL()
266 xmlFree(ctxt->hostname); in xmlNanoHTTPScanURL()
267 ctxt->hostname = NULL; in xmlNanoHTTPScanURL()
269 if (ctxt->path != NULL) { in xmlNanoHTTPScanURL()
270 xmlFree(ctxt->path); in xmlNanoHTTPScanURL()
271 ctxt->path = NULL; in xmlNanoHTTPScanURL()
273 if (ctxt->query != NULL) { in xmlNanoHTTPScanURL()
274 xmlFree(ctxt->query); in xmlNanoHTTPScanURL()
275 ctxt->query = NULL; in xmlNanoHTTPScanURL()
283 if ((uri->scheme == NULL) || (uri->server == NULL)) { in xmlNanoHTTPScanURL()
288 ctxt->protocol = xmlMemStrdup(uri->scheme); in xmlNanoHTTPScanURL()
290 if ((uri->server != NULL) && (*uri->server == '[')) { in xmlNanoHTTPScanURL()
291 len = strlen(uri->server); in xmlNanoHTTPScanURL()
292 if ((len > 2) && (uri->server[len - 1] == ']')) { in xmlNanoHTTPScanURL()
293 ctxt->hostname = (char *) xmlCharStrndup(uri->server + 1, len -2); in xmlNanoHTTPScanURL()
295 ctxt->hostname = xmlMemStrdup(uri->server); in xmlNanoHTTPScanURL()
297 ctxt->hostname = xmlMemStrdup(uri->server); in xmlNanoHTTPScanURL()
298 if (uri->path != NULL) in xmlNanoHTTPScanURL()
299 ctxt->path = xmlMemStrdup(uri->path); in xmlNanoHTTPScanURL()
301 ctxt->path = xmlMemStrdup("/"); in xmlNanoHTTPScanURL()
302 if (uri->query != NULL) in xmlNanoHTTPScanURL()
303 ctxt->query = xmlMemStrdup(uri->query); in xmlNanoHTTPScanURL()
304 if (uri->port != 0) in xmlNanoHTTPScanURL()
305 ctxt->port = uri->port; in xmlNanoHTTPScanURL()
312 * @URL: The proxy URL used to initialize the proxy context
314 * (Re)Initialize the HTTP Proxy context by parsing the URL and finding
317 * A NULL URL cleans up proxy information.
324 if (proxy != NULL) { in xmlNanoHTTPScanProxy()
325 xmlFree(proxy); in xmlNanoHTTPScanProxy()
326 proxy = NULL; in xmlNanoHTTPScanProxy()
333 if ((uri == NULL) || (uri->scheme == NULL) || in xmlNanoHTTPScanProxy()
334 (strcmp(uri->scheme, "http")) || (uri->server == NULL)) { in xmlNanoHTTPScanProxy()
341 proxy = xmlMemStrdup(uri->server); in xmlNanoHTTPScanProxy()
342 if (uri->port != 0) in xmlNanoHTTPScanProxy()
343 proxyPort = uri->port; in xmlNanoHTTPScanProxy()
368 ret->port = 80; in xmlNanoHTTPNewCtxt()
369 ret->returnValue = 0; in xmlNanoHTTPNewCtxt()
370 ret->fd = INVALID_SOCKET; in xmlNanoHTTPNewCtxt()
371 ret->ContentLength = -1; in xmlNanoHTTPNewCtxt()
388 if (ctxt->hostname != NULL) xmlFree(ctxt->hostname); in xmlNanoHTTPFreeCtxt()
389 if (ctxt->protocol != NULL) xmlFree(ctxt->protocol); in xmlNanoHTTPFreeCtxt()
390 if (ctxt->path != NULL) xmlFree(ctxt->path); in xmlNanoHTTPFreeCtxt()
391 if (ctxt->query != NULL) xmlFree(ctxt->query); in xmlNanoHTTPFreeCtxt()
392 if (ctxt->out != NULL) xmlFree(ctxt->out); in xmlNanoHTTPFreeCtxt()
393 if (ctxt->in != NULL) xmlFree(ctxt->in); in xmlNanoHTTPFreeCtxt()
394 if (ctxt->contentType != NULL) xmlFree(ctxt->contentType); in xmlNanoHTTPFreeCtxt()
395 if (ctxt->encoding != NULL) xmlFree(ctxt->encoding); in xmlNanoHTTPFreeCtxt()
396 if (ctxt->mimeType != NULL) xmlFree(ctxt->mimeType); in xmlNanoHTTPFreeCtxt()
397 if (ctxt->location != NULL) xmlFree(ctxt->location); in xmlNanoHTTPFreeCtxt()
398 if (ctxt->authHeader != NULL) xmlFree(ctxt->authHeader); in xmlNanoHTTPFreeCtxt()
400 if (ctxt->strm != NULL) { in xmlNanoHTTPFreeCtxt()
401 inflateEnd(ctxt->strm); in xmlNanoHTTPFreeCtxt()
402 xmlFree(ctxt->strm); in xmlNanoHTTPFreeCtxt()
406 ctxt->state = XML_NANO_HTTP_NONE; in xmlNanoHTTPFreeCtxt()
407 if (ctxt->fd != INVALID_SOCKET) closesocket(ctxt->fd); in xmlNanoHTTPFreeCtxt()
408 ctxt->fd = INVALID_SOCKET; in xmlNanoHTTPFreeCtxt()
417 * Returns number of bytes sent or -1 on error.
431 if ((ctxt->state & XML_NANO_HTTP_WRITE) && (xmt_ptr != NULL)) { in xmlNanoHTTPSend()
433 int nsent = send(ctxt->fd, SEND_ARG2_CAST (xmt_ptr + total_sent), in xmlNanoHTTPSend()
434 outlen - total_sent, 0); in xmlNanoHTTPSend()
438 else if ((nsent == -1) && in xmlNanoHTTPSend()
445 total_sent = -1; in xmlNanoHTTPSend()
450 * Since non-blocking sockets are used, wait for in xmlNanoHTTPSend()
456 if (ctxt->fd > FD_SETSIZE) in xmlNanoHTTPSend()
457 return -1; in xmlNanoHTTPSend()
467 FD_SET(ctxt->fd, &wfd); in xmlNanoHTTPSend()
471 (void) select(ctxt->fd + 1, NULL, &wfd, NULL, &tv); in xmlNanoHTTPSend()
473 p.fd = ctxt->fd; in xmlNanoHTTPSend()
488 * Read information coming from the HTTP connection.
491 * Returns the number of byte read or -1 in case of error.
505 while (ctxt->state & XML_NANO_HTTP_READ) { in xmlNanoHTTPRecv()
506 if (ctxt->in == NULL) { in xmlNanoHTTPRecv()
507 ctxt->in = (char *) xmlMallocAtomic(65000); in xmlNanoHTTPRecv()
508 if (ctxt->in == NULL) { in xmlNanoHTTPRecv()
510 ctxt->last = -1; in xmlNanoHTTPRecv()
511 return (-1); in xmlNanoHTTPRecv()
513 ctxt->inlen = 65000; in xmlNanoHTTPRecv()
514 ctxt->inptr = ctxt->content = ctxt->inrptr = ctxt->in; in xmlNanoHTTPRecv()
516 if (ctxt->inrptr > ctxt->in + XML_NANO_HTTP_CHUNK) { in xmlNanoHTTPRecv()
517 int delta = ctxt->inrptr - ctxt->in; in xmlNanoHTTPRecv()
518 int len = ctxt->inptr - ctxt->inrptr; in xmlNanoHTTPRecv()
520 memmove(ctxt->in, ctxt->inrptr, len); in xmlNanoHTTPRecv()
521 ctxt->inrptr -= delta; in xmlNanoHTTPRecv()
522 ctxt->content -= delta; in xmlNanoHTTPRecv()
523 ctxt->inptr -= delta; in xmlNanoHTTPRecv()
525 if ((ctxt->in + ctxt->inlen) < (ctxt->inptr + XML_NANO_HTTP_CHUNK)) { in xmlNanoHTTPRecv()
526 int d_inptr = ctxt->inptr - ctxt->in; in xmlNanoHTTPRecv()
527 int d_content = ctxt->content - ctxt->in; in xmlNanoHTTPRecv()
528 int d_inrptr = ctxt->inrptr - ctxt->in; in xmlNanoHTTPRecv()
529 char *tmp_ptr = ctxt->in; in xmlNanoHTTPRecv()
531 ctxt->inlen *= 2; in xmlNanoHTTPRecv()
532 ctxt->in = (char *) xmlRealloc(tmp_ptr, ctxt->inlen); in xmlNanoHTTPRecv()
533 if (ctxt->in == NULL) { in xmlNanoHTTPRecv()
536 ctxt->last = -1; in xmlNanoHTTPRecv()
537 return (-1); in xmlNanoHTTPRecv()
539 ctxt->inptr = ctxt->in + d_inptr; in xmlNanoHTTPRecv()
540 ctxt->content = ctxt->in + d_content; in xmlNanoHTTPRecv()
541 ctxt->inrptr = ctxt->in + d_inrptr; in xmlNanoHTTPRecv()
543 ctxt->last = recv(ctxt->fd, ctxt->inptr, XML_NANO_HTTP_CHUNK, 0); in xmlNanoHTTPRecv()
544 if (ctxt->last > 0) { in xmlNanoHTTPRecv()
545 ctxt->inptr += ctxt->last; in xmlNanoHTTPRecv()
546 return (ctxt->last); in xmlNanoHTTPRecv()
548 if (ctxt->last == 0) { in xmlNanoHTTPRecv()
551 if (ctxt->last == -1) { in xmlNanoHTTPRecv()
566 return (-1); in xmlNanoHTTPRecv()
570 p.fd = ctxt->fd; in xmlNanoHTTPRecv()
580 if (ctxt->fd > FD_SETSIZE) in xmlNanoHTTPRecv()
593 FD_SET(ctxt->fd, &rfd); in xmlNanoHTTPRecv()
599 if ((select(ctxt->fd + 1, &rfd, NULL, NULL, &tv) < 1) in xmlNanoHTTPRecv()
615 * the HTTP protocol information from the answer header.
627 while (bp - buf < 4095) { in xmlNanoHTTPReadLine()
628 if (ctxt->inrptr == ctxt->inptr) { in xmlNanoHTTPReadLine()
636 else if ( rc == -1 ) { in xmlNanoHTTPReadLine()
640 *bp = *ctxt->inrptr++; in xmlNanoHTTPReadLine()
658 * Try to extract useful information from the server answer.
660 * - The HTTP revision/ return code
661 * - The Content-Type, Mime-Type and charset used
662 * - The Location for redirect processing.
664 * Returns -1 in case of failure, the file descriptor number otherwise
680 version += *cur - '0'; in xmlNanoHTTPScanAnswer()
687 version += *cur - '0'; in xmlNanoHTTPScanAnswer()
699 ret += *cur - '0'; in xmlNanoHTTPScanAnswer()
703 ctxt->returnValue = ret; in xmlNanoHTTPScanAnswer()
704 ctxt->version = version; in xmlNanoHTTPScanAnswer()
705 } else if (!xmlStrncasecmp(BAD_CAST line, BAD_CAST"Content-Type:", 13)) { in xmlNanoHTTPScanAnswer()
709 if (ctxt->contentType != NULL) in xmlNanoHTTPScanAnswer()
710 xmlFree(ctxt->contentType); in xmlNanoHTTPScanAnswer()
711 ctxt->contentType = xmlMemStrdup(cur); in xmlNanoHTTPScanAnswer()
717 if (ctxt->mimeType != NULL) in xmlNanoHTTPScanAnswer()
718 xmlFree(ctxt->mimeType); in xmlNanoHTTPScanAnswer()
719 ctxt->mimeType = (char *) xmlStrndup(mime, last - mime); in xmlNanoHTTPScanAnswer()
720 charset = xmlStrstr(BAD_CAST ctxt->contentType, BAD_CAST "charset="); in xmlNanoHTTPScanAnswer()
727 if (ctxt->encoding != NULL) in xmlNanoHTTPScanAnswer()
728 xmlFree(ctxt->encoding); in xmlNanoHTTPScanAnswer()
729 ctxt->encoding = (char *) xmlStrndup(charset, last - charset); in xmlNanoHTTPScanAnswer()
734 if (ctxt->contentType != NULL) return; in xmlNanoHTTPScanAnswer()
736 ctxt->contentType = xmlMemStrdup(cur); in xmlNanoHTTPScanAnswer()
742 if (ctxt->mimeType != NULL) in xmlNanoHTTPScanAnswer()
743 xmlFree(ctxt->mimeType); in xmlNanoHTTPScanAnswer()
744 ctxt->mimeType = (char *) xmlStrndup(mime, last - mime); in xmlNanoHTTPScanAnswer()
745 charset = xmlStrstr(BAD_CAST ctxt->contentType, BAD_CAST "charset="); in xmlNanoHTTPScanAnswer()
752 if (ctxt->encoding != NULL) in xmlNanoHTTPScanAnswer()
753 xmlFree(ctxt->encoding); in xmlNanoHTTPScanAnswer()
754 ctxt->encoding = (char *) xmlStrndup(charset, last - charset); in xmlNanoHTTPScanAnswer()
759 if (ctxt->location != NULL) in xmlNanoHTTPScanAnswer()
760 xmlFree(ctxt->location); in xmlNanoHTTPScanAnswer()
764 xmlStrcat(tmp_http, (const xmlChar *) ctxt->hostname); in xmlNanoHTTPScanAnswer()
765 ctxt->location = in xmlNanoHTTPScanAnswer()
768 ctxt->location = xmlMemStrdup(cur); in xmlNanoHTTPScanAnswer()
770 } else if (!xmlStrncasecmp(BAD_CAST line, BAD_CAST"WWW-Authenticate:", 17)) { in xmlNanoHTTPScanAnswer()
773 if (ctxt->authHeader != NULL) in xmlNanoHTTPScanAnswer()
774 xmlFree(ctxt->authHeader); in xmlNanoHTTPScanAnswer()
775 ctxt->authHeader = xmlMemStrdup(cur); in xmlNanoHTTPScanAnswer()
776 } else if (!xmlStrncasecmp(BAD_CAST line, BAD_CAST"Proxy-Authenticate:", 19)) { in xmlNanoHTTPScanAnswer()
779 if (ctxt->authHeader != NULL) in xmlNanoHTTPScanAnswer()
780 xmlFree(ctxt->authHeader); in xmlNanoHTTPScanAnswer()
781 ctxt->authHeader = xmlMemStrdup(cur); in xmlNanoHTTPScanAnswer()
783 } else if ( !xmlStrncasecmp( BAD_CAST line, BAD_CAST"Content-Encoding:", 17) ) { in xmlNanoHTTPScanAnswer()
787 ctxt->usesGzip = 1; in xmlNanoHTTPScanAnswer()
789 ctxt->strm = xmlMalloc(sizeof(z_stream)); in xmlNanoHTTPScanAnswer()
791 if (ctxt->strm != NULL) { in xmlNanoHTTPScanAnswer()
792 ctxt->strm->zalloc = Z_NULL; in xmlNanoHTTPScanAnswer()
793 ctxt->strm->zfree = Z_NULL; in xmlNanoHTTPScanAnswer()
794 ctxt->strm->opaque = Z_NULL; in xmlNanoHTTPScanAnswer()
795 ctxt->strm->avail_in = 0; in xmlNanoHTTPScanAnswer()
796 ctxt->strm->next_in = Z_NULL; in xmlNanoHTTPScanAnswer()
798 inflateInit2( ctxt->strm, 31 ); in xmlNanoHTTPScanAnswer()
802 } else if ( !xmlStrncasecmp( BAD_CAST line, BAD_CAST"Content-Length:", 15) ) { in xmlNanoHTTPScanAnswer()
804 ctxt->ContentLength = strtol( cur, NULL, 10 ); in xmlNanoHTTPScanAnswer()
813 * non-blocking semantic on the socket, and allow 60 seconds for
816 * Returns -1 in case of failure, the file descriptor number otherwise
838 if (addr->sa_family == AF_INET6) { in xmlNanoHTTPConnectAttempt()
855 status = ioctlsocket(s, FIONBIO, &one) == SOCKET_ERROR ? -1 : 0; in xmlNanoHTTPConnectAttempt()
865 if ((status = fcntl(s, F_GETFL, 0)) != -1) { in xmlNanoHTTPConnectAttempt()
876 __xmlIOErr(XML_FROM_HTTP, 0, "error setting non-blocking IO\n"); in xmlNanoHTTPConnectAttempt()
883 if (connect(s, addr, addrlen) == -1) { in xmlNanoHTTPConnectAttempt()
934 case -1: in xmlNanoHTTPConnectAttempt()
988 * Returns -1 in case of failure, the file descriptor number otherwise
1021 for (res = result; res; res = res->ai_next) { in xmlNanoHTTPConnectHost()
1022 if (res->ai_family == AF_INET) { in xmlNanoHTTPConnectHost()
1023 if ((size_t)res->ai_addrlen > sizeof(sockin)) { in xmlNanoHTTPConnectHost()
1028 memcpy (&sockin, res->ai_addr, res->ai_addrlen); in xmlNanoHTTPConnectHost()
1031 } else if (res->ai_family == AF_INET6) { in xmlNanoHTTPConnectHost()
1032 if ((size_t)res->ai_addrlen > sizeof(sockin6)) { in xmlNanoHTTPConnectHost()
1037 memcpy (&sockin6, res->ai_addr, res->ai_addrlen); in xmlNanoHTTPConnectHost()
1063 * Okay, I got fed up by the non-portability of this error message in xmlNanoHTTPConnectHost()
1077 "Non-authoritative host not found or server failure."; in xmlNanoHTTPConnectHost()
1082 "Non-recoverable errors: FORMERR, REFUSED, or NOTIMP."; in xmlNanoHTTPConnectHost()
1103 for (i = 0; h->h_addr_list[i]; i++) { in xmlNanoHTTPConnectHost()
1104 if (h->h_addrtype == AF_INET) { in xmlNanoHTTPConnectHost()
1106 if ((unsigned int) h->h_length > sizeof(ia)) { in xmlNanoHTTPConnectHost()
1110 memcpy (&ia, h->h_addr_list[i], h->h_length); in xmlNanoHTTPConnectHost()
1111 sockin.sin_family = h->h_addrtype; in xmlNanoHTTPConnectHost()
1132 * @contentType: if available the Content-Type information will be
1151 * @contentType: if available the Content-Type information will be
1175 * This function tries to read @len bytes from the existing HTTP connection
1179 * -1 indicates a parameter error.
1190 if (ctx == NULL) return(-1); in xmlNanoHTTPRead()
1191 if (dest == NULL) return(-1); in xmlNanoHTTPRead()
1195 if (ctxt->usesGzip == 1) { in xmlNanoHTTPRead()
1196 if (ctxt->strm == NULL) return(0); in xmlNanoHTTPRead()
1198 ctxt->strm->next_out = dest; in xmlNanoHTTPRead()
1199 ctxt->strm->avail_out = len; in xmlNanoHTTPRead()
1200 ctxt->strm->avail_in = ctxt->inptr - ctxt->inrptr; in xmlNanoHTTPRead()
1202 while (ctxt->strm->avail_out > 0 && in xmlNanoHTTPRead()
1203 (ctxt->strm->avail_in > 0 || xmlNanoHTTPRecv(ctxt) > 0)) { in xmlNanoHTTPRead()
1204 orig_avail_in = ctxt->strm->avail_in = in xmlNanoHTTPRead()
1205 ctxt->inptr - ctxt->inrptr - bytes_read; in xmlNanoHTTPRead()
1206 ctxt->strm->next_in = BAD_CAST (ctxt->inrptr + bytes_read); in xmlNanoHTTPRead()
1208 z_ret = inflate(ctxt->strm, Z_NO_FLUSH); in xmlNanoHTTPRead()
1209 bytes_read += orig_avail_in - ctxt->strm->avail_in; in xmlNanoHTTPRead()
1214 ctxt->inrptr += bytes_read; in xmlNanoHTTPRead()
1215 return(len - ctxt->strm->avail_out); in xmlNanoHTTPRead()
1219 while (ctxt->inptr - ctxt->inrptr < len) { in xmlNanoHTTPRead()
1222 if (ctxt->inptr - ctxt->inrptr < len) in xmlNanoHTTPRead()
1223 len = ctxt->inptr - ctxt->inrptr; in xmlNanoHTTPRead()
1225 memcpy(dest, ctxt->inrptr, len); in xmlNanoHTTPRead()
1226 ctxt->inrptr += len; in xmlNanoHTTPRead()
1254 * usually is a token from the no_proxy environment variable. Wildcards in the
1270 idx_pattern = strlen(pattern) -1; in xmlNanoHTTPHostnameMatch()
1280 --idx_pattern, --idx_hostname) { in xmlNanoHTTPHostnameMatch()
1285 return idx_pattern == -1 && (idx_hostname == -1|| hostname[idx_hostname] == '.'); in xmlNanoHTTPHostnameMatch()
1294 * whether the proxy server should be bypassed for a given host.
1296 * Returns true, iff a proxy server should be bypassed for the given hostname.
1302 char *env = getenv("no_proxy"), *cpy=NULL, *p=NULL; in xmlNanoHTTPBypassProxy() local
1303 if (!env) in xmlNanoHTTPBypassProxy()
1307 envlen = strlen(env) + 1; in xmlNanoHTTPBypassProxy()
1309 memcpy(cpy, env, envlen); in xmlNanoHTTPBypassProxy()
1310 env = cpy; in xmlNanoHTTPBypassProxy()
1313 while (isspace(*env)) in xmlNanoHTTPBypassProxy()
1314 ++env; in xmlNanoHTTPBypassProxy()
1315 if (*env == '\0') { in xmlNanoHTTPBypassProxy()
1320 p = env; in xmlNanoHTTPBypassProxy()
1321 while (*env) { in xmlNanoHTTPBypassProxy()
1323 if (*env != ',') { in xmlNanoHTTPBypassProxy()
1324 ++env; in xmlNanoHTTPBypassProxy()
1328 *(env++) = '\0'; in xmlNanoHTTPBypassProxy()
1334 while (isspace(*env)) in xmlNanoHTTPBypassProxy()
1335 ++env; in xmlNanoHTTPBypassProxy()
1336 p = env; in xmlNanoHTTPBypassProxy()
1353 * @contentType: the Content-Type information IN and OUT
1391 ctxt->location = xmlMemStrdup(redirURL); in xmlNanoHTTPMethodRedir()
1394 if ((ctxt->protocol == NULL) || (strcmp(ctxt->protocol, "http"))) { in xmlNanoHTTPMethodRedir()
1395 __xmlIOErr(XML_FROM_IO, XML_IO_UNSUPPORTED_PROTOCOL, ctxt->protocol); in xmlNanoHTTPMethodRedir()
1400 if (ctxt->hostname == NULL) { in xmlNanoHTTPMethodRedir()
1407 use_proxy = proxy && !xmlNanoHTTPBypassProxy(ctxt->hostname); in xmlNanoHTTPMethodRedir()
1409 blen = strlen(ctxt->hostname) * 2 + 16; in xmlNanoHTTPMethodRedir()
1410 ret = xmlNanoHTTPConnectHost(proxy, proxyPort); in xmlNanoHTTPMethodRedir()
1413 blen = strlen(ctxt->hostname); in xmlNanoHTTPMethodRedir()
1414 ret = xmlNanoHTTPConnectHost(ctxt->hostname, ctxt->port); in xmlNanoHTTPMethodRedir()
1421 ctxt->fd = ret; in xmlNanoHTTPMethodRedir()
1431 /* reserve for string plus 'Content-Type: \r\n" */ in xmlNanoHTTPMethodRedir()
1433 if (ctxt->query != NULL) in xmlNanoHTTPMethodRedir()
1435 blen += strlen(ctxt->query) + 1; in xmlNanoHTTPMethodRedir()
1436 blen += strlen(method) + strlen(ctxt->path) + 24; in xmlNanoHTTPMethodRedir()
1438 /* reserve for possible 'Accept-Encoding: gzip' string */ in xmlNanoHTTPMethodRedir()
1441 if (ctxt->port != 80) { in xmlNanoHTTPMethodRedir()
1442 /* reserve space for ':xxxxx', incl. potential proxy */ in xmlNanoHTTPMethodRedir()
1458 if (ctxt->port != 80) { in xmlNanoHTTPMethodRedir()
1459 p += snprintf( p, blen - (p - bp), "%s http://%s:%d%s", in xmlNanoHTTPMethodRedir()
1460 method, ctxt->hostname, in xmlNanoHTTPMethodRedir()
1461 ctxt->port, ctxt->path ); in xmlNanoHTTPMethodRedir()
1464 p += snprintf( p, blen - (p - bp), "%s http://%s%s", method, in xmlNanoHTTPMethodRedir()
1465 ctxt->hostname, ctxt->path); in xmlNanoHTTPMethodRedir()
1468 p += snprintf( p, blen - (p - bp), "%s %s", method, ctxt->path); in xmlNanoHTTPMethodRedir()
1470 if (ctxt->query != NULL) in xmlNanoHTTPMethodRedir()
1471 p += snprintf( p, blen - (p - bp), "?%s", ctxt->query); in xmlNanoHTTPMethodRedir()
1473 if (ctxt->port == 80) { in xmlNanoHTTPMethodRedir()
1474 p += snprintf( p, blen - (p - bp), " HTTP/1.0\r\nHost: %s\r\n", in xmlNanoHTTPMethodRedir()
1475 ctxt->hostname); in xmlNanoHTTPMethodRedir()
1477 p += snprintf( p, blen - (p - bp), " HTTP/1.0\r\nHost: %s:%d\r\n", in xmlNanoHTTPMethodRedir()
1478 ctxt->hostname, ctxt->port); in xmlNanoHTTPMethodRedir()
1482 p += snprintf(p, blen - (p - bp), "Accept-Encoding: gzip\r\n"); in xmlNanoHTTPMethodRedir()
1486 p += snprintf(p, blen - (p - bp), "Content-Type: %s\r\n", *contentType); in xmlNanoHTTPMethodRedir()
1489 p += snprintf( p, blen - (p - bp), "%s", headers ); in xmlNanoHTTPMethodRedir()
1492 snprintf(p, blen - (p - bp), "Content-Length: %d\r\n\r\n", ilen ); in xmlNanoHTTPMethodRedir()
1494 snprintf(p, blen - (p - bp), "\r\n"); in xmlNanoHTTPMethodRedir()
1496 ctxt->outptr = ctxt->out = bp; in xmlNanoHTTPMethodRedir()
1497 ctxt->state = XML_NANO_HTTP_WRITE; in xmlNanoHTTPMethodRedir()
1498 blen = strlen( ctxt->out ); in xmlNanoHTTPMethodRedir()
1499 xmlNanoHTTPSend(ctxt, ctxt->out, blen ); in xmlNanoHTTPMethodRedir()
1505 ctxt->state = XML_NANO_HTTP_READ; in xmlNanoHTTPMethodRedir()
1509 ctxt->content = ctxt->inrptr; in xmlNanoHTTPMethodRedir()
1518 if ((ctxt->location != NULL) && (ctxt->returnValue >= 300) && in xmlNanoHTTPMethodRedir()
1519 (ctxt->returnValue < 400)) { in xmlNanoHTTPMethodRedir()
1526 redirURL = xmlMemStrdup(ctxt->location); in xmlNanoHTTPMethodRedir()
1536 if (ctxt->contentType != NULL) in xmlNanoHTTPMethodRedir()
1537 *contentType = xmlMemStrdup(ctxt->contentType); in xmlNanoHTTPMethodRedir()
1559 * @contentType: the Content-Type information IN and OUT
1582 * @contentType: if available the Content-Type information will be
1588 * Returns -1 in case of failure, 0 in case of success. The contentType,
1599 if (filename == NULL) return(-1); in xmlNanoHTTPFetch()
1601 if (ctxt == NULL) return(-1); in xmlNanoHTTPFetch()
1603 if (!strcmp(filename, "-")) in xmlNanoHTTPFetch()
1613 return(-1); in xmlNanoHTTPFetch()
1619 if (write(fd, buf, len) == -1) { in xmlNanoHTTPFetch()
1620 ret = -1; in xmlNanoHTTPFetch()
1638 * Returns -1 in case of failure, 0 in case of success.
1647 if ((ctxt == NULL) || (filename == NULL)) return(-1); in xmlNanoHTTPSave()
1649 if (!strcmp(filename, "-")) in xmlNanoHTTPSave()
1655 return(-1); in xmlNanoHTTPSave()
1661 if (write(fd, buf, len) == -1) { in xmlNanoHTTPSave()
1662 ret = -1; in xmlNanoHTTPSave()
1684 if (ctxt == NULL) return(-1); in xmlNanoHTTPReturnCode()
1686 return(ctxt->returnValue); in xmlNanoHTTPReturnCode()
1695 * Returns the stashed value of the WWW-Authenticate or Proxy-Authenticate
1704 return(ctxt->authHeader); in xmlNanoHTTPAuthHeader()
1711 * Provides the specified content length from the HTTP header.
1713 * Return the specified content length from the HTTP header. Note that
1714 * a value of -1 indicates that the content length element was not included in
1721 return ( ( ctxt == NULL ) ? -1 : ctxt->ContentLength ); in xmlNanoHTTPContentLength()
1728 * Provides the specified redirection URL if available from the HTTP header.
1736 return ( ( ctxt == NULL ) ? NULL : ctxt->location ); in xmlNanoHTTPRedir()
1751 return ( ( ctxt == NULL ) ? NULL : ctxt->encoding ); in xmlNanoHTTPEncoding()
1758 * Provides the specified Mime-Type if specified in the HTTP headers.
1760 * Return the specified Mime-Type or NULL if not available
1766 return ( ( ctxt == NULL ) ? NULL : ctxt->mimeType ); in xmlNanoHTTPMimeType()
1778 * -1 if received content length was less than specified or an error
1801 if ( ( ctxt == NULL ) || ( ctxt->content == NULL ) ) { in xmlNanoHTTPFetchContent()
1804 return ( -1 ); in xmlNanoHTTPFetchContent()
1807 rcvd_lgth = ctxt->inptr - ctxt->content; in xmlNanoHTTPFetchContent()
1812 if ( (ctxt->ContentLength > 0) && (rcvd_lgth >= ctxt->ContentLength) ) in xmlNanoHTTPFetchContent()
1816 *ptr = ctxt->content; in xmlNanoHTTPFetchContent()
1819 if ( ( ctxt->ContentLength > 0 ) && ( rcvd_lgth < ctxt->ContentLength ) ) in xmlNanoHTTPFetchContent()
1820 rc = -1; in xmlNanoHTTPFetchContent()
1822 rc = -1; in xmlNanoHTTPFetchContent()
1835 xmlNanoHTTPFetch(argv[1], "-", &contentType); in main()