X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=http_headers_api.c;h=81181e5711e6141b9cf4c653c72506b8fd2e721f;hp=7d824525602ae4f45451392702fef9eb17b3f276;hb=74c406d2e8a73540d9df9b888a17c86b0bb7fc2c;hpb=147fb6c4b51fc83e0d0393ca6999e36a36908157 diff --git a/http_headers_api.c b/http_headers_api.c index 7d82452..81181e5 100644 --- a/http_headers_api.c +++ b/http_headers_api.c @@ -464,6 +464,36 @@ PHP_HTTP_API void _http_get_request_headers_ex(HashTable *headers, zend_bool pre } /* }}} */ +/* {{{ zend_bool http_match_request_header(char *, char *) */ +PHP_HTTP_API zend_bool _http_match_request_header_ex(const char *header, const char *value, zend_bool match_case TSRMLS_DC) +{ + char *name, *key = NULL; + ulong idx; + zend_bool result = 0; + HashTable headers; + + name = pretty_key(estrdup(header), strlen(header), 1, 1); + zend_hash_init(&headers, 0, NULL, ZVAL_PTR_DTOR, 0); + http_get_request_headers_ex(&headers, 1); + + FOREACH_HASH_KEY(&headers, key, idx) { + if (key && (!strcmp(key, name))) { + zval **data; + + if (SUCCESS == zend_hash_get_current_data(&headers, (void **) &data)) { + result = (match_case ? strcmp(Z_STRVAL_PP(data), value) : strcasecmp(Z_STRVAL_PP(data), value)) ? 0 : 1; + } + break; + } + } + + zend_hash_destroy(&headers); + efree(name); + + return result; +} +/* }}} */ + /* * Local variables: