Project

General

Profile

Docs ModDeflate » mod_deflate-1.4.19-fix-chunked-coding.patch

Fix broken chunked transfer encoding: no last-chunk in mod_cgi after adding mod_deflate - geronimo, 2009-12-16 17:18

View differences:

src/chunk.c Mon Jul 13 13:57:03 2009 +0400 → src/chunk.c Wed Dec 16 18:22:21 2009 +0300
376 376
	return cq->first ? 0 : 1;
377 377
}
378 378

  
379
int chunkqueue_is_empty_or_has_last_chunk(chunkqueue *cq) {
380
	return chunkqueue_is_empty(cq) || is_last_chunk(cq->first);
381
}
382

  
383
int is_last_chunk(chunk* c) {
384
	return c->mem->ptr[0] == '\0' && c->mem->used == 1;
385
}
386

  
379 387
int chunkqueue_remove_finished_chunks(chunkqueue *cq) {
380 388
	chunk *c;
381 389

  
src/chunk.h Mon Jul 13 13:57:03 2009 +0400 → src/chunk.h Wed Dec 16 18:22:21 2009 +0300
67 67
void chunkqueue_reset(chunkqueue *c);
68 68

  
69 69
int chunkqueue_is_empty(chunkqueue *c);
70
int chunkqueue_is_empty_or_has_last_chunk(chunkqueue *c);
71
int is_last_chunk(chunk* c);
70 72

  
71 73
int chunk_encode_append_mem(chunkqueue *cq, const char * mem, size_t len);
72 74
int chunk_encode_append_buffer(chunkqueue *cq, buffer *mem);
src/http_chunk.c Mon Jul 13 13:57:03 2009 +0400 → src/http_chunk.c Wed Dec 16 18:22:21 2009 +0300
85 85
	cq = con->write_queue;
86 86

  
87 87
	if (len == 0) {
88
		if (cq->last == NULL || !is_last_chunk(cq->last)) {
89
			// RFC 2616: last-chunk     = 1*("0") [ chunk-extension ] CRLF
90
			chunkqueue_append_mem(cq, "", 1);
91
		}
92

  
88 93
		return 0;
89 94
	}
90 95

  
src/mod_deflate.c Mon Jul 13 13:57:03 2009 +0400 → src/mod_deflate.c Wed Dec 16 18:22:21 2009 +0300
1009 1009
		chunkqueue_remove_finished_chunks(hctx->in_queue);
1010 1010
	}
1011 1011

  
1012
	close_stream = (con->file_finished && chunkqueue_is_empty(hctx->in_queue));
1012
	close_stream = (con->file_finished && chunkqueue_is_empty_or_has_last_chunk(hctx->in_queue));
1013 1013
	rc = mod_deflate_stream_flush(srv, con, hctx, close_stream);
1014 1014
	if(rc < 0) {
1015 1015
		log_error_write(srv, __FILE__, __LINE__, "s", "flush error");
(9-9/11)