Karlson2k / libmicrohttpd

GNU libmicrohttpd repository unofficial mirror on GitHub
https://www.gnu.org/software/libmicrohttpd/
Other
101 stars 29 forks source link

MHD_SSO_HDR_CORK might break chunked transfer #7

Closed a1exanderpetrov closed 3 years ago

a1exanderpetrov commented 4 years ago

Hello. I have an issue with https server application which use chunked encoding to transfer data from FreeBSD machine. After freebsd-ports libmicrohttpd updating from 0.9.58 to 0.9.70 wget(and curl) on client side (Ubuntu) getting stuck. As I saw in curl trace-ascii logs last CRLF in chunk ending is missing. After disabling CORK in _MHD_connection_handlewrite() on _MHD_CONNECTION_FOOTERSSENDING state problem was solved. Could it be a bug? Transfers with disabled chunked encoding works well.

Environment:

Changes:

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 3f47c924..cb338543 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -3151,7 +3151,7 @@ MHD_connection_handle_write (struct MHD_Connection *connection)
                                    [connection->write_buffer_send_offset],
                                    connection->write_buffer_append_offset
                                    - connection->write_buffer_send_offset,
-                                   MHD_SSO_HDR_CORK);
+                                   MHD_SSO_NO_CORK);
     if (ret < 0)
     {
       if (MHD_ERR_AGAIN_ == ret)

Originally posted by @a1exanderpetrov in https://github.com/Karlson2k/libmicrohttpd/issues/6#issuecomment-700002928

Karlson2k commented 4 years ago

Hi @a1exanderpetrov. Could you provide a minimal example to reproduce? Do you use TLS or plain HTTP connection?

a1exanderpetrov commented 4 years ago

@Karlson2k I'm using TLS. Here is modified chunked_example.zip from src/examples. It sends testfile.bin which could be generated by command dd if=/dev/zero of=testfile.bin bs=1M count=1 Command to receive data: curl -v -k -o 1.bin "https://127.0.0.1:9080" --trace-ascii trace.log Issue was reproduced on ubuntu (20.04/18.04) machine.

Config summary:

configure: GNU libmicrohttpd 0.9.70 Configuration Summary:
  Target directory:  /usr/local
  Cross-compiling:   no
  Operating System:  linux-gnu
  Shutdown of listening socket trigger select: yes
  Inter-thread comm: eventfd
  poll support:      yes
  epoll support:     yes
  sendfile used:     yes, Linux-style
  HTTPS support:     yes (using libgnutls)
  Threading lib:     posix
  Use thread names:  yes
  Use debug asserts: no
  Messages:          yes
  Gettext:           yes
  Basic auth.:       yes
  Digest auth.:      yes
  HTTP "Upgrade":    yes
  Postproc:          yes
  Build docs:        yes
  Build examples:    yes
  Test with libcurl: yes

configure: HTTPS subsystem configuration:
  License         :  LGPL only
Karlson2k commented 3 years ago

I saw that you reported it on our official bugtracker. New version should fix this problem, please try it.

a1exanderpetrov commented 3 years ago

@Karlson2k thanks for update. Will try it.

Karlson2k commented 3 years ago

@a1exanderpetrov please report whether it solved the issue for you.

a1exanderpetrov commented 3 years ago

@Karlson2k sorry for a long delay, FreeBSD port was released couple days ago and we are going to test v0.9.72 soon. I'll let you know the results.

Karlson2k commented 3 years ago

Bug should be fixed by version 0.9.72