Browse Source

workaround a hanging ssl-connections in Opera 9.01 and 8.54 (and earlier) if chunked-encoding is used

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.11-ssl-fixes@1315 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.12
Jan Kneschke 16 years ago
parent
commit
2721197ff6
  1. 2
      src/chunk.c
  2. 3
      src/http_chunk.c
  3. 29
      src/network_openssl.c

2
src/chunk.c

@ -355,7 +355,7 @@ int chunkqueue_remove_finished_chunks(chunkqueue *cq) {
switch (c->type) {
case MEM_CHUNK:
if (c->offset == (off_t)c->mem->used - 1) is_finished = 1;
if (c->mem->used == 0 || (c->offset == (off_t)c->mem->used - 1)) is_finished = 1;
break;
case FILE_CHUNK:
if (c->offset == c->file.length) is_finished = 1;

3
src/http_chunk.c

@ -100,8 +100,7 @@ int http_chunk_append_mem(server *srv, connection *con, const char * mem, size_t
if (len == 0) {
if (con->response.transfer_encoding & HTTP_TRANSFER_ENCODING_CHUNKED) {
http_chunk_append_len(srv, con, 0);
chunkqueue_append_mem(cq, "\r\n", 2 + 1);
chunkqueue_append_mem(cq, "0\r\n\r\n", 5 + 1);
} else {
chunkqueue_append_mem(cq, "", 1);
}

29
src/network_openssl.c

@ -58,6 +58,35 @@ int network_write_chunkqueue_openssl(server *srv, connection *con, SSL *ssl, chu
SSL_set_shutdown(ssl, SSL_RECEIVED_SHUTDOWN);
}
/* evil hack for opera 9.01 and 8.54 and earlier
*
* opera hangs if the trainling 0\r\n\r\n is in a seperate SSL-packet
*
* we try to move the packet into the previous mem-chunk if possible
*/
if ((cq == con->write_queue) &&
(con->response.transfer_encoding & HTTP_TRANSFER_ENCODING_CHUNKED) &&
(con->file_finished)) {
/* merge the last chunk into the previous chunk */
fprintf(stderr, "%s.%d: trying to merge final chunk\r\n", __FILE__, __LINE__);
for(c = cq->first; c && c->next && c->next->next; c = c->next);
if (c &&
c->type == MEM_CHUNK &&
c->next &&
c->next->type == MEM_CHUNK &&
c->next->mem->used == sizeof("0\r\n\r\n") &&
0 == strcmp(c->next->mem->ptr, "0\r\n\r\n")) {
fprintf(stderr, "%s.%d: trying to merge final chunk, merged\r\n", __FILE__, __LINE__);
buffer_append_string_buffer(c->mem, c->next->mem);
c->next->mem->used = 0;
}
}
for(c = cq->first; c; c = c->next) {
int chunk_finished = 0;

Loading…
Cancel
Save