Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Case issue in response protocol header #119

Open
jwwsjlm opened this issue Jun 26, 2024 · 7 comments
Open

[Bug]: Case issue in response protocol header #119

jwwsjlm opened this issue Jun 26, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@jwwsjlm
Copy link

jwwsjlm commented Jun 26, 2024

TLS client version

v1.3.12

System information

windows10,64

Issue description

微信截图_20240627004657
微信截图_20240627004733
Case issue in response protocol header

As shown in the figure, I used net/http to create an httpServe, and the response protocol header was set to x-custom-header. Note that it is lowercase. When tested with other tools, the responses were all lowercase. However, when using tls_client.NewHttpClient-client.Do(req) to send a request, taking resp.Header, it will become uppercase. I know this is a standard. But is there any way to get the original format?

Steps to reproduce / Code Sample

`func main() {

client, err := tls_client.NewHttpClient(tls_client.NewNoopLogger())

req, err := fhttp.NewRequest(fhttp.MethodGet, "http://127.0.0.1:55881/ping", nil)

resp, err := client.Do(req)
if err != nil {
	log.Println(err)
	return
}

defer resp.Body.Close()

for key, values := range resp.Header {
	fmt.Printf("Key: %s, Values: %v\n", key, values)
}
log.Println(fmt.Sprintf("status code: %d", resp.StatusCode))

readBytes, err := io.ReadAll(resp.Body)
if err != nil {
	log.Println(err)
	return
}

log.Println(string(readBytes))

}`

@jwwsjlm jwwsjlm added the bug Something isn't working label Jun 26, 2024
@jwwsjlm
Copy link
Author

jwwsjlm commented Jun 26, 2024

QQ图片20240627005557
Use other tools. httpserver returns lowercase.

@combo23
Copy link

combo23 commented Jun 26, 2024

it's possible when you force HTTP1, this can be set in client options

@jwwsjlm
Copy link
Author

jwwsjlm commented Jun 26, 2024

it's possible when you force HTTP1, this can be set in client options

Is there any way to get the original response protocol header?

@combo23
Copy link

combo23 commented Jun 26, 2024

what do you mean

@jwwsjlm
Copy link
Author

jwwsjlm commented Jun 26, 2024

what do you mean

https://github.com/luminati-io/luminati-proxy

Hmm. I mainly want to use it to develop a middleware or something like that. Other languages ​​can use golang to send requests through a proxy. But there is a problem that the net\http package will correct the case of the protocol header. For other clients, they need to be handled separately, which is very troublesome. Something like this

@jwwsjlm
Copy link
Author

jwwsjlm commented Jun 26, 2024

what do you mean

However, when the middleware forwards data, the server returns lowercase letters, and the middleware sends it to the client in uppercase letters, causing the client to not recognize it.

So I hope to get the raw bytes or unprocessed response headers

@jwwsjlm
Copy link
Author

jwwsjlm commented Jun 26, 2024

what do you mean

This is indeed not in compliance with the specification. However, as a middleware, it can perfectly copy what the client requests and what the server responds to. In the middle, tls-client is used to perform tls fingerprint randomization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants