if ((eol_str = php_http_locate_bin_eol(buffer->data, buffer->used, &eol_len))) {
if (eol_str + eol_len - buffer->data < buffer->used) {
- char *nextline = eol_str + eol_len;
+ const char *nextline = eol_str + eol_len;
if (*nextline == '\t' || *nextline == ' ') {
while (nextline < buffer->data + buffer->used && (*nextline == '\t' || *nextline == ' ')) {
if (parser->_key.str && parser->_val.str) {
zval array, **exist;
+ if (!headers && callback_func) {
+ callback_func(callback_arg, &headers, NULL TSRMLS_CC);
+ }
+
INIT_PZVAL_ARRAY(&array, headers);
php_http_pretty_key(parser->_key.str, parser->_key.len, 1, 1);
if (SUCCESS == zend_symtable_find(headers, parser->_key.str, parser->_key.len + 1, (void *) &exist)) {
(*headers) = &((*message)->hdrs);
}
- php_http_message_set_info(*message, info);
+ if (info) {
+ php_http_message_set_info(*message, info);
+ }
return old != *message;
}
if ((sval = php_http_env_get_server_var(ZEND_STRL("REQUEST_URI"), 1 TSRMLS_CC))) {
message->http.info.request.url = estrdup(Z_STRVAL_P(sval));
}
+ if ((sval = php_http_env_get_server_var(ZEND_STRL("CONTENT_TYPE"), 1 TSRMLS_CC))) {
+ Z_ADDREF_P(sval);
+ zend_hash_update(&message->hdrs, "Content-Type", sizeof("Content-Type"), (void *) &sval, sizeof(zval *), NULL);
+ }
+ if ((sval = php_http_env_get_server_var(ZEND_STRL("CONTENT_LENGTH"), 1 TSRMLS_CC))) {
+ Z_ADDREF_P(sval);
+ zend_hash_update(&message->hdrs, "Content-Length", sizeof("Content-Length"), (void *) &sval, sizeof(zval *), NULL);
+ }
php_http_env_get_request_headers(&message->hdrs TSRMLS_CC);
{
unsigned header_parser_flags = (flags & PHP_HTTP_MESSAGE_PARSER_CLEANUP) ? PHP_HTTP_HEADER_PARSER_CLEANUP : 0;
- switch (php_http_header_parser_parse(&parser->header, buffer, header_parser_flags, &(*message)->hdrs, (php_http_info_callback_t) php_http_message_info_callback, message)) {
+ switch (php_http_header_parser_parse(&parser->header, buffer, header_parser_flags, *message ? &(*message)->hdrs : NULL, (php_http_info_callback_t) php_http_message_info_callback, message)) {
case PHP_HTTP_HEADER_PARSER_STATE_FAILURE:
return PHP_HTTP_MESSAGE_PARSER_STATE_FAILURE;