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] DigestAuth with SetBody will be 'http: ContentLength=54 with Body length 0' #729

Closed
icepie opened this issue Oct 11, 2023 · 3 comments
Assignees
Labels
Milestone

Comments

@icepie
Copy link
Contributor

icepie commented Oct 11, 2023

Code

	req := c.HttpClient.R().
		SetDigestAuth("admin", "123456").
		SetHeader("Content-Type", "application/xml").
		SetBody(reqBody)

	resp, err := req.Put("/ISAPI/AccessControl/RemoteControL/door/1")

Out

2023/10/11 17:13:52  Put "http://192.168.0.51/ISAPI/AccessControl/RemoteControL/door/1": net/http: HTTP/1.x transport connection broken: http: ContentLength=54 with Body length 0

but GET method will be fine !

@SVilgelm
Copy link
Contributor

there is a special function to automatically set the content length, it will also set to 0 if needed:

r.SetContentLength(true)

@icepie
Copy link
Contributor Author

icepie commented Oct 12, 2023

there is a special function to automatically set the content length, it will also set to 0 if needed:

r.SetContentLength(true)

Code

	req := c.HttpClient.R().SetDigestAuth(c.username, c.password).
		SetHeader("Content-Type", "application/xml").
		SetContentLength(true).
		SetBody(reqBody)

	resp, err := req.
		Put("/ISAPI/AccessControl/RemoteControL/door/1")

Out

 Put "http://192.168.0.51/ISAPI/AccessControl/RemoteControL/door/1": net/http: HTTP/1.x transport connection broken: http: ContentLength=54 with Body length 0

Same problem.

@jeevatkm
Copy link
Member

Merged #730

@jeevatkm jeevatkm added the bug label Oct 14, 2023
@jeevatkm jeevatkm added this to the v2.10.0 milestone Oct 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants