[BUG] DigestAuth with SetBody will be 'http: ContentLength=54 with Body length 0'
icepie opened this issue · comments
Tea commented
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 !
Sergey Vilgelm commented
there is a special function to automatically set the content length, it will also set to 0 if needed:
r.SetContentLength(true)
Tea commented
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.
Jeevanandam M. commented
Merged #730