X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=http_api.c;h=6f39434d7b76ef6e429db5b5cce86ad8a1fcb77d;hp=e1dae2dbcbe09e4b07d6c72461f7782ddfcc9e76;hb=8bc520ceaec7aa783bc4cd5ace758d6fb37ed875;hpb=86e60ef185c731dd86cef3c849282eb4f33edd4a diff --git a/http_api.c b/http_api.c index e1dae2d..6f39434 100644 --- a/http_api.c +++ b/http_api.c @@ -562,7 +562,7 @@ static inline void _http_curl_setopts(CURL *ch, const char *url, HashTable *opti /* {{{ static inline char *http_curl_getinfoname(CURLINFO) */ static inline char *_http_curl_getinfoname(CURLINFO i TSRMLS_DC) { -#define CASE(I) case CURLINFO_ ##I : return pretty_key(estrdup( #I ), strlen(#I), 0, 0) +#define CASE(I) case CURLINFO_ ##I : { static char I[] = #I; return pretty_key(I, sizeof(#I)-1, 0, 0); } switch (i) { /* CURLINFO_EFFECTIVE_URL = CURLINFO_STRING +1, */ @@ -1060,9 +1060,12 @@ PHP_HTTP_API inline time_t _http_lmod(const void *data_ptr, const http_send_mode default: { - zval mtime; - php_stat(Z_STRVAL_P((zval *) data_ptr), Z_STRLEN_P((zval *) data_ptr), FS_MTIME, &mtime TSRMLS_CC); - return Z_LVAL(mtime); + if (!HTTP_G(ssb).sb.st_mtime) { + if(php_stream_stat_path(Z_STRVAL_P((zval *) data_ptr), &HTTP_G(ssb))) { + return 0; + } + } + return HTTP_G(ssb).sb.st_mtime; } } } @@ -1329,7 +1332,7 @@ PHP_HTTP_API STATUS _http_send_content_type(const char *content_type, /* {{{ STATUS http_send_content_disposition(char *, size_t, zend_bool) */ PHP_HTTP_API STATUS _http_send_content_disposition(const char *filename, - const size_t f_len, const zend_bool send_inline TSRMLS_DC) + const size_t f_len, const int send_inline TSRMLS_DC) { STATUS status; char *cd_header; @@ -1936,15 +1939,14 @@ PHP_HTTP_API STATUS _http_chunked_decode(const char *encoded, } /* }}} */ -/* {{{ proto STATUS http_split_response(zval *, zval *, zval *) */ -PHP_HTTP_API STATUS _http_split_response(const zval *zresponse, zval *zheaders, - zval *zbody TSRMLS_DC) +/* {{{ proto STATUS http_split_response_ex(char *, size_t, zval *, zval *) */ +PHP_HTTP_API STATUS _http_split_response_ex( char *response, + size_t response_len, zval *zheaders, zval *zbody TSRMLS_DC) { - char *header, *response, *body = NULL; - long response_len = Z_STRLEN_P(zresponse); - header = response = Z_STRVAL_P(zresponse); + char *body = NULL; + char *header = response; - while ((response - Z_STRVAL_P(zresponse) + 3) < response_len) { + while ((response - header + 4) < response_len) { if ( (*response++ == '\r') && (*response++ == '\n') && (*response++ == '\r') && @@ -1960,7 +1962,7 @@ PHP_HTTP_API STATUS _http_split_response(const zval *zresponse, zval *zheaders, Z_TYPE_P(zbody) = IS_NULL; } - return http_parse_headers(header, body - Z_STRVAL_P(zresponse), zheaders); + return http_parse_headers(header, body ? body - header : response_len, zheaders); } /* }}} */