-PHP_HTTP_API void _http_parse_headers_default_callback(const char *http_line, HashTable **headers, void **cb_data TSRMLS_DC)
-{
- zval array;
- char *crlf = NULL;
- size_t line_length;
- Z_ARRVAL(array) = *headers;
-
- if (crlf = strstr(http_line, HTTP_CRLF)) {
- line_length = crlf - http_line;
- } else {
- line_length = strlen(http_line);
- }
-
- /* response */
- if (!strncmp(http_line, "HTTP/1.", lenof("HTTP/1."))) {
- char *status = estrndup(http_line + lenof("HTTP/1.x "), line_length - lenof("HTTP/1.x "));
- add_assoc_stringl(&array, "Response Status", status, line_length - lenof("HTTP/1.x "), 0);
- } else
- /* request */
- if (!strncmp(http_line + line_length - lenof("HTTP/1.x"), "HTTP/1.", lenof("HTTP/1."))) {
- char *sep = strchr(http_line, ' ');
- char *url = estrndup(sep + 1, strstr(sep, "HTTP/1.") - sep + 1 + 1);
- char *met = estrndup(http_line, sep - http_line);
-
- add_assoc_stringl(&array, "Request Method", met, sep - http_line, 0);
- add_assoc_stringl(&array, "Request Uri", url, strstr(sep, "HTTP/1.") - sep + 1 + 1, 0);
- }
-}
-