-
-#include "php_http.h"
+/*
+ +--------------------------------------------------------------------+
+ | PECL :: http |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted provided that the conditions mentioned |
+ | in the accompanying LICENSE file are met. |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2004-2011, Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#include "php_http_api.h"
typedef struct php_http_header_parser_state_spec {
php_http_header_parser_state_t state;
};
-PHP_HTTP_API php_http_header_parser_t *php_http_header_parser_init(php_http_header_parser_t *parser TSRMLS_CC)
+PHP_HTTP_API php_http_header_parser_t *php_http_header_parser_init(php_http_header_parser_t *parser TSRMLS_DC)
{
if (!parser) {
parser = emalloc(sizeof(*parser));
}
case PHP_HTTP_HEADER_PARSER_STATE_KEY: {
- const char *colon, *eol_str;
- int eol_len;
+ const char *colon, *eol_str = NULL;
+ int eol_len = 0;
if (buffer->data == (eol_str = php_http_locate_bin_eol(buffer->data, buffer->used, &eol_len))) {
/* end of headers */
const char *eol_str;
int eol_len;
- do {
+ line_split: {
+
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);
-
- if (nextline == '\t' || nextline == ' ') {
- php_http_buffer_cut(buffer, eol_str - buffer->data, eol_len);
- continue;
+ const char *nextline = eol_str + eol_len;
+
+ if (*nextline == '\t' || *nextline == ' ') {
+ while (nextline < buffer->data + buffer->used && (*nextline == '\t' || *nextline == ' ')) {
+ ++nextline;
+ }
+ php_http_buffer_cut(buffer, eol_str - buffer->data, nextline - eol_str);
+ goto line_split;
}
}
} else {
return php_http_header_parser_state_push(parser, 1, PHP_HTTP_HEADER_PARSER_STATE_VALUE);
}
- } while (0);
+ }
break;
}
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_hash_find(headers, parser->_key.str, parser->_key.len + 1, (void *) &exist)) {
+ if (SUCCESS == zend_symtable_find(headers, parser->_key.str, parser->_key.len + 1, (void *) &exist)) {
convert_to_array(*exist);
add_next_index_stringl(*exist, parser->_val.str, parser->_val.len, 0);
} else {
return php_http_header_parser_state_is(parser);
}
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
+