{
char *p, *q, *r;
- for (p = hp->s ; p < hp->v && isspace(*p); p++)
- continue;
assert(hp->t != NULL);
+ assert(hp->s < hp->t);
+ assert(hp->t <= hp->v);
+ for (p = hp->s ; isspace(*p); p++)
+ continue;
if (rr == 1) {
/* First, isolate and possibly identify request type */
hp->req = p;
while (!isspace(*p))
p++;
VSLR(SLT_URL, fd, hp->url, p);
- *p++ = '\0';
-
- /* Finally, look for protocol, if any */
- while (isspace(*p) && *p != '\n')
- p++;
- hp->proto = p;
if (*p != '\n') {
- while (!isspace(*p))
+ *p++ = '\0';
+
+ /* Finally, look for protocol, if any */
+ while (isspace(*p) && *p != '\n')
p++;
+ if (*p != '\n') {
+ hp->proto = p;
+ while (!isspace(*p))
+ p++;
+ if (*p != '\n')
+ *p++ = '\0';
+ while (isspace(*p) && *p != '\n')
+ p++;
+ }
}
- VSLR(SLT_Protocol, fd, hp->proto, p);
*p++ = '\0';
-
- while (isspace(*p) && *p != '\n')
- p++;
- p++;
+ if (hp->proto != NULL)
+ VSLR(SLT_Protocol, fd, hp->proto, p);
} else {
/* First, protocol */
hp->proto = p;
if (!http_header_complete(hp))
return;
+ assert(hp->t != NULL);
event_del(&hp->ev);
if (hp->callback != NULL)
hp->callback(hp->arg, 1);
hp->v = hp->s + l;
hp->t = hp->s;
if (http_header_complete(hp)) {
+ assert(func != NULL);
func(arg, 1);
return;
}
sbuf_cat(sb, hp->req);
sbuf_cat(sb, " ");
sbuf_cat(sb, hp->url);
- sbuf_cat(sb, " ");
- sbuf_cat(sb, hp->proto);
+ if (hp->proto != NULL) {
+ sbuf_cat(sb, " ");
+ sbuf_cat(sb, hp->proto);
+ }
sup = 2;
break;
case Build_Fetch:
sbuf_cat(sb, "GET ");
sbuf_cat(sb, hp->url);
- sbuf_cat(sb, " ");
- sbuf_cat(sb, hp->proto);
+ if (hp->proto != NULL) {
+ sbuf_cat(sb, " ");
+ sbuf_cat(sb, hp->proto);
+ } else {
+ sbuf_cat(sb, " HTTP/1.1");
+ }
sup = 1;
break;
default: