v icon indicating copy to clipboard operation
v copied to clipboard

Failure to Handle Transfer-Encoding: chunked Correctly Over HTTPS

Open senluowx opened this issue 3 months ago • 1 comments

Describe the bug

The client encounters an error when processing HTTP responses with Transfer-Encoding: chunked over HTTPS. The same request/response works correctly under HTTP, but fails when using HTTPS.

Reproduction Steps

client code (v)

module main

import net.http

fn main() {
	url := 'https://127.0.0.1:8080'
	mut req := http.new_request(.post, url, '')
	resp := req.do() or { panic(err) }
	println('resp ${resp}')
}

server code (go)

package main

import (
	"fmt"
	"net/http"
	"time"
)

func main() {
	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		w.Header().Set("Content-Type", "text/plain")

		flusher, ok := w.(http.Flusher)
		if !ok {
			http.Error(w, "Streaming not supported", http.StatusInternalServerError)
			return
		}

		flusher.Flush()

		time.Sleep(1 * time.Second)
		fmt.Fprint(w, `test data`)
		flusher.Flush()

		time.Sleep(1 * time.Second)
		fmt.Fprint(w, `test data`)
		flusher.Flush()
	})
	http.ListenAndServeTLS(":8080", "server.crt", "server.key", nil)
}

Expected Behavior

print

resp http.Response{
    body: 'test datatest data'
    header: Content-Type: text/plain
Date: Sun, 05 Oct 2025 11:45:18 GMT
Connection: close
Transfer-Encoding: chunked

    status_code: 200
    status_msg: 'OK'
    http_version: '1.1'
}

Current Behavior

current body is empty

resp http.Response{
    body: ''
    header: Content-Type: text/plain
Date: Sun, 05 Oct 2025 11:45:18 GMT
Connection: close
Transfer-Encoding: chunked

    status_code: 200
    status_msg: 'OK'
    http_version: '1.1'
}

Possible Solution

No response

Additional Information/Context

When using the DeepSeek API, I discovered abnormal behavior with the response body. Currently, similar issues may be encountered when using AI-related APIs.

V version

V 0.4.12 f6e5118

Environment details (OS name and version, etc.)

V full version V 0.4.12 7f6db12a461a5388b1b9765acec74138ce2817bc.f6e5118
OS linux, Deepin 25
Processor 16 cpus, 64bit, little endian, AMD Ryzen 7 7735HS with Radeon Graphics
Memory 35.47GB/61.53GB
V executable /home/x/v/v
V last modified time 2025-10-05 10:15:04
V home dir OK, value: /home/x/v
VMODULES OK, value: /home/x/.vmodules
VTMP OK, value: /tmp/v_1000
Current working dir OK, value: /home/x/Projects/aireview
Git version git version 2.50.1
V git status f6e51188
.git/config present true
cc version cc (Deepin 12.3.0-17deepin15) 12.3.0
gcc version gcc (Deepin 12.3.0-17deepin15) 12.3.0
clang version N/A
tcc version tcc version 0.9.28rc 2025-02-13 HEAD@f8bd136d (x86_64 Linux)
tcc git status thirdparty-linux-amd64 696c1d84
emcc version N/A
glibc version ldd (Debian GLIBC 2.38-6deepin16) 2.38

[!NOTE] You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote. Other reactions and those to comments will not be taken into account.

senluowx avatar Oct 05 '25 12:10 senluowx

Connected to Huly®: V_0.6-26135

huly-for-github[bot] avatar Oct 05 '25 12:10 huly-for-github[bot]