X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=php_http_message_body.c;h=fa9155110d776d37a0e1e26bed4ec5ef627acee6;hp=6129caff1a9bc4eb2e4af7171eb267f87f8ed196;hb=27b7c648120c1f061ba7c494441347cdb891eea4;hpb=629c7b270b047582160c87b7c688c2b942a75d60 diff --git a/php_http_message_body.c b/php_http_message_body.c index 6129caf..fa91551 100644 --- a/php_http_message_body.c +++ b/php_http_message_body.c @@ -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) @@ -482,11 +486,9 @@ static size_t splitbody(void *opaque, char *buf, size_t len TSRMLS_DC) } if (!first_boundary) { - int st; /* this is not the first boundary, read rest of this message */ php_http_buffer_append(&arg->buf, buf, real_boundary - buf); - st=php_http_message_parser_parse(arg->parser, &arg->buf, 0, &arg->parser->message); - //fprintf(stderr, "1 st=%d\n",st); + php_http_message_parser_parse(arg->parser, &arg->buf, 0, &arg->parser->message); } /* move after the boundary */ @@ -526,11 +528,9 @@ static size_t splitbody(void *opaque, char *buf, size_t len TSRMLS_DC) /* let there be room for the next boundary */ if (len > arg->boundary_len) { - int st; consumed += len - arg->boundary_len; php_http_buffer_append(&arg->buf, buf, len - arg->boundary_len); - st=php_http_message_parser_parse(arg->parser, &arg->buf, 0, &arg->parser->message); - //fprintf(stderr, "2 st=%d\n", st); + php_http_message_parser_parse(arg->parser, &arg->buf, 0, &arg->parser->message); } arg->consumed += consumed;