2 +--------------------------------------------------------------------+
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the conditions mentioned |
7 | in the accompanying LICENSE file are met. |
8 +--------------------------------------------------------------------+
9 | Copyright (c) 2004-2014, Michael Wallner <mike@php.net> |
10 +--------------------------------------------------------------------+
13 #include "php_http_api.h"
15 static void set_option(zval
*options
, const char *name_str
, size_t name_len
, int type
, void *value_ptr
, size_t value_len TSRMLS_DC
)
17 if (Z_TYPE_P(options
) == IS_OBJECT
) {
21 zend_update_property_double(Z_OBJCE_P(options
), options
, name_str
, name_len
, *(double *)value_ptr TSRMLS_CC
);
24 zend_update_property_long(Z_OBJCE_P(options
), options
, name_str
, name_len
, *(long *)value_ptr TSRMLS_CC
);
27 zend_update_property_stringl(Z_OBJCE_P(options
), options
, name_str
, name_len
, value_ptr
, value_len TSRMLS_CC
);
30 zend_update_property(Z_OBJCE_P(options
), options
, name_str
, name_len
, value_ptr TSRMLS_CC
);
34 zend_update_property_null(Z_OBJCE_P(options
), options
, name_str
, name_len TSRMLS_CC
);
37 convert_to_array(options
);
41 add_assoc_double_ex(options
, name_str
, name_len
+ 1, *(double *)value_ptr
);
44 add_assoc_long_ex(options
, name_str
, name_len
+ 1, *(long *)value_ptr
);
47 char *value
= estrndup(value_ptr
, value_len
);
48 add_assoc_stringl_ex(options
, name_str
, name_len
+ 1, value
, value_len
, 0);
51 Z_ADDREF_P(value_ptr
);
52 add_assoc_zval_ex(options
, name_str
, name_len
+ 1, value_ptr
);
57 add_assoc_null_ex(options
, name_str
, name_len
+ 1);
61 static zval
*get_option(zval
*options
, const char *name_str
, size_t name_len TSRMLS_DC
)
65 if (Z_TYPE_P(options
) == IS_OBJECT
) {
66 val
= zend_read_property(Z_OBJCE_P(options
), options
, name_str
, name_len
, 0 TSRMLS_CC
);
68 if (SUCCESS
== zend_symtable_find(Z_ARRVAL_P(options
), name_str
, name_len
+ 1, (void *) &valptr
)) {
79 static php_http_message_body_t
*get_body(zval
*options TSRMLS_DC
)
82 php_http_message_body_t
*body
= NULL
;
84 if ((zbody
= get_option(options
, ZEND_STRL("body") TSRMLS_CC
))) {
85 if ((Z_TYPE_P(zbody
) == IS_OBJECT
) && instanceof_function(Z_OBJCE_P(zbody
), php_http_message_body_class_entry TSRMLS_CC
)) {
86 php_http_message_body_object_t
*body_obj
= zend_object_store_get_object(zbody TSRMLS_CC
);
88 body
= body_obj
->body
;
90 zval_ptr_dtor(&zbody
);
95 static php_http_message_t
*get_request(zval
*options TSRMLS_DC
)
98 php_http_message_t
*request
= NULL
;
100 if ((zrequest
= get_option(options
, ZEND_STRL("request") TSRMLS_CC
))) {
101 if (Z_TYPE_P(zrequest
) == IS_OBJECT
&& instanceof_function(Z_OBJCE_P(zrequest
), php_http_message_class_entry TSRMLS_CC
)) {
102 php_http_message_object_t
*request_obj
= zend_object_store_get_object(zrequest TSRMLS_CC
);
104 request
= request_obj
->message
;
106 zval_ptr_dtor(&zrequest
);
112 php_http_cache_status_t
php_http_env_is_response_cached_by_etag(zval
*options
, const char *header_str
, size_t header_len
, php_http_message_t
*request TSRMLS_DC
)
114 php_http_cache_status_t ret
= PHP_HTTP_CACHE_NO
;
116 char *header
= NULL
, *etag
;
117 php_http_message_body_t
*body
;
121 if (!(body
= get_body(options TSRMLS_CC
))) {
125 if ((zetag
= get_option(options
, ZEND_STRL("etag") TSRMLS_CC
))) {
126 zval
*zetag_copy
= php_http_ztyp(IS_STRING
, zetag
);
127 zval_ptr_dtor(&zetag
);
131 if (zetag
&& Z_STRLEN_P(zetag
)) {
132 etag
= Z_STRVAL_P(zetag
);
133 } else if ((etag
= php_http_message_body_etag(body
))) {
134 set_option(options
, ZEND_STRL("etag"), IS_STRING
, etag
, strlen(etag
) TSRMLS_CC
);
139 zval_ptr_dtor(&zetag
);
142 if (etag
&& (header
= php_http_env_get_request_header(header_str
, header_len
, NULL
, request TSRMLS_CC
))) {
143 ret
= php_http_match(header
, etag
, PHP_HTTP_MATCH_WORD
) ? PHP_HTTP_CACHE_HIT
: PHP_HTTP_CACHE_MISS
;
154 php_http_cache_status_t
php_http_env_is_response_cached_by_last_modified(zval
*options
, const char *header_str
, size_t header_len
, php_http_message_t
*request TSRMLS_DC
)
156 php_http_cache_status_t ret
= PHP_HTTP_CACHE_NO
;
159 php_http_message_body_t
*body
;
162 if (!(body
= get_body(options TSRMLS_CC
))) {
166 if ((zlm
= get_option(options
, ZEND_STRL("lastModified") TSRMLS_CC
))) {
167 zval
*zlm_copy
= php_http_ztyp(IS_LONG
, zlm
);
172 if (zlm
&& Z_LVAL_P(zlm
) > 0) {
175 lm
= php_http_message_body_mtime(body
);
176 set_option(options
, ZEND_STRL("lastModified"), IS_LONG
, &lm
, 0 TSRMLS_CC
);
183 if ((header
= php_http_env_get_request_header(header_str
, header_len
, NULL
, request TSRMLS_CC
))) {
184 ums
= php_parse_date(header
, NULL
);
186 if (ums
> 0 && ums
>= lm
) {
187 ret
= PHP_HTTP_CACHE_HIT
;
189 ret
= PHP_HTTP_CACHE_MISS
;
197 static zend_bool
php_http_env_response_is_cacheable(php_http_env_response_t
*r
, php_http_message_t
*request
)
199 TSRMLS_FETCH_FROM_CTX(r
->ts
);
201 if (r
->ops
->get_status(r
) >= 400) {
205 if (php_http_env_got_request_header(ZEND_STRL("Authorization"), request TSRMLS_CC
)) {
209 if (-1 == php_http_select_str(php_http_env_get_request_method(request TSRMLS_CC
), 2, "HEAD", "GET")) {
216 static size_t output(void *context
, char *buf
, size_t len TSRMLS_DC
)
218 php_http_env_response_t
*r
= context
;
220 r
->ops
->write(r
, buf
, len
);
222 /* we really only need to flush when throttling is enabled,
223 because we push the data as fast as possible anyway if not */
224 if (r
->throttle
.delay
>= PHP_HTTP_DIFFSEC
) {
226 php_http_sleep(r
->throttle
.delay
);
231 #define php_http_env_response_send_done(r) php_http_env_response_send_data((r), NULL, 0)
232 static STATUS
php_http_env_response_send_data(php_http_env_response_t
*r
, const char *buf
, size_t len
)
234 size_t chunk
= r
->throttle
.chunk
? r
->throttle
.chunk
: PHP_HTTP_SENDBUF_SIZE
;
235 TSRMLS_FETCH_FROM_CTX(r
->ts
);
237 if (r
->content
.encoder
) {
238 char *enc_str
= NULL
;
242 if (SUCCESS
!= php_http_encoding_stream_update(r
->content
.encoder
, buf
, len
, &enc_str
, &enc_len
)) {
246 if (SUCCESS
!= php_http_encoding_stream_finish(r
->content
.encoder
, &enc_str
, &enc_len
)) {
252 php_http_buffer_chunked_output(&r
->buffer
, enc_str
, enc_len
, buf
? chunk
: 0, output
, r TSRMLS_CC
);
256 php_http_buffer_chunked_output(&r
->buffer
, buf
, len
, buf
? chunk
: 0, output
, r TSRMLS_CC
);
262 php_http_env_response_t
*php_http_env_response_init(php_http_env_response_t
*r
, zval
*options
, php_http_env_response_ops_t
*ops
, void *init_arg TSRMLS_DC
)
267 r
= emalloc(sizeof(*r
));
269 memset(r
, 0, sizeof(*r
));
274 r
->ops
= php_http_env_response_get_sapi_ops();
277 r
->buffer
= php_http_buffer_init(NULL
);
280 r
->options
= options
;
282 TSRMLS_SET_CTX(r
->ts
);
284 if (r
->ops
->init
&& (SUCCESS
!= r
->ops
->init(r
, init_arg
))) {
286 php_http_env_response_free(&r
);
288 php_http_env_response_dtor(r
);
296 void php_http_env_response_dtor(php_http_env_response_t
*r
)
301 php_http_buffer_free(&r
->buffer
);
302 zval_ptr_dtor(&r
->options
);
303 STR_FREE(r
->content
.type
);
304 STR_FREE(r
->content
.encoding
);
305 if (r
->content
.encoder
) {
306 php_http_encoding_stream_free(&r
->content
.encoder
);
310 void php_http_env_response_free(php_http_env_response_t
**r
)
313 php_http_env_response_dtor(*r
);
319 static STATUS
php_http_env_response_send_head(php_http_env_response_t
*r
, php_http_message_t
*request
)
321 STATUS ret
= SUCCESS
;
322 zval
*zoption
, *options
= r
->options
;
323 TSRMLS_FETCH_FROM_CTX(r
->ts
);
329 if ((zoption
= get_option(options
, ZEND_STRL("responseCode") TSRMLS_CC
))) {
330 zval
*zoption_copy
= php_http_ztyp(IS_LONG
, zoption
);
332 zval_ptr_dtor(&zoption
);
333 if (Z_LVAL_P(zoption_copy
) > 0) {
334 ret
= r
->ops
->set_status(r
, Z_LVAL_P(zoption_copy
));
336 zval_ptr_dtor(&zoption_copy
);
339 if (ret
!= SUCCESS
) {
343 if ((zoption
= get_option(options
, ZEND_STRL("httpVersion") TSRMLS_CC
))) {
344 php_http_version_t v
;
345 zval
*zoption_copy
= php_http_ztyp(IS_STRING
, zoption
);
347 zval_ptr_dtor(&zoption
);
348 if (Z_STRLEN_P(zoption_copy
) && php_http_version_parse(&v
, Z_STRVAL_P(zoption_copy
) TSRMLS_CC
)) {
349 ret
= r
->ops
->set_protocol_version(r
, &v
);
350 php_http_version_dtor(&v
);
352 zval_ptr_dtor(&zoption_copy
);
355 if (ret
!= SUCCESS
) {
359 if ((zoption
= get_option(options
, ZEND_STRL("headers") TSRMLS_CC
))) {
360 if (Z_TYPE_P(zoption
) == IS_ARRAY
) {
361 php_http_header_to_callback(Z_ARRVAL_P(zoption
), 0, (php_http_pass_format_callback_t
) r
->ops
->set_header
, r TSRMLS_CC
);
363 zval_ptr_dtor(&zoption
);
366 if (ret
!= SUCCESS
) {
370 if ((zoption
= get_option(options
, ZEND_STRL("contentType") TSRMLS_CC
))) {
371 zval
*zoption_copy
= php_http_ztyp(IS_STRING
, zoption
);
373 zval_ptr_dtor(&zoption
);
374 if (Z_STRLEN_P(zoption_copy
) && strchr(Z_STRVAL_P(zoption_copy
), '/')) {
375 if (SUCCESS
== (ret
= r
->ops
->set_header(r
, "Content-Type: %.*s", Z_STRLEN_P(zoption_copy
), Z_STRVAL_P(zoption_copy
)))) {
376 r
->content
.type
= estrndup(Z_STRVAL_P(zoption_copy
), Z_STRLEN_P(zoption_copy
));
379 zval_ptr_dtor(&zoption_copy
);
382 if (ret
!= SUCCESS
) {
386 if (r
->range
.status
== PHP_HTTP_RANGE_OK
) {
387 if (zend_hash_num_elements(&r
->range
.values
) == 1) {
388 zval
**range
, **begin
, **end
;
390 if ( 1 == php_http_array_list(&r
->range
.values TSRMLS_CC
, 1, &range
)
391 && 2 == php_http_array_list(Z_ARRVAL_PP(range
) TSRMLS_CC
, 2, &begin
, &end
)
393 if (SUCCESS
== (ret
= r
->ops
->set_status(r
, 206))) {
394 ret
= r
->ops
->set_header(r
, "Content-Range: bytes %ld-%ld/%zu", Z_LVAL_PP(begin
), Z_LVAL_PP(end
), r
->content
.length
);
397 /* this should never happen */
398 zend_hash_destroy(&r
->range
.values
);
402 php_http_boundary(r
->range
.boundary
, sizeof(r
->range
.boundary
) TSRMLS_CC
);
403 if (SUCCESS
== (ret
= r
->ops
->set_status(r
, 206))) {
404 ret
= r
->ops
->set_header(r
, "Content-Type: multipart/byteranges; boundary=%s", r
->range
.boundary
);
408 if ((zoption
= get_option(options
, ZEND_STRL("cacheControl") TSRMLS_CC
))) {
409 zval
*zoption_copy
= php_http_ztyp(IS_STRING
, zoption
);
411 zval_ptr_dtor(&zoption
);
412 if (Z_STRLEN_P(zoption_copy
)) {
413 ret
= r
->ops
->set_header(r
, "Cache-Control: %.*s", Z_STRLEN_P(zoption_copy
), Z_STRVAL_P(zoption_copy
));
415 zval_ptr_dtor(&zoption_copy
);
418 if (ret
!= SUCCESS
) {
422 if ((zoption
= get_option(options
, ZEND_STRL("contentDisposition") TSRMLS_CC
))) {
423 zval
*zoption_copy
= php_http_ztyp(IS_ARRAY
, zoption
);
424 php_http_buffer_t buf
;
426 php_http_buffer_init(&buf
);
427 if (php_http_params_to_string(&buf
, Z_ARRVAL_P(zoption_copy
), ZEND_STRL(","), ZEND_STRL(";"), ZEND_STRL("="), PHP_HTTP_PARAMS_DEFAULT TSRMLS_CC
)) {
429 ret
= r
->ops
->set_header(r
, "Content-Disposition: %.*s", buf
.used
, buf
.data
);
433 php_http_buffer_dtor(&buf
);
434 zval_ptr_dtor(&zoption_copy
);
435 zval_ptr_dtor(&zoption
);
438 if (ret
!= SUCCESS
) {
442 if ((zoption
= get_option(options
, ZEND_STRL("contentEncoding") TSRMLS_CC
))) {
443 zval
*zoption_copy
= php_http_ztyp(IS_LONG
, zoption
);
445 HashTable
*result
= NULL
;
447 zval_ptr_dtor(&zoption
);
448 switch (Z_LVAL_P(zoption_copy
)) {
449 case PHP_HTTP_CONTENT_ENCODING_GZIP
:
450 INIT_PZVAL(&zsupported
);
451 array_init(&zsupported
);
452 add_next_index_stringl(&zsupported
, ZEND_STRL("none"), 1);
453 add_next_index_stringl(&zsupported
, ZEND_STRL("gzip"), 1);
454 add_next_index_stringl(&zsupported
, ZEND_STRL("deflate"), 1);
456 if ((result
= php_http_negotiate_encoding(Z_ARRVAL(zsupported
), request TSRMLS_CC
))) {
457 char *key_str
= NULL
;
460 zend_hash_internal_pointer_reset(result
);
461 if (HASH_KEY_IS_STRING
== zend_hash_get_current_key_ex(result
, &key_str
, &key_len
, NULL
, 0, NULL
)) {
462 if (!strcmp(key_str
, "gzip")) {
463 if (!(r
->content
.encoder
= php_http_encoding_stream_init(NULL
, php_http_encoding_stream_get_deflate_ops(), PHP_HTTP_DEFLATE_TYPE_GZIP TSRMLS_CC
))) {
465 } else if (SUCCESS
== (ret
= r
->ops
->set_header(r
, "Content-Encoding: gzip"))) {
466 r
->content
.encoding
= estrndup(key_str
, key_len
- 1);
468 } else if (!strcmp(key_str
, "deflate")) {
469 if (!(r
->content
.encoder
= php_http_encoding_stream_init(NULL
, php_http_encoding_stream_get_deflate_ops(), PHP_HTTP_DEFLATE_TYPE_ZLIB TSRMLS_CC
))) {
471 } else if (SUCCESS
== (ret
= r
->ops
->set_header(r
, "Content-Encoding: deflate"))) {
472 r
->content
.encoding
= estrndup(key_str
, key_len
- 1);
475 ret
= r
->ops
->del_header(r
, ZEND_STRL("Content-Encoding"));
478 if (SUCCESS
== ret
) {
479 ret
= r
->ops
->add_header(r
, "Vary: Accept-Encoding");
483 zend_hash_destroy(result
);
484 FREE_HASHTABLE(result
);
487 zval_dtor(&zsupported
);
490 case PHP_HTTP_CONTENT_ENCODING_NONE
:
492 ret
= r
->ops
->del_header(r
, ZEND_STRL("Content-Encoding"));
495 zval_ptr_dtor(&zoption_copy
);
498 if (SUCCESS
!= ret
) {
502 if (php_http_env_response_is_cacheable(r
, request
)) {
503 switch (php_http_env_is_response_cached_by_etag(options
, ZEND_STRL("If-None-Match"), request TSRMLS_CC
)) {
504 case PHP_HTTP_CACHE_MISS
:
507 case PHP_HTTP_CACHE_NO
:
508 if (PHP_HTTP_CACHE_HIT
!= php_http_env_is_response_cached_by_last_modified(options
, ZEND_STRL("If-Modified-Since"), request TSRMLS_CC
)) {
513 case PHP_HTTP_CACHE_HIT
:
514 ret
= r
->ops
->set_status(r
, 304);
519 if ((zoption
= get_option(options
, ZEND_STRL("etag") TSRMLS_CC
))) {
520 zval
*zoption_copy
= php_http_ztyp(IS_STRING
, zoption
);
522 zval_ptr_dtor(&zoption
);
523 if (*Z_STRVAL_P(zoption_copy
) != '"' && strncmp(Z_STRVAL_P(zoption_copy
), "W/\"", 3)) {
524 ret
= r
->ops
->set_header(r
, "ETag: \"%s\"", Z_STRVAL_P(zoption_copy
));
526 ret
= r
->ops
->set_header(r
, "ETag: %s", Z_STRVAL_P(zoption_copy
));
528 zval_ptr_dtor(&zoption_copy
);
530 if ((zoption
= get_option(options
, ZEND_STRL("lastModified") TSRMLS_CC
))) {
531 zval
*zoption_copy
= php_http_ztyp(IS_LONG
, zoption
);
533 zval_ptr_dtor(&zoption
);
534 if (Z_LVAL_P(zoption_copy
)) {
535 char *date
= php_format_date(ZEND_STRL(PHP_HTTP_DATE_FORMAT
), Z_LVAL_P(zoption_copy
), 0 TSRMLS_CC
);
537 ret
= r
->ops
->set_header(r
, "Last-Modified: %s", date
);
541 zval_ptr_dtor(&zoption_copy
);
549 static STATUS
php_http_env_response_send_body(php_http_env_response_t
*r
)
551 STATUS ret
= SUCCESS
;
553 php_http_message_body_t
*body
;
554 TSRMLS_FETCH_FROM_CTX(r
->ts
);
560 if ((body
= get_body(r
->options TSRMLS_CC
))) {
561 if ((zoption
= get_option(r
->options
, ZEND_STRL("throttleDelay") TSRMLS_CC
))) {
562 if (Z_TYPE_P(zoption
) == IS_DOUBLE
) {
563 r
->throttle
.delay
= Z_DVAL_P(zoption
);
565 zval_ptr_dtor(&zoption
);
567 if ((zoption
= get_option(r
->options
, ZEND_STRL("throttleChunk") TSRMLS_CC
))) {
568 if (Z_TYPE_P(zoption
) == IS_LONG
) {
569 r
->throttle
.chunk
= Z_LVAL_P(zoption
);
571 zval_ptr_dtor(&zoption
);
574 if (r
->range
.status
== PHP_HTTP_RANGE_OK
) {
575 if (zend_hash_num_elements(&r
->range
.values
) == 1) {
577 zval
**range
, **begin
, **end
;
579 if ( 1 == php_http_array_list(&r
->range
.values TSRMLS_CC
, 1, &range
)
580 && 2 == php_http_array_list(Z_ARRVAL_PP(range
) TSRMLS_CC
, 2, &begin
, &end
)
583 ret
= php_http_message_body_to_callback(body
, (php_http_pass_callback_t
) php_http_env_response_send_data
, r
, Z_LVAL_PP(begin
), Z_LVAL_PP(end
) - Z_LVAL_PP(begin
) + 1);
584 if (ret
== SUCCESS
) {
585 ret
= php_http_env_response_send_done(r
);
587 zend_hash_destroy(&r
->range
.values
);
589 /* this should never happen */
590 zend_hash_destroy(&r
->range
.values
);
591 r
->ops
->set_status(r
, 500);
596 /* send multipart/byte-ranges message */
600 FOREACH_HASH_VAL(pos
, &r
->range
.values
, chunk
) {
603 if (2 == php_http_array_list(Z_ARRVAL_PP(chunk
) TSRMLS_CC
, 2, &begin
, &end
)) {
604 php_http_buffer_appendf(r
->buffer
,
607 "Content-Type: %s" PHP_HTTP_CRLF
608 "Content-Range: bytes %ld-%ld/%zu" PHP_HTTP_CRLF PHP_HTTP_CRLF
,
611 r
->content
.type
? r
->content
.type
: "application/octet-stream",
616 ret
= php_http_message_body_to_callback(body
, (php_http_pass_callback_t
) php_http_env_response_send_data
, r
, Z_LVAL_PP(begin
), Z_LVAL_PP(end
) - Z_LVAL_PP(begin
) + 1);
620 if (ret
== SUCCESS
) {
621 php_http_buffer_appendf(r
->buffer
, PHP_HTTP_CRLF
"--%s--", r
->range
.boundary
);
622 ret
= php_http_env_response_send_done(r
);
624 zend_hash_destroy(&r
->range
.values
);
628 ret
= php_http_message_body_to_callback(body
, (php_http_pass_callback_t
) php_http_env_response_send_data
, r
, 0, 0);
629 if (ret
== SUCCESS
) {
630 ret
= php_http_env_response_send_done(r
);
637 STATUS
php_http_env_response_send(php_http_env_response_t
*r
)
639 php_http_message_t
*request
;
640 php_http_message_body_t
*body
;
641 TSRMLS_FETCH_FROM_CTX(r
->ts
);
643 request
= get_request(r
->options TSRMLS_CC
);
645 /* check for ranges */
646 if ((body
= get_body(r
->options TSRMLS_CC
))) {
647 r
->content
.length
= php_http_message_body_size(body
);
649 if (SUCCESS
!= r
->ops
->set_header(r
, "Accept-Ranges: bytes")) {
652 zend_hash_init(&r
->range
.values
, 0, NULL
, ZVAL_PTR_DTOR
, 0);
653 r
->range
.status
= php_http_env_get_request_ranges(&r
->range
.values
, r
->content
.length
, request TSRMLS_CC
);
655 switch (r
->range
.status
) {
656 case PHP_HTTP_RANGE_NO
:
657 zend_hash_destroy(&r
->range
.values
);
660 case PHP_HTTP_RANGE_ERR
:
661 if (php_http_env_got_request_header(ZEND_STRL("If-Range"), request TSRMLS_CC
)) {
662 r
->range
.status
= PHP_HTTP_RANGE_NO
;
663 zend_hash_destroy(&r
->range
.values
);
666 zend_hash_destroy(&r
->range
.values
);
667 if (SUCCESS
!= r
->ops
->set_status(r
, 416)) {
670 if (SUCCESS
!= r
->ops
->set_header(r
, "Content-Range: bytes */%zu", r
->content
.length
)) {
676 case PHP_HTTP_RANGE_OK
:
677 if (PHP_HTTP_CACHE_MISS
== php_http_env_is_response_cached_by_etag(r
->options
, ZEND_STRL("If-Range"), request TSRMLS_CC
)
678 || PHP_HTTP_CACHE_MISS
== php_http_env_is_response_cached_by_last_modified(r
->options
, ZEND_STRL("If-Range"), request TSRMLS_CC
)
680 r
->range
.status
= PHP_HTTP_RANGE_NO
;
681 zend_hash_destroy(&r
->range
.values
);
684 if (PHP_HTTP_CACHE_MISS
== php_http_env_is_response_cached_by_etag(r
->options
, ZEND_STRL("If-Match"), request TSRMLS_CC
)
685 || PHP_HTTP_CACHE_MISS
== php_http_env_is_response_cached_by_last_modified(r
->options
, ZEND_STRL("If-Unmodified-Since"), request TSRMLS_CC
)
686 || PHP_HTTP_CACHE_MISS
== php_http_env_is_response_cached_by_last_modified(r
->options
, ZEND_STRL("Unless-Modified-Since"), request TSRMLS_CC
)
689 zend_hash_destroy(&r
->range
.values
);
690 if (SUCCESS
!= r
->ops
->set_status(r
, 412)) {
701 if (SUCCESS
!= php_http_env_response_send_head(r
, request
)) {
702 php_error_docref(NULL TSRMLS_CC
, E_WARNING
, "Failed to send response headers");
706 if (SUCCESS
!= php_http_env_response_send_body(r
)) {
707 php_error_docref(NULL TSRMLS_CC
, E_WARNING
, "Failed to send response body");
711 if (SUCCESS
!= r
->ops
->finish(r
)) {
712 php_error_docref(NULL TSRMLS_CC
, E_WARNING
, "Failed to finish response");
719 static long php_http_env_response_sapi_get_status(php_http_env_response_t
*r
)
721 TSRMLS_FETCH_FROM_CTX(r
->ts
);
723 return php_http_env_get_response_code(TSRMLS_C
);
725 static STATUS
php_http_env_response_sapi_set_status(php_http_env_response_t
*r
, long http_code
)
727 TSRMLS_FETCH_FROM_CTX(r
->ts
);
729 return php_http_env_set_response_code(http_code TSRMLS_CC
);
731 static STATUS
php_http_env_response_sapi_set_protocol_version(php_http_env_response_t
*r
, php_http_version_t
*v
)
733 TSRMLS_FETCH_FROM_CTX(r
->ts
);
735 return php_http_env_set_response_protocol_version(v TSRMLS_CC
);
737 static STATUS
php_http_env_response_sapi_set_header(php_http_env_response_t
*r
, const char *fmt
, ...)
741 TSRMLS_FETCH_FROM_CTX(r
->ts
);
744 ret
= php_http_env_set_response_header_va(0, 1, fmt
, args TSRMLS_CC
);
749 static STATUS
php_http_env_response_sapi_add_header(php_http_env_response_t
*r
, const char *fmt
, ...)
753 TSRMLS_FETCH_FROM_CTX(r
->ts
);
756 ret
= php_http_env_set_response_header_va(0, 0, fmt
, args TSRMLS_CC
);
761 static STATUS
php_http_env_response_sapi_del_header(php_http_env_response_t
*r
, const char *header_str
, size_t header_len
)
763 TSRMLS_FETCH_FROM_CTX(r
->ts
);
765 return php_http_env_set_response_header_value(0, header_str
, header_len
, NULL
, 1 TSRMLS_CC
);
767 static STATUS
php_http_env_response_sapi_write(php_http_env_response_t
*r
, const char *data_str
, size_t data_len
)
769 TSRMLS_FETCH_FROM_CTX(r
->ts
);
771 if (0 < PHPWRITE(data_str
, data_len
)) {
776 static STATUS
php_http_env_response_sapi_flush(php_http_env_response_t
*r
)
778 TSRMLS_FETCH_FROM_CTX(r
->ts
);
780 #if PHP_VERSION_ID >= 50400
781 if (php_output_get_level(TSRMLS_C
)) {
782 php_output_flush_all(TSRMLS_C
);
784 if (!(php_output_get_status(TSRMLS_C
) & PHP_OUTPUT_IMPLICITFLUSH
)) {
785 sapi_flush(TSRMLS_C
);
788 php_end_ob_buffer(1, 1 TSRMLS_CC
);
789 sapi_flush(TSRMLS_C
);
794 static STATUS
php_http_env_response_sapi_finish(php_http_env_response_t
*r
)
799 static php_http_env_response_ops_t php_http_env_response_sapi_ops
= {
802 php_http_env_response_sapi_get_status
,
803 php_http_env_response_sapi_set_status
,
804 php_http_env_response_sapi_set_protocol_version
,
805 php_http_env_response_sapi_set_header
,
806 php_http_env_response_sapi_add_header
,
807 php_http_env_response_sapi_del_header
,
808 php_http_env_response_sapi_write
,
809 php_http_env_response_sapi_flush
,
810 php_http_env_response_sapi_finish
813 php_http_env_response_ops_t
*php_http_env_response_get_sapi_ops(void)
815 return &php_http_env_response_sapi_ops
;
818 typedef struct php_http_env_response_stream_ctx
{
820 php_http_version_t version
;
827 } php_http_env_response_stream_ctx_t
;
829 static STATUS
php_http_env_response_stream_init(php_http_env_response_t
*r
, void *init_arg
)
831 php_http_env_response_stream_ctx_t
*ctx
;
832 TSRMLS_FETCH_FROM_CTX(r
->ts
);
834 ctx
= ecalloc(1, sizeof(*ctx
));
836 ctx
->stream
= init_arg
;
837 if (SUCCESS
!= zend_list_addref(ctx
->stream
->rsrc_id
)) {
841 zend_hash_init(&ctx
->header
, 0, NULL
, ZVAL_PTR_DTOR
, 0);
842 php_http_version_init(&ctx
->version
, 1, 1 TSRMLS_CC
);
843 ctx
->status_code
= 200;
849 static void php_http_env_response_stream_dtor(php_http_env_response_t
*r
)
851 php_http_env_response_stream_ctx_t
*ctx
= r
->ctx
;
852 TSRMLS_FETCH_FROM_CTX(r
->ts
);
854 zend_hash_destroy(&ctx
->header
);
855 zend_list_delete(ctx
->stream
->rsrc_id
);
859 static void php_http_env_response_stream_header(php_http_env_response_stream_ctx_t
*ctx
, HashTable
*header TSRMLS_DC
)
864 FOREACH_HASH_VAL(pos
, &ctx
->header
, val
) {
865 if (Z_TYPE_PP(val
) == IS_ARRAY
) {
866 php_http_env_response_stream_header(ctx
, Z_ARRVAL_PP(val
) TSRMLS_CC
);
868 php_stream_write(ctx
->stream
, Z_STRVAL_PP(val
), Z_STRLEN_PP(val
));
869 php_stream_write_string(ctx
->stream
, PHP_HTTP_CRLF
);
873 static STATUS
php_http_env_response_stream_start(php_http_env_response_stream_ctx_t
*ctx TSRMLS_DC
)
875 if (ctx
->started
|| ctx
->finished
) {
879 php_stream_printf(ctx
->stream TSRMLS_CC
, "HTTP/%u.%u %ld %s" PHP_HTTP_CRLF
, ctx
->version
.major
, ctx
->version
.minor
, ctx
->status_code
, php_http_env_get_response_status_for_code(ctx
->status_code
));
880 php_http_env_response_stream_header(ctx
, &ctx
->header TSRMLS_CC
);
881 php_stream_write_string(ctx
->stream
, PHP_HTTP_CRLF
);
885 static long php_http_env_response_stream_get_status(php_http_env_response_t
*r
)
887 php_http_env_response_stream_ctx_t
*ctx
= r
->ctx
;
889 return ctx
->status_code
;
891 static STATUS
php_http_env_response_stream_set_status(php_http_env_response_t
*r
, long http_code
)
893 php_http_env_response_stream_ctx_t
*stream_ctx
= r
->ctx
;
895 if (stream_ctx
->started
|| stream_ctx
->finished
) {
899 stream_ctx
->status_code
= http_code
;
903 static STATUS
php_http_env_response_stream_set_protocol_version(php_http_env_response_t
*r
, php_http_version_t
*v
)
905 php_http_env_response_stream_ctx_t
*stream_ctx
= r
->ctx
;
907 if (stream_ctx
->started
|| stream_ctx
->finished
) {
911 memcpy(&stream_ctx
->version
, v
, sizeof(stream_ctx
->version
));
915 static STATUS
php_http_env_response_stream_set_header_ex(php_http_env_response_t
*r
, zend_bool replace
, const char *fmt
, va_list argv
)
917 php_http_env_response_stream_ctx_t
*stream_ctx
= r
->ctx
;
918 char *header_end
, *header_str
= NULL
;
919 size_t header_len
= 0;
920 zval
*zheader
, **zheader_ptr
;
922 if (stream_ctx
->started
|| stream_ctx
->finished
) {
926 header_len
= vspprintf(&header_str
, 0, fmt
, argv
);
928 if (!(header_end
= strchr(header_str
, ':'))) {
935 if (!replace
&& (SUCCESS
== zend_hash_find(&stream_ctx
->header
, header_str
, header_end
- header_str
+ 1, (void *) &zheader_ptr
))) {
936 convert_to_array(*zheader_ptr
);
938 return add_next_index_stringl(*zheader_ptr
, header_str
, header_len
, 0);
940 MAKE_STD_ZVAL(zheader
);
941 ZVAL_STRINGL(zheader
, header_str
, header_len
, 0);
943 if (SUCCESS
!= zend_hash_update(&stream_ctx
->header
, header_str
, header_end
- header_str
+ 1, (void *) &zheader
, sizeof(zval
*), NULL
)) {
944 zval_ptr_dtor(&zheader
);
952 static STATUS
php_http_env_response_stream_set_header(php_http_env_response_t
*r
, const char *fmt
, ...)
958 ret
= php_http_env_response_stream_set_header_ex(r
, 1, fmt
, argv
);
963 static STATUS
php_http_env_response_stream_add_header(php_http_env_response_t
*r
, const char *fmt
, ...)
969 ret
= php_http_env_response_stream_set_header_ex(r
, 0, fmt
, argv
);
974 static STATUS
php_http_env_response_stream_del_header(php_http_env_response_t
*r
, const char *header_str
, size_t header_len
)
976 php_http_env_response_stream_ctx_t
*stream_ctx
= r
->ctx
;
978 if (stream_ctx
->started
|| stream_ctx
->finished
) {
982 zend_hash_del(&stream_ctx
->header
, header_str
, header_len
+ 1);
985 static STATUS
php_http_env_response_stream_write(php_http_env_response_t
*r
, const char *data_str
, size_t data_len
)
987 php_http_env_response_stream_ctx_t
*stream_ctx
= r
->ctx
;
988 TSRMLS_FETCH_FROM_CTX(r
->ts
);
990 if (stream_ctx
->finished
) {
993 if (!stream_ctx
->started
) {
994 if (SUCCESS
!= php_http_env_response_stream_start(stream_ctx TSRMLS_CC
)) {
999 php_stream_write(stream_ctx
->stream
, data_str
, data_len
);
1003 static STATUS
php_http_env_response_stream_flush(php_http_env_response_t
*r
)
1005 php_http_env_response_stream_ctx_t
*stream_ctx
= r
->ctx
;
1006 TSRMLS_FETCH_FROM_CTX(r
->ts
);
1008 if (stream_ctx
->finished
) {
1011 if (!stream_ctx
->started
) {
1012 if (SUCCESS
!= php_http_env_response_stream_start(stream_ctx TSRMLS_CC
)) {
1017 return php_stream_flush(stream_ctx
->stream
);
1019 static STATUS
php_http_env_response_stream_finish(php_http_env_response_t
*r
)
1021 php_http_env_response_stream_ctx_t
*stream_ctx
= r
->ctx
;
1022 TSRMLS_FETCH_FROM_CTX(r
->ts
);
1024 if (stream_ctx
->finished
) {
1027 if (!stream_ctx
->started
) {
1028 if (SUCCESS
!= php_http_env_response_stream_start(stream_ctx TSRMLS_CC
)) {
1033 stream_ctx
->finished
= 1;
1038 static php_http_env_response_ops_t php_http_env_response_stream_ops
= {
1039 php_http_env_response_stream_init
,
1040 php_http_env_response_stream_dtor
,
1041 php_http_env_response_stream_get_status
,
1042 php_http_env_response_stream_set_status
,
1043 php_http_env_response_stream_set_protocol_version
,
1044 php_http_env_response_stream_set_header
,
1045 php_http_env_response_stream_add_header
,
1046 php_http_env_response_stream_del_header
,
1047 php_http_env_response_stream_write
,
1048 php_http_env_response_stream_flush
,
1049 php_http_env_response_stream_finish
1052 php_http_env_response_ops_t
*php_http_env_response_get_stream_ops(void)
1054 return &php_http_env_response_stream_ops
;
1057 #define PHP_HTTP_ENV_RESPONSE_OBJECT_INIT(obj) \
1059 if (!obj->message) { \
1060 obj->message = php_http_message_init_env(NULL, PHP_HTTP_RESPONSE TSRMLS_CC); \
1064 ZEND_BEGIN_ARG_INFO_EX(ai_HttpEnvResponse___construct
, 0, 0, 0)
1065 ZEND_END_ARG_INFO();
1066 static PHP_METHOD(HttpEnvResponse
, __construct
)
1068 php_http_message_object_t
*obj
;
1070 php_http_expect(SUCCESS
== zend_parse_parameters_none(), invalid_arg
, return);
1072 obj
= zend_object_store_get_object(getThis() TSRMLS_CC
);
1074 php_http_expect(obj
->message
= php_http_message_init_env(obj
->message
, PHP_HTTP_RESPONSE TSRMLS_CC
), unexpected_val
, return);
1077 ZEND_BEGIN_ARG_INFO_EX(ai_HttpEnvResponse___invoke
, 0, 0, 1)
1078 ZEND_ARG_INFO(0, ob_string
)
1079 ZEND_ARG_INFO(0, ob_flags
)
1080 ZEND_END_ARG_INFO();
1081 static PHP_METHOD(HttpEnvResponse
, __invoke
)
1087 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s|l", &ob_str
, &ob_len
, &ob_flags
)) {
1088 php_http_message_object_t
*obj
= zend_object_store_get_object(getThis() TSRMLS_CC
);
1090 PHP_HTTP_ENV_RESPONSE_OBJECT_INIT(obj
);
1092 php_http_message_object_init_body_object(obj
);
1093 php_http_message_body_append(obj
->message
->body
, ob_str
, ob_len
);
1098 ZEND_BEGIN_ARG_INFO_EX(ai_HttpEnvResponse_setEnvRequest
, 0, 0, 1)
1099 ZEND_ARG_OBJ_INFO(0, env_request
, http
\\Message
, 1)
1100 ZEND_END_ARG_INFO();
1101 static PHP_METHOD(HttpEnvResponse
, setEnvRequest
)
1103 zval
*env_req
= NULL
;
1105 php_http_expect(SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|O", &env_req
, php_http_message_class_entry
), invalid_arg
, return);
1107 set_option(getThis(), ZEND_STRL("request"), IS_OBJECT
, env_req
, 0 TSRMLS_CC
);
1108 RETVAL_ZVAL(getThis(), 1, 0);
1111 ZEND_BEGIN_ARG_INFO_EX(ai_HttpEnvResponse_setContentType
, 0, 0, 1)
1112 ZEND_ARG_INFO(0, content_type
)
1113 ZEND_END_ARG_INFO();
1114 static PHP_METHOD(HttpEnvResponse
, setContentType
)
1116 char *ct_str
= NULL
;
1119 php_http_expect(SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s!", &ct_str
, &ct_len
), invalid_arg
, return);
1121 set_option(getThis(), ZEND_STRL("contentType"), IS_STRING
, ct_str
, ct_len TSRMLS_CC
);
1122 RETVAL_ZVAL(getThis(), 1, 0);
1125 ZEND_BEGIN_ARG_INFO_EX(ai_HttpEnvResponse_setContentDisposition
, 0, 0, 1)
1126 ZEND_ARG_ARRAY_INFO(0, disposition_params
, 1)
1127 ZEND_END_ARG_INFO();
1128 static PHP_METHOD(HttpEnvResponse
, setContentDisposition
)
1132 php_http_expect(SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "a", &zdisposition
), invalid_arg
, return);
1134 zend_update_property(Z_OBJCE_P(getThis()), getThis(), ZEND_STRL("contentDisposition"), zdisposition TSRMLS_CC
);
1135 RETVAL_ZVAL(getThis(), 1, 0);
1138 ZEND_BEGIN_ARG_INFO_EX(ai_HttpEnvResponse_setContentEncoding
, 0, 0, 1)
1139 ZEND_ARG_INFO(0, content_encoding
)
1140 ZEND_END_ARG_INFO();
1141 static PHP_METHOD(HttpEnvResponse
, setContentEncoding
)
1145 php_http_expect(SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "l", &ce
), invalid_arg
, return);
1147 set_option(getThis(), ZEND_STRL("contentEncoding"), IS_LONG
, &ce
, 0 TSRMLS_CC
);
1148 RETVAL_ZVAL(getThis(), 1, 0);
1151 ZEND_BEGIN_ARG_INFO_EX(ai_HttpEnvResponse_setCacheControl
, 0, 0, 1)
1152 ZEND_ARG_INFO(0, cache_control
)
1153 ZEND_END_ARG_INFO();
1154 static PHP_METHOD(HttpEnvResponse
, setCacheControl
)
1156 char *cc_str
= NULL
;
1159 php_http_expect(SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s!", &cc_str
, &cc_len
), invalid_arg
, return);
1161 set_option(getThis(), ZEND_STRL("cacheControl"), IS_STRING
, cc_str
, cc_len TSRMLS_CC
);
1162 RETVAL_ZVAL(getThis(), 1, 0);
1165 ZEND_BEGIN_ARG_INFO_EX(ai_HttpEnvResponse_setLastModified
, 0, 0, 1)
1166 ZEND_ARG_INFO(0, last_modified
)
1167 ZEND_END_ARG_INFO();
1168 static PHP_METHOD(HttpEnvResponse
, setLastModified
)
1172 php_http_expect(SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "l", &last_modified
), invalid_arg
, return);
1174 set_option(getThis(), ZEND_STRL("lastModified"), IS_LONG
, &last_modified
, 0 TSRMLS_CC
);
1175 RETVAL_ZVAL(getThis(), 1, 0);
1178 ZEND_BEGIN_ARG_INFO_EX(ai_HttpEnvResponse_isCachedByLastModified
, 0, 0, 0)
1179 ZEND_ARG_INFO(0, header_name
)
1180 ZEND_END_ARG_INFO();
1181 static PHP_METHOD(HttpEnvResponse
, isCachedByLastModified
)
1183 char *header_name_str
= NULL
;
1184 int header_name_len
= 0;
1186 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|s!", &header_name_str
, &header_name_len
)) {
1187 if (!header_name_str
|| !header_name_len
) {
1188 header_name_str
= "If-Modified-Since";
1189 header_name_len
= lenof("If-Modified-Since");
1192 RETURN_LONG(php_http_env_is_response_cached_by_last_modified(getThis(), header_name_str
, header_name_len
, get_request(getThis() TSRMLS_CC
) TSRMLS_CC
));
1196 ZEND_BEGIN_ARG_INFO_EX(ai_HttpEnvResponse_setEtag
, 0, 0, 1)
1197 ZEND_ARG_INFO(0, etag
)
1198 ZEND_END_ARG_INFO();
1199 static PHP_METHOD(HttpEnvResponse
, setEtag
)
1201 char *etag_str
= NULL
;
1204 php_http_expect(SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s!", &etag_str
, &etag_len
), invalid_arg
, return);
1206 set_option(getThis(), ZEND_STRL("etag"), IS_STRING
, etag_str
, etag_len TSRMLS_CC
);
1207 RETVAL_ZVAL(getThis(), 1, 0);
1210 ZEND_BEGIN_ARG_INFO_EX(ai_HttpEnvResponse_isCachedByEtag
, 0, 0, 0)
1211 ZEND_ARG_INFO(0, header_name
)
1212 ZEND_END_ARG_INFO();
1213 static PHP_METHOD(HttpEnvResponse
, isCachedByEtag
)
1215 char *header_name_str
= NULL
;
1216 int header_name_len
= 0;
1218 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|s!", &header_name_str
, &header_name_len
)) {
1219 if (!header_name_str
|| !header_name_len
) {
1220 header_name_str
= "If-None-Match";
1221 header_name_len
= lenof("If-None-Match");
1223 RETURN_LONG(php_http_env_is_response_cached_by_etag(getThis(), header_name_str
, header_name_len
, get_request(getThis() TSRMLS_CC
) TSRMLS_CC
));
1227 ZEND_BEGIN_ARG_INFO_EX(ai_HttpEnvResponse_setThrottleRate
, 0, 0, 1)
1228 ZEND_ARG_INFO(0, chunk_size
)
1229 ZEND_ARG_INFO(0, delay
)
1230 ZEND_END_ARG_INFO();
1231 static PHP_METHOD(HttpEnvResponse
, setThrottleRate
)
1236 php_http_expect(SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "l|d", &chunk_size
, &delay
), invalid_arg
, return);
1238 set_option(getThis(), ZEND_STRL("throttleDelay"), IS_DOUBLE
, &delay
, 0 TSRMLS_CC
);
1239 set_option(getThis(), ZEND_STRL("throttleChunk"), IS_LONG
, &chunk_size
, 0 TSRMLS_CC
);
1240 RETVAL_ZVAL(getThis(), 1, 0);
1243 ZEND_BEGIN_ARG_INFO_EX(ai_HttpEnvResponse_send
, 0, 0, 0)
1244 ZEND_ARG_INFO(0, stream
)
1245 ZEND_END_ARG_INFO();
1246 static PHP_METHOD(HttpEnvResponse
, send
)
1248 zval
*zstream
= NULL
;
1249 php_stream
*s
= NULL
;
1251 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|r", &zstream
)) {
1252 /* first flush the output layer to avoid conflicting headers and output;
1253 * also, ob_start($thisEnvResponse) might have been called */
1254 #if PHP_VERSION_ID >= 50400
1255 php_output_end_all(TSRMLS_C
);
1257 php_end_ob_buffers(1 TSRMLS_CC
);
1260 php_http_env_response_t
*r
;
1262 php_stream_from_zval(s
, &zstream
);
1263 r
= php_http_env_response_init(NULL
, getThis(), php_http_env_response_get_stream_ops(), s TSRMLS_CC
);
1268 RETVAL_BOOL(SUCCESS
== php_http_env_response_send(r
));
1269 php_http_env_response_free(&r
);
1271 php_http_env_response_t r
;
1273 if (!php_http_env_response_init(&r
, getThis(), NULL
, NULL TSRMLS_CC
)) {
1277 RETVAL_BOOL(SUCCESS
== php_http_env_response_send(&r
));
1278 php_http_env_response_dtor(&r
);
1283 static zend_function_entry php_http_env_response_methods
[] = {
1284 PHP_ME(HttpEnvResponse
, __construct
, ai_HttpEnvResponse___construct
, ZEND_ACC_PUBLIC
|ZEND_ACC_CTOR
)
1285 PHP_ME(HttpEnvResponse
, __invoke
, ai_HttpEnvResponse___invoke
, ZEND_ACC_PUBLIC
)
1286 PHP_ME(HttpEnvResponse
, setEnvRequest
, ai_HttpEnvResponse_setEnvRequest
, ZEND_ACC_PUBLIC
)
1287 PHP_ME(HttpEnvResponse
, setContentType
, ai_HttpEnvResponse_setContentType
, ZEND_ACC_PUBLIC
)
1288 PHP_ME(HttpEnvResponse
, setContentDisposition
, ai_HttpEnvResponse_setContentDisposition
, ZEND_ACC_PUBLIC
)
1289 PHP_ME(HttpEnvResponse
, setContentEncoding
, ai_HttpEnvResponse_setContentEncoding
, ZEND_ACC_PUBLIC
)
1290 PHP_ME(HttpEnvResponse
, setCacheControl
, ai_HttpEnvResponse_setCacheControl
, ZEND_ACC_PUBLIC
)
1291 PHP_ME(HttpEnvResponse
, setLastModified
, ai_HttpEnvResponse_setLastModified
, ZEND_ACC_PUBLIC
)
1292 PHP_ME(HttpEnvResponse
, isCachedByLastModified
, ai_HttpEnvResponse_isCachedByLastModified
, ZEND_ACC_PUBLIC
)
1293 PHP_ME(HttpEnvResponse
, setEtag
, ai_HttpEnvResponse_setEtag
, ZEND_ACC_PUBLIC
)
1294 PHP_ME(HttpEnvResponse
, isCachedByEtag
, ai_HttpEnvResponse_isCachedByEtag
, ZEND_ACC_PUBLIC
)
1295 PHP_ME(HttpEnvResponse
, setThrottleRate
, ai_HttpEnvResponse_setThrottleRate
, ZEND_ACC_PUBLIC
)
1296 PHP_ME(HttpEnvResponse
, send
, ai_HttpEnvResponse_send
, ZEND_ACC_PUBLIC
)
1297 EMPTY_FUNCTION_ENTRY
1300 zend_class_entry
*php_http_env_response_class_entry
;
1302 PHP_MINIT_FUNCTION(http_env_response
)
1304 zend_class_entry ce
= {0};
1306 INIT_NS_CLASS_ENTRY(ce
, "http\\Env", "Response", php_http_env_response_methods
);
1307 php_http_env_response_class_entry
= zend_register_internal_class_ex(&ce
, php_http_message_class_entry
, NULL TSRMLS_CC
);
1309 zend_declare_class_constant_long(php_http_env_response_class_entry
, ZEND_STRL("CONTENT_ENCODING_NONE"), PHP_HTTP_CONTENT_ENCODING_NONE TSRMLS_CC
);
1310 zend_declare_class_constant_long(php_http_env_response_class_entry
, ZEND_STRL("CONTENT_ENCODING_GZIP"), PHP_HTTP_CONTENT_ENCODING_GZIP TSRMLS_CC
);
1312 zend_declare_class_constant_long(php_http_env_response_class_entry
, ZEND_STRL("CACHE_NO"), PHP_HTTP_CACHE_NO TSRMLS_CC
);
1313 zend_declare_class_constant_long(php_http_env_response_class_entry
, ZEND_STRL("CACHE_HIT"), PHP_HTTP_CACHE_HIT TSRMLS_CC
);
1314 zend_declare_class_constant_long(php_http_env_response_class_entry
, ZEND_STRL("CACHE_MISS"), PHP_HTTP_CACHE_MISS TSRMLS_CC
);
1316 zend_declare_property_null(php_http_env_response_class_entry
, ZEND_STRL("request"), ZEND_ACC_PROTECTED TSRMLS_CC
);
1317 zend_declare_property_null(php_http_env_response_class_entry
, ZEND_STRL("contentType"), ZEND_ACC_PROTECTED TSRMLS_CC
);
1318 zend_declare_property_null(php_http_env_response_class_entry
, ZEND_STRL("contentDisposition"), ZEND_ACC_PROTECTED TSRMLS_CC
);
1319 zend_declare_property_null(php_http_env_response_class_entry
, ZEND_STRL("contentEncoding"), ZEND_ACC_PROTECTED TSRMLS_CC
);
1320 zend_declare_property_null(php_http_env_response_class_entry
, ZEND_STRL("cacheControl"), ZEND_ACC_PROTECTED TSRMLS_CC
);
1321 zend_declare_property_null(php_http_env_response_class_entry
, ZEND_STRL("etag"), ZEND_ACC_PROTECTED TSRMLS_CC
);
1322 zend_declare_property_null(php_http_env_response_class_entry
, ZEND_STRL("lastModified"), ZEND_ACC_PROTECTED TSRMLS_CC
);
1323 zend_declare_property_null(php_http_env_response_class_entry
, ZEND_STRL("throttleDelay"), ZEND_ACC_PROTECTED TSRMLS_CC
);
1324 zend_declare_property_null(php_http_env_response_class_entry
, ZEND_STRL("throttleChunk"), ZEND_ACC_PROTECTED TSRMLS_CC
);
1335 * vim600: noet sw=4 ts=4 fdm=marker
1336 * vim<600: noet sw=4 ts=4