if (i == 0) return status;
- if ((body = strstr(p, "\r\n\r\n"))) {
+ if ((body = strstr(buffer, "\r\n\r\n"))) {
*body = '\0';
body += 4;
- } else if (( body = strstr(p, "\n\n"))) {
+ } else if (( body = strstr(buffer, "\n\n"))) {
*body = '\0';
body += 2;
+ } else {
+ return status;
}
request->_buffer = strdup(buffer);
}
p = strchr(request->method, ' ');
+
+ if (!p) goto err;
+
*p++ = '\0';
request->uri = p;
request->qs = p;
}
- p = strchr(http, '\n');
-
- if (!p) goto err;
-
if (!strncmp(http, "HTTP/1.1", 8)) {
request->keepalive = SWITCH_TRUE;
} else if (strncmp(http, "HTTP/1.0", 8)) {
goto err;
}
- p++; // now the first header
-
if (!request->headers) {
if (switch_event_create(&request->headers, SWITCH_EVENT_CHANNEL_DATA) != SWITCH_STATUS_SUCCESS) {
goto err;
request->_destroy_headers = SWITCH_TRUE;
}
+ p = strchr(http, '\n');
+
+ if (p) {
+ *p++ = '\0'; // now the first header
+ } else {
+ goto noheader;
+ }
+
header_count = switch_separate_string(p, '\n', headers, sizeof(headers)/ sizeof(headers[0]));
- if (header_count < 2) goto err; /* at least two lines */
+ if (header_count < 1) goto err;
for (i = 0; i < header_count; i++) {
char *header, *value;
}
}
+noheader:
+
if (request->qs) {
switch_http_parse_qs(request, NULL);
}