Annotation of libwww/Library/src/HTTP.c, revision 1.34
1.1 timbl 1: /* HyperText Tranfer Protocol - Client implementation HTTP.c
2: ** ==========================
1.2 timbl 3: **
4: ** Bugs:
5: ** Not implemented:
6: ** Forward
7: ** Redirection
8: ** Error handling
1.1 timbl 9: */
10:
11: /* Module parameters:
12: ** -----------------
13: **
14: ** These may be undefined and redefined by syspec.h
15: */
1.2 timbl 16:
17: /* Implements:
18: */
19: #include "HTTP.h"
20:
21: #define HTTP_VERSION "HTTP/1.0"
22: #define HTTP2 /* Version is greater than 0.9 */
23:
24: #define INIT_LINE_SIZE 1024 /* Start with line buffer this big */
25: #define LINE_EXTEND_THRESH 256 /* Minimum read size */
26: #define VERSION_LENGTH 20 /* for returned protocol version */
27:
28: /* Uses:
29: */
1.1 timbl 30: #include "HTParse.h"
31: #include "HTUtils.h"
32: #include "tcp.h"
33: #include "HTTCP.h"
34: #include "HTFormat.h"
1.2 timbl 35: #include <ctype.h>
36: #include "HTAlert.h"
37: #include "HTMIME.h"
1.5 timbl 38: #include "HTML.h" /* SCW */
39: #include "HTInit.h" /* SCW */
1.21 luotonen 40: #include "HTAccess.h" /* HTRequest */
1.14 luotonen 41: #include "HTAABrow.h" /* Access Authorization */
1.20 timbl 42: #include "HTTee.h" /* Tee off a cache stream */
43: #include "HTFWriter.h" /* Write to cache file */
1.1 timbl 44:
1.2 timbl 45: struct _HTStream {
46: HTStreamClass * isa; /* all we need to know */
47: };
48:
1.6 timbl 49: extern char * HTAppName; /* Application name: please supply */
50: extern char * HTAppVersion; /* Application version: please supply */
51:
1.19 timbl 52: PUBLIC BOOL HTCacheHTTP = YES; /* Enable caching of HTTP-retrieved files */
1.23 luotonen 53:
54:
1.21 luotonen 55: PRIVATE void parse_401_headers ARGS2(HTRequest *, req,
56: HTInputSocket *, isoc)
57: {
58: HTAAScheme scheme;
59: char *line;
60: int num_schemes = 0;
61: HTList *valid_schemes = HTList_new();
62: HTAssocList **scheme_specifics = NULL;
63: char *template = NULL;
64:
65: /* Read server reply header lines */
66:
67: if (TRACE)
68: fprintf(stderr, "Server 401 reply header lines:\n");
69:
70: while (NULL != (line = HTInputSocket_getUnfoldedLine(isoc)) &&
71: *line != 0) {
72:
73: if (TRACE) fprintf(stderr, "%s\n", line);
74:
75: if (strchr(line, ':')) { /* Valid header line */
76:
77: char *p = line;
78: char *fieldname = HTNextField(&p);
79: char *arg1 = HTNextField(&p);
80: char *args = p;
81:
82: if (0==strcasecomp(fieldname, "WWW-Authenticate:")) {
83: if (HTAA_UNKNOWN != (scheme = HTAAScheme_enum(arg1))) {
84: HTList_addObject(valid_schemes, (void*)scheme);
85: if (!scheme_specifics) {
86: int i;
87: scheme_specifics = (HTAssocList**)
88: malloc(HTAA_MAX_SCHEMES * sizeof(HTAssocList*));
89: if (!scheme_specifics)
90: outofmem(__FILE__, "parse_401_headers");
91: for (i=0; i < HTAA_MAX_SCHEMES; i++)
92: scheme_specifics[i] = NULL;
93: }
94: scheme_specifics[scheme] = HTAA_parseArgList(args);
95: num_schemes++;
96: }
97: else if (TRACE) {
98: fprintf(stderr, "Unknown scheme `%s' %s\n",
99: (arg1 ? arg1 : "(null)"),
100: "in WWW-Authenticate: field");
101: }
102: }
103:
104: else if (0==strcasecomp(fieldname, "WWW-Protection-Template:")) {
105: if (TRACE)
106: fprintf(stderr, "Protection template set to `%s'\n", arg1);
107: StrAllocCopy(template, arg1);
108: }
109:
110: } /* if a valid header line */
111: else if (TRACE) {
112: fprintf(stderr, "Invalid header line `%s' ignored\n", line);
113: } /* else invalid header line */
114: } /* while header lines remain */
115:
116: req->valid_schemes = valid_schemes;
117: req->scheme_specifics = scheme_specifics;
118: req->prot_template = template;
119: }
120:
121:
122:
1.1 timbl 123: /* Load Document from HTTP Server HTLoadHTTP()
124: ** ==============================
125: **
126: ** Given a hypertext address, this routine loads a document.
127: **
128: **
129: ** On entry,
130: ** arg is the hypertext reference of the article to be loaded.
131: **
132: ** On exit,
133: ** returns >=0 If no error, a good socket number
134: ** <0 Error.
135: **
136: ** The socket must be closed by the caller after the document has been
137: ** read.
138: **
139: */
1.19 timbl 140: PUBLIC int HTLoadHTTP ARGS1 (HTRequest *, request)
1.1 timbl 141: {
1.22 luotonen 142: CONST char * arg = NULL;
1.1 timbl 143: int s; /* Socket number for returned data */
144: int status; /* tcp return */
1.10 timbl 145: char crlf[3]; /* A CR LF equivalent string */
1.3 timbl 146: HTStream * target = NULL; /* Unconverted data */
147:
1.2 timbl 148: CONST char* gate = 0; /* disable this feature */
1.1 timbl 149: SockA soc_address; /* Binary network address */
150: SockA * sin = &soc_address;
1.2 timbl 151: BOOL extensions = YES; /* Assume good HTTP server */
1.27 luotonen 152: char * cache_file_name = NULL;
1.17 timbl 153:
1.22 luotonen 154: if (request->reason == HTAA_OK_GATEWAY) {
155: arg = request->translated;
1.23 luotonen 156:
157: /*
158: ** Cache lookup
159: */
1.29 luotonen 160: #ifdef NOT_USED_YET
1.27 luotonen 161: if (request->method == METHOD_GET &&
162: !request->authorization &&
163: !request->arg_keywords) {
1.23 luotonen 164:
1.27 luotonen 165: if (HTCacheLookupOrCreate(arg, &cache_file_name)) {
1.23 luotonen 166:
1.27 luotonen 167: FILE * cache_file = fopen(cache_file_name, "r");
1.23 luotonen 168:
1.27 luotonen 169: if (cache_file) {
170: HTFileCopy(cache_file, request->output_stream);
171: fclose(cache_file);
172: free(cache_file_name);
173: (*request->output_stream->isa->free)(request->output_stream);
174: return HT_LOADED;
175: }
176: free(cache_file_name);
177: cache_file_name = NULL;
178: } /* Cache lookup */
179: } /* Can use cache? */
1.29 luotonen 180: #endif /* NOT_USED_YET */
1.27 luotonen 181: } /* I'm a gateway */
1.22 luotonen 182: else {
183: arg = HTAnchor_physical(request->anchor);
184: StrAllocCopy(request->argument, arg);
185: }
186:
1.1 timbl 187: if (!arg) return -3; /* Bad if no name sepcified */
188: if (!*arg) return -2; /* Bad if name had zero length */
189:
190: /* Set up defaults:
191: */
192: #ifdef DECNET
1.2 timbl 193: sin->sdn_family = AF_DECnet; /* Family = DECnet, host order */
194: sin->sdn_objnum = DNP_OBJ; /* Default: http object number */
1.1 timbl 195: #else /* Internet */
1.2 timbl 196: sin->sin_family = AF_INET; /* Family = internet, host order */
197: sin->sin_port = htons(TCP_PORT); /* Default: http port */
1.1 timbl 198: #endif
199:
1.10 timbl 200: sprintf(crlf, "%c%c", CR, LF); /* To be corect on Mac, VM, etc */
201:
1.1 timbl 202: if (TRACE) {
203: if (gate) fprintf(stderr,
204: "HTTPAccess: Using gateway %s for %s\n", gate, arg);
205: else fprintf(stderr, "HTTPAccess: Direct access for %s\n", arg);
206: }
207:
208: /* Get node name and optional port number:
209: */
210: {
211: char *p1 = HTParse(gate ? gate : arg, "", PARSE_HOST);
212: int status = HTParseInet(sin, p1); /* TBL 920622 */
213: free(p1);
214: if (status) return status; /* No such host for example */
215: }
216:
1.15 luotonen 217: /*
218: ** Compose authorization information (this was moved here
219: ** from after the making of the connection so that the connection
220: ** wouldn't have to wait while prompting username and password
221: ** from the user). -- AL 13.10.93
222: */
223: #ifdef ACCESS_AUTH
1.21 luotonen 224: HTAA_composeAuth(request);
225: if (TRACE) {
226: if (request->authorization)
227: fprintf(stderr, "HTTP: Sending Authorization: %s\n",
228: request->authorization);
229: else
230: fprintf(stderr, "HTTP: Not sending authorization (yet)\n");
1.15 luotonen 231: }
232: #endif /* ACCESS_AUTH */
1.1 timbl 233:
1.10 timbl 234: /* Now, let's get a socket set up from the server for the data:
1.1 timbl 235: */
236: #ifdef DECNET
237: s = socket(AF_DECnet, SOCK_STREAM, 0);
238: #else
239: s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
240: #endif
241: status = connect(s, (struct sockaddr*)&soc_address, sizeof(soc_address));
242: if (status < 0) {
243: if (TRACE) fprintf(stderr,
1.30 frystyk 244: "HTTP: Unable to connect to remote host for `%s' (errno = %d).\n",
245: arg, errno);
1.17 timbl 246:
1.1 timbl 247: return HTInetStatus("connect");
248: }
249:
250: if (TRACE) fprintf(stderr, "HTTP connected, socket %d\n", s);
251:
1.17 timbl 252:
253: /* Compose and send command
254: ** ------------------------
255: */
256: {
257: char *command; /* The whole command */
258:
1.1 timbl 259: /* Ask that node for the document,
260: ** omitting the host name & anchor if not gatewayed.
261: */
1.17 timbl 262: if (gate) {
263: command = malloc(4 + strlen(arg)+ 2 + 31);
264: if (command == NULL) outofmem(__FILE__, "HTLoadHTTP");
265: strcpy(command, "GET ");
266: strcat(command, arg);
267: } else { /* not gatewayed */
268: char * p1 = HTParse(arg, "", PARSE_PATH|PARSE_PUNCTUATION);
269: command = malloc(4 + strlen(p1)+ 2 + 31);
270: if (command == NULL) outofmem(__FILE__, "HTLoadHTTP");
1.23 luotonen 271: if (request->method != METHOD_INVALID) {
272: strcpy(command, HTMethod_name(request->method));
1.22 luotonen 273: strcat(command, " ");
274: }
275: else {
276: strcpy(command, "GET ");
277: }
1.17 timbl 278: strcat(command, p1);
279: free(p1);
280: }
1.2 timbl 281: #ifdef HTTP2
1.17 timbl 282: if (extensions) {
283: strcat(command, " ");
284: strcat(command, HTTP_VERSION);
285: }
1.2 timbl 286: #endif
1.17 timbl 287:
288: strcat(command, crlf); /* CR LF, as in rfc 977 */
289:
290: if (extensions) {
1.21 luotonen 291:
1.17 timbl 292: int i;
293: HTAtom * present = WWW_PRESENT;
294: char line[256]; /*@@@@ */
1.21 luotonen 295: HTList *conversions[2];
296:
1.22 luotonen 297: if (!HTConversions) {
298: HTConversions = HTList_new();
1.34 ! frystyk 299: /* HTFormatInit(HTConversions); App may do this not us tbl940210 */
1.22 luotonen 300: }
1.28 timbl 301:
1.21 luotonen 302: conversions[0] = HTConversions;
303: conversions[1] = request->conversions;
304:
1.34 ! frystyk 305:
1.21 luotonen 306: for (i=0; i<2; i++) {
307: HTList *cur = conversions[i];
308: HTPresentation *pres;
309:
310: while ((pres = (HTPresentation*)HTList_nextObject(cur))) {
311: if (pres->rep_out == present) {
312: if (pres->quality != 1.0) {
313: sprintf(line, "Accept: %s q=%.3f%c%c",
314: HTAtom_name(pres->rep),
315: pres->quality, CR, LF);
316: } else {
317: sprintf(line, "Accept: %s%c%c",
318: HTAtom_name(pres->rep), CR, LF);
319: }
320: StrAllocCat(command, line);
1.17 timbl 321: }
322: }
1.2 timbl 323: }
1.22 luotonen 324:
325: sprintf(line, "User-Agent: %s%s %s/%s libwww/%s%c%c",
326: request->user_agent ? request->user_agent : "",
327: request->user_agent ? " VIA Gateway" : "",
1.17 timbl 328: HTAppName ? HTAppName : "unknown",
329: HTAppVersion ? HTAppVersion : "0.0",
330: HTLibraryVersion, CR, LF);
331: StrAllocCat(command, line);
332:
1.22 luotonen 333: if (request->from) {
334: sprintf(line, "From: %s%c%c", request->from, CR, LF);
335: StrAllocCat(command, line);
336: }
337:
1.14 luotonen 338: #ifdef ACCESS_AUTH
1.21 luotonen 339: if (request->authorization != NULL) {
340: sprintf(line, "Authorization: %s%c%c",
341: request->authorization, CR, LF);
1.17 timbl 342: StrAllocCat(command, line);
343: }
344: #endif /* ACCESS_AUTH */
1.22 luotonen 345:
346: if (request->content_type) {
347: sprintf(line, "Content-Type: %s%c%c",
348: HTAtom_name(request->content_type), CR, LF);
349: StrAllocCat(command, line);
350: }
351:
352: if (request->content_length > 0) {
353: sprintf(line, "Content-Length: %d%c%c",
354: request->content_length, CR, LF);
355: StrAllocCat(command, line);
356: }
357:
358:
1.14 luotonen 359: }
1.17 timbl 360:
361: StrAllocCat(command, crlf); /* Blank line means "end" */
362:
363: if (TRACE) fprintf(stderr, "HTTP Tx: %s\n", command);
364:
365: /* Translate into ASCII if necessary
366: */
1.4 timbl 367: #ifdef NOT_ASCII
1.17 timbl 368: {
369: char * p;
370: for(p = command; *p; p++) {
371: *p = TOASCII(*p);
372: }
1.1 timbl 373: }
1.3 timbl 374: #endif
1.17 timbl 375:
376: status = NETWRITE(s, command, (int)strlen(command));
377: free(command);
378: if (status<0) {
379: if (TRACE) fprintf(stderr,
380: "HTTPAccess: Unable to send command.\n");
1.1 timbl 381: return HTInetStatus("send");
1.17 timbl 382: }
383: } /* compose and send command */
384:
1.2 timbl 385:
1.17 timbl 386: /* Read the response
387: ** -----------------
1.11 timbl 388: **
389: ** HTTP0 servers must return ASCII style text, though it can in
390: ** principle be just text without any markup at all.
391: ** Full HTTP servers must return a response
392: ** line and RFC822 style header. The response must therefore in
393: ** either case have a CRLF somewhere soon.
394: **
395: ** This is the theory. In practice, there are (1993) unfortunately
396: ** many binary documents just served up with HTTP0.9. This
397: ** means we have to preserve the binary buffer (on the assumption that
398: ** conversion from ASCII may lose information) in case it turns
399: ** out that we want the binary original.
1.2 timbl 400: */
1.3 timbl 401:
1.22 luotonen 402: if (request->reason == HTAA_OK_GATEWAY) {
1.24 luotonen 403:
1.22 luotonen 404: /*
405: ** Server as a gateway -- send body of the message
406: ** received from client (if any).
407: */
408: if (request->isoc && request->content_length > 0) {
409: int remain = request->content_length;
410: int i = remain;
411: char * buf;
412:
413: while (remain > 0 &&
414: (buf = HTInputSocket_getBlock(request->isoc, &i))) {
415: int status = NETWRITE(s, buf, i);
416: if (status < 0) {
1.27 luotonen 417: CTRACE(stderr, "HTTPAccess.. Unable to forward body\n");
1.22 luotonen 418: return HTInetStatus("send");
419: }
420: remain -= i;
421: i = remain;
422: }
423: }
1.23 luotonen 424:
425: /*
426: ** Cache the document if it a GET request,
427: ** not protected and not a search request.
428: */
1.27 luotonen 429: if (cache_file_name) {
430: FILE * cache_file = fopen(cache_file_name, "w");
1.23 luotonen 431:
1.27 luotonen 432: if (cache_file) {
433: request->output_stream = HTTee(request->output_stream,
1.31 frystyk 434: HTFWriter_new(cache_file, NO));
1.27 luotonen 435: CTRACE(stderr, "Gateway..... writing to cache file\n");
436: }
437: else {
1.29 luotonen 438: #ifdef NOT_USED_YET
1.27 luotonen 439: HTCacheCancel(arg);
1.29 luotonen 440: #endif /* NOT_USED_YET */
1.27 luotonen 441: free(cache_file_name);
442: cache_file_name = NULL;
443: CTRACE(stderr, "Gateway..... couldn't create cache file\n");
1.23 luotonen 444: }
445: }
1.27 luotonen 446: else CTRACE(stderr, "Gateway..... not caching\n");
1.23 luotonen 447:
1.22 luotonen 448: /*
449: ** Load results directly to client
450: */
451: HTCopy(s, request->output_stream);
1.25 luotonen 452: (*request->output_stream->isa->free)(request->output_stream);
1.27 luotonen 453: if (cache_file_name) {
1.29 luotonen 454: #ifdef NOT_USED_YET
1.27 luotonen 455: HTCacheCreated(arg, (time_t)0);
1.29 luotonen 456: #endif /* NOT_USED_YET */
1.27 luotonen 457: free(cache_file_name);
1.24 luotonen 458: }
1.22 luotonen 459: return HT_LOADED;
460: }
461: else { /* read response */
1.21 luotonen 462:
1.17 timbl 463: HTFormat format_in; /* Format arriving in the message */
1.21 luotonen 464: HTInputSocket *isoc = HTInputSocket_new(s);
465: char * status_line = HTInputSocket_getStatusLine(isoc);
1.2 timbl 466:
1.11 timbl 467: /* Kludge to trap binary responses from illegal HTTP0.9 servers.
468: ** First time we have enough, look at the stub in ASCII
469: ** and get out of here if it doesn't look right.
470: **
471: ** We also check for characters above 128 in the first few bytes, and
472: ** if we find them we forget the html default.
473: **
474: ** Bugs: A HTTP0.9 server returning a document starting "HTTP/"
475: ** will be taken as a HTTP 1.0 server. Failure.
476: ** An HTTP 0.9 server returning a binary document with
477: ** characters < 128 will be read as ASCII.
478: */
1.21 luotonen 479: if (!status_line) { /* HTTP0 response */
480: if (HTInputSocket_seemsBinary(isoc)) {
481: format_in = HTAtom_for("www/unknown");
482: }
483: else {
484: format_in = WWW_HTML;
485: }
486: goto copy;
487: } /* end kludge */
488:
489: if (status_line) { /* Decode full HTTP response */
490: /*
491: ** We now have a terminated server status line, and we have
492: ** checked that it is most probably a legal one. Parse it.
493: */
494: char server_version[VERSION_LENGTH+1];
495: int server_status;
496:
497: if (TRACE)
498: fprintf(stderr, "HTTP Status Line: Rx: %.70s\n", status_line);
1.17 timbl 499:
1.21 luotonen 500: sscanf(status_line, "%20s%d", server_version, &server_status);
1.2 timbl 501:
1.21 luotonen 502: format_in = HTAtom_for("www/mime");
1.7 timbl 503:
1.21 luotonen 504: switch (server_status / 100) {
1.2 timbl 505:
1.21 luotonen 506: default: /* bad number */
507: HTAlert("Unknown status reply from server!");
508: break;
1.17 timbl 509:
1.21 luotonen 510: case 3: /* Various forms of redirection */
511: HTAlert(
1.17 timbl 512: "Redirection response from server is not handled by this client");
1.21 luotonen 513: break;
1.17 timbl 514:
1.21 luotonen 515: case 4: /* Access Authorization problem */
1.14 luotonen 516: #ifdef ACCESS_AUTH
1.21 luotonen 517: switch (server_status) {
518: case 401:
519: parse_401_headers(request, isoc);
520:
521: if (TRACE) fprintf(stderr, "%s %d %s\n",
522: "HTTP: close socket", s,
523: "to retry with Access Authorization");
524: HTInputSocket_free(isoc);
525: (void)NETCLOSE(s);
1.24 luotonen 526: if (HTAA_retryWithAuth(request, HTLoadHTTP)) {
1.21 luotonen 527: status = HT_LOADED;/* @@ THIS ONLY WORKS ON LINEMODE */
528: goto clean_up;
529: }
530: /* else falltrough */
531: default:
1.14 luotonen 532: {
1.21 luotonen 533: char *p1 = HTParse(gate ? gate : arg, "",
534: PARSE_HOST);
535: char * message;
536:
537: if (!(message = (char*)malloc(strlen(status_line) +
538: strlen(p1) + 100)))
539: outofmem(__FILE__, "HTTP 4xx status");
1.14 luotonen 540: sprintf(message,
1.21 luotonen 541: "HTTP server at %s replies:\n%s\n\n%s\n",
542: p1, status_line,
543: ((server_status == 401)
544: ? "Access Authorization package giving up.\n"
545: : ""));
1.22 luotonen 546: status = HTLoadError(request, server_status, message);
1.14 luotonen 547: free(message);
548: free(p1);
549: goto clean_up;
550: }
1.21 luotonen 551: } /* switch */
552: goto clean_up;
553: break;
554: #else
555: /* case 4 without Access Authorization falls through */
556: /* to case 5 (previously "I think I goofed"). -- AL */
557: #endif /* ACCESS_AUTH */
558:
559: case 5: /* I think you goofed */
560: {
561: char *p1 = HTParse(gate ? gate : arg, "", PARSE_HOST);
562: char * message = (char*)malloc(strlen(status_line) +
563: strlen(p1) + 100);
564: if (!message) outofmem(__FILE__, "HTTP 5xx status");
565: sprintf(message,
566: "HTTP server at %s replies:\n%s", p1, status_line);
1.22 luotonen 567: status = HTLoadError(request, server_status, message);
1.21 luotonen 568: free(message);
569: free(p1);
570: goto clean_up;
571: }
572: break;
1.17 timbl 573:
1.21 luotonen 574: case 2: /* Good: Got MIME object */
575: break;
1.17 timbl 576:
1.21 luotonen 577: } /* switch on response code */
1.17 timbl 578:
1.21 luotonen 579: } /* Full HTTP reply */
1.17 timbl 580:
581:
1.3 timbl 582: /* Set up the stream stack to handle the body of the message
1.33 timbl 583: **
584: ** In the special case of user asking for source and the message
585: ** being in MIME, we force the MIME decoding to occur, as it is really
586: ** HTTP decoding. If the user really wants the HTTP headers, he
587: ** can ask for them as www/mime.
1.3 timbl 588: */
1.21 luotonen 589:
1.13 duns 590: copy:
1.21 luotonen 591:
1.33 timbl 592: if ((format_in == HTAtom_for("www/mime"))
593: && (request->output_format == HTAtom_for("www/source"))) {
594: target = HTMIMEConvert(request, NULL, format_in,
595: request->output_format, request->output_stream);
596: } else {
597: target = HTStreamStack(format_in, request);
598: }
599:
1.17 timbl 600: if (!target) {
601: char buffer[1024]; /* @@@@@@@@ */
602: sprintf(buffer, "Sorry, no known way of converting %s to %s.",
603: HTAtom_name(format_in), HTAtom_name(request->output_format));
604: fprintf(stderr, "HTTP: %s", buffer);
1.22 luotonen 605: status = HTLoadError(request, 501, buffer);
1.17 timbl 606: goto clean_up;
607: }
608:
1.19 timbl 609: /* @@ Bug: The decision of whether or not to cache should also be
1.21 luotonen 610: ** made contingent on a IP address match or non match.
611: */
1.19 timbl 612: if (HTCacheHTTP) {
613: target = HTTee(target, HTCacheWriter(request, NULL, format_in,
1.21 luotonen 614: request->output_format,
615: request->output_stream));
1.19 timbl 616: }
617:
1.11 timbl 618: /* Push the data down the stream
1.3 timbl 619: ** We have to remember the end of the first buffer we just read
1.2 timbl 620: */
1.30 frystyk 621: if (format_in == WWW_HTML) {
1.17 timbl 622: target = HTNetToText(target); /* Pipe through CR stripper */
623: }
1.21 luotonen 624:
1.17 timbl 625: (*target->isa->put_block)(target,
1.21 luotonen 626: isoc->input_pointer,
627: isoc->input_limit - isoc->input_pointer);
628: HTInputSocket_free(isoc);
1.17 timbl 629: HTCopy(s, target);
630:
631: (*target->isa->free)(target);
632: status = HT_LOADED;
1.11 timbl 633:
1.2 timbl 634: /* Clean up
1.1 timbl 635: */
1.17 timbl 636:
637: clean_up:
638: if (TRACE) fprintf(stderr, "HTTP: close socket %d.\n", s);
639: (void) NETCLOSE(s);
640:
641: return status; /* Good return */
1.3 timbl 642:
1.17 timbl 643: } /* read response */
644: } /* load HTTP */
1.1 timbl 645:
646: /* Protocol descriptor
647: */
648:
1.17 timbl 649: GLOBALDEF PUBLIC HTProtocol HTTP = { "http", HTLoadHTTP, 0, 0 };
1.21 luotonen 650:
Webmaster