X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=php_http_env_response.c;h=0d220d0c281a1e6c193de631f96ccf38967724dd;hp=2f147554dc1d988e3d2b13deaaff2745dca024f7;hb=4407379af8d886b627c88572e9da69c38cdbda58;hpb=a07b79b1871054ca17e48b69445b4dc201f24662 diff --git a/php_http_env_response.c b/php_http_env_response.c index 2f14755..0d220d0 100644 --- a/php_http_env_response.c +++ b/php_http_env_response.c @@ -6,18 +6,11 @@ | modification, are permitted provided that the conditions mentioned | | in the accompanying LICENSE file are met. | +--------------------------------------------------------------------+ - | Copyright (c) 2004-2010, Michael Wallner | + | Copyright (c) 2004-2011, Michael Wallner | +--------------------------------------------------------------------+ */ -/* $Id $ */ - -#include "php_http.h" - -#include
-#include -#include - +#include "php_http_api.h" static void set_option(zval *options, const char *name_str, size_t name_len, int type, const void *value_ptr, size_t value_len TSRMLS_DC) { @@ -70,7 +63,7 @@ static zval *get_option(zval *options, const char *name_str, size_t name_len TSR val = zend_read_property(Z_OBJCE_P(options), options, name, name_len, 0 TSRMLS_CC); efree(name); } else { - if (SUCCESS == zend_hash_find(Z_ARRVAL_P(options), name_str, name_len + 1, (void *) &valptr)) { + if (SUCCESS == zend_symtable_find(Z_ARRVAL_P(options), name_str, name_len + 1, (void *) &valptr)) { val = *valptr; } else { val = NULL; @@ -84,11 +77,11 @@ static zval *get_option(zval *options, const char *name_str, size_t name_len TSR PHP_HTTP_API php_http_cache_status_t php_http_env_is_response_cached_by_etag(zval *options, const char *header_str, size_t header_len TSRMLS_DC) { - int ret, free_etag = 0; + int ret = 0, free_etag = 0; char *header, *etag; zval *zetag, *zbody = NULL; - if ( !(header = php_http_env_get_request_header(header_str, header_len TSRMLS_CC)) + if ( !(header = php_http_env_get_request_header(header_str, header_len, NULL TSRMLS_CC)) || !(zbody = get_option(options, ZEND_STRL("body") TSRMLS_CC)) || !(Z_TYPE_P(zbody) == IS_OBJECT) || !instanceof_function(Z_OBJCE_P(zbody), php_http_message_body_class_entry TSRMLS_CC) @@ -108,8 +101,7 @@ PHP_HTTP_API php_http_cache_status_t php_http_env_is_response_cached_by_etag(zva if (zetag && Z_STRLEN_P(zetag)) { etag = Z_STRVAL_P(zetag); - } else { - etag = php_http_message_body_etag(((php_http_message_body_object_t *) zend_object_store_get_object(zbody TSRMLS_CC))->body); + } else if ((etag = php_http_message_body_etag(((php_http_message_body_object_t *) zend_object_store_get_object(zbody TSRMLS_CC))->body))) { set_option(options, ZEND_STRL("etag"), IS_STRING, etag, strlen(etag) TSRMLS_CC); free_etag = 1; } @@ -122,7 +114,9 @@ PHP_HTTP_API php_http_cache_status_t php_http_env_is_response_cached_by_etag(zva zval_ptr_dtor(&zetag); } - ret = php_http_match(header, etag, PHP_HTTP_MATCH_WORD); + if (etag) { + ret = php_http_match(header, etag, PHP_HTTP_MATCH_WORD); + } if (free_etag) { efree(etag); @@ -138,7 +132,7 @@ PHP_HTTP_API php_http_cache_status_t php_http_env_is_response_cached_by_last_mod time_t ums, lm = 0; zval *zbody = NULL, *zlm; - if ( !(header = php_http_env_get_request_header(header_str, header_len TSRMLS_CC)) + if ( !(header = php_http_env_get_request_header(header_str, header_len, NULL TSRMLS_CC)) || !(zbody = get_option(options, ZEND_STRL("body") TSRMLS_CC)) || !(Z_TYPE_P(zbody) == IS_OBJECT) || !instanceof_function(Z_OBJCE_P(zbody), php_http_message_body_class_entry TSRMLS_CC) @@ -392,6 +386,7 @@ static STATUS php_http_env_response_send_head(php_http_env_response_t *r) switch (Z_LVAL_P(zdisposition_copy)) { case PHP_HTTP_CONTENT_DISPOSITION_NONE: ret = php_http_env_set_response_header_value(0, ZEND_STRL("Content-Disposition"), NULL, 1 TSRMLS_CC); + break; case PHP_HTTP_CONTENT_DISPOSITION_INLINE: tmp = "inline"; break; @@ -496,6 +491,7 @@ static STATUS php_http_env_response_send_head(php_http_env_response_t *r) if (PHP_HTTP_CACHE_HIT != php_http_env_is_response_cached_by_last_modified(options, ZEND_STRL("If-Modified-Since") TSRMLS_CC)) { break; } + /* fallthrough */ case PHP_HTTP_CACHE_HIT: ret = php_http_env_set_response_code(304 TSRMLS_CC); @@ -664,6 +660,8 @@ PHP_HTTP_API STATUS php_http_env_response_send(php_http_env_response_t *r) } break; } + + break; } } } else if (zbody) { @@ -893,7 +891,7 @@ PHP_METHOD(HttpEnvResponse, send) PHP_MINIT_FUNCTION(http_env_response) { - PHP_HTTP_REGISTER_CLASS(http\\env, Response, http_env_response, php_http_message_class_entry, 0); + PHP_HTTP_REGISTER_CLASS(http\\Env, Response, http_env_response, php_http_message_class_entry, 0); zend_declare_class_constant_long(php_http_env_response_class_entry, ZEND_STRL("CONTENT_DISPOSITION_NONE"), PHP_HTTP_CONTENT_DISPOSITION_NONE TSRMLS_CC); zend_declare_class_constant_long(php_http_env_response_class_entry, ZEND_STRL("CONTENT_DISPOSITION_INLINE"), PHP_HTTP_CONTENT_DISPOSITION_INLINE TSRMLS_CC);