/*
- * $Id: http.cc,v 1.139 1996/12/17 07:16:54 wessels Exp $
+ * $Id: http.cc,v 1.140 1996/12/18 03:50:23 wessels Exp $
*
* DEBUG: section 11 Hypertext Transfer Protocol (HTTP)
* AUTHOR: Harvest Derived
httpParseReplyHeaders(const char *buf, struct _http_reply *reply)
{
char *headers = get_free_4k_page();
- char *line = get_free_4k_page();
+ char *line;
char *end;
char *s = NULL;
char *t;
ReplyHeaderStats.parsed++;
xstrncpy(headers, buf, 4096);
end = mime_headers_end(headers);
- if (end)
- reply->hdr_sz = end - headers;
+ if (end == NULL) {
+ t = headers;
+ if (!strncasecmp(t, "HTTP/", 5)) {
+ reply->version = atof(t+5);
+ if ((t = strchr(t, ' ')))
+ reply->code = atoi(++t);
+ }
+ put_free_4k_page(headers);
+ return;
+ }
+ reply->hdr_sz = end - headers;
+ line = get_free_4k_page();
for (s = headers; s < end; s += strcspn(s, crlf), s += strspn(s, crlf)) {
l = strcspn(s, crlf) + 1;
if (l > 4096)
t = line;
debug(11, 3, "httpParseReplyHeaders: %s\n", t);
if (!strncasecmp(t, "HTTP/", 5)) {
- sscanf(t + 5, "%lf", &reply->version);
+ reply->version = atof(t+5);
if ((t = strchr(t, ' ')))
reply->code = atoi(++t);
} else if (!strncasecmp(t, "Content-type:", 13)) {
/*
- * $Id: mime.cc,v 1.26 1996/12/05 17:36:12 wessels Exp $
+ * $Id: mime.cc,v 1.27 1996/12/18 03:50:24 wessels Exp $
*
* DEBUG: section 25 MIME Parsing
* AUTHOR: Harvest Derived
const char *p1, *p2;
const char *end = NULL;
- p1 = strstr(mime, "\r\n\r\n");
+ p1 = strstr(mime, "\n\r\n");
p2 = strstr(mime, "\n\n");
if (p1 && p2)
else
end = p1 ? p1 : p2;
if (end)
- end += (end == p1 ? 4 : 2);
+ end += (end == p1 ? 3 : 2);
return (char *) end;
}