X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=php_http_message_body.c;h=fa9155110d776d37a0e1e26bed4ec5ef627acee6;hp=0337aa641eda257d9f0dc58a98180256aef1c690;hb=refs%2Fheads%2Fv2.3.x;hpb=4b123a5347d0f16003feb045a5304bbb91630d74 diff --git a/php_http_message_body.c b/php_http_message_body.c index 0337aa6..fa91551 100644 --- a/php_http_message_body.c +++ b/php_http_message_body.c @@ -6,7 +6,7 @@ | modification, are permitted provided that the conditions mentioned | | in the accompanying LICENSE file are met. | +--------------------------------------------------------------------+ - | Copyright (c) 2004-2013, Michael Wallner | + | Copyright (c) 2004-2014, Michael Wallner | +--------------------------------------------------------------------+ */ @@ -100,7 +100,7 @@ void php_http_message_body_free(php_http_message_body_t **body_ptr) TSRMLS_FETCH_FROM_CTX(body->ts); /* NOFIXME: shows leakinfo in DEBUG mode */ zend_list_delete(body->stream_id); - STR_FREE(body->boundary); + PTR_FREE(body->boundary); efree(body); } *body_ptr = NULL; @@ -128,25 +128,29 @@ const char *php_http_message_body_boundary(php_http_message_body_t *body) char *php_http_message_body_etag(php_http_message_body_t *body) { - const php_stream_statbuf *ssb = php_http_message_body_stat(body); + php_http_etag_t *etag; + php_stream *s = php_http_message_body_stream(body); TSRMLS_FETCH_FROM_CTX(body->ts); /* real file or temp buffer ? */ - if (ssb && ssb->sb.st_mtime) { - char *etag; + if (s->ops != &php_stream_temp_ops && s->ops != &php_stream_memory_ops) { + php_stream_stat(php_http_message_body_stream(body), &body->ssb); - spprintf(&etag, 0, "%lx-%lx-%lx", ssb->sb.st_ino, ssb->sb.st_mtime, ssb->sb.st_size); - return etag; - } else { - php_http_etag_t *etag = php_http_etag_init(PHP_HTTP_G->env.etag_mode TSRMLS_CC); + if (body->ssb.sb.st_mtime) { + char *etag; - if (etag) { - php_http_message_body_to_callback(body, (php_http_pass_callback_t) php_http_etag_update, etag, 0, 0); - return php_http_etag_finish(etag); - } else { - return NULL; + spprintf(&etag, 0, "%lx-%lx-%lx", body->ssb.sb.st_ino, body->ssb.sb.st_mtime, body->ssb.sb.st_size); + return etag; } } + + /* content based */ + if ((etag = php_http_etag_init(PHP_HTTP_G->env.etag_mode TSRMLS_CC))) { + php_http_message_body_to_callback(body, (php_http_pass_callback_t) php_http_etag_update, etag, 0, 0); + return php_http_etag_finish(etag); + } + + return NULL; } void php_http_message_body_to_string(php_http_message_body_t *body, char **buf, size_t *len, off_t offset, size_t forlen) @@ -557,7 +561,7 @@ php_http_message_t *php_http_message_body_split(php_http_message_body_t *body, c php_http_buffer_free(&tmp); php_http_message_parser_free(&arg.parser); php_http_buffer_dtor(&arg.buf); - STR_FREE(arg.boundary_str); + PTR_FREE(arg.boundary_str); return msg; }