X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=http_send_api.c;h=41ba3058e556d1089853ecf3e2d670ce10696531;hp=52e2b83f59883fa718e904155d0c7748c96f7279;hb=bb6571e22d14c87114eb729145be2e7b87ebea42;hpb=2b7331c5fdb73cb48f7f60a8e4ec88766581ced3 diff --git a/http_send_api.c b/http_send_api.c index 52e2b83..41ba305 100644 --- a/http_send_api.c +++ b/http_send_api.c @@ -27,6 +27,7 @@ #include "php_http.h" #include "php_http_std_defs.h" #include "php_http_api.h" +#include "php_http_date_api.h" #include "php_http_send_api.h" #include "php_http_headers_api.h" #include "php_http_date_api.h" @@ -125,7 +126,7 @@ static STATUS _http_send_chunk(const void *data, size_t begin, size_t end, http_ PHP_HTTP_API STATUS _http_send_status_header(int status, const char *header TSRMLS_DC) { STATUS ret; - sapi_header_line h = {(char *) header, strlen(header), status}; + sapi_header_line h = {(char *) header, header ? strlen(header) : 0, status}; if (SUCCESS != (ret = sapi_header_op(SAPI_HEADER_REPLACE, &h TSRMLS_CC))) { http_error_ex(E_WARNING, HTTP_E_HEADER, "Could not send header: %s (%d)", header, status); } @@ -329,6 +330,9 @@ PHP_HTTP_API STATUS _http_send(const void *data_ptr, size_t data_size, http_send HTTP_G(etag_started) = 0; } + /* enable partial dl and resume */ + http_send_header("Accept-Ranges: bytes"); + zend_hash_init(&ranges, 0, NULL, ZVAL_PTR_DTOR, 0); range_status = http_get_request_ranges(&ranges, data_size); @@ -361,15 +365,14 @@ PHP_HTTP_API STATUS _http_send(const void *data_ptr, size_t data_size, http_send return FAILURE; } if (http_match_etag("HTTP_IF_NONE_MATCH", etag)) { - efree(etag); - return http_cache_exit(); + return http_cache_exit_ex(etag, 1, 1); } efree(etag); } /* send 304 Not Modified if last modified matches */ if (http_match_last_modified("HTTP_IF_MODIFIED_SINCE", HTTP_G(lmod))) { - return http_cache_exit(); + return http_cache_exit_ex(http_date(HTTP_G(lmod)), 0, 1); } /* send full entity */