go-resty / resty

Simple HTTP and REST client library for Go
MIT License
9.89k stars 696 forks source link

Fix digest auth http: ContentLength=xxx with Body length 0 #730

Closed icepie closed 10 months ago

icepie commented 11 months ago

729

icepie commented 10 months ago

@icepie Can you please add unit test cases?

Ok! I have added d3026f9b3e574db015e63819fd0f72c8bf4b528c

old code

Running tool: /home/icepie/.go/bin/go test -timeout 30s -run ^TestRequestDigestAuthWithBody$ github.com/go-resty/resty/v2

--- FAIL: TestRequestDigestAuthWithBody (0.00s)
    /home/icepie/Projects/resty-fix/resty_test.go:690: Method: POST
    /home/icepie/Projects/resty-fix/resty_test.go:691: Path: /dir/index.html
    /home/icepie/Projects/resty-fix/resty_test.go:690: Method: POST
    /home/icepie/Projects/resty-fix/resty_test.go:691: Path: /dir/index.html
    /home/icepie/Projects/resty-fix/resty_test.go:828: Error occurred [Post "http://127.0.0.1:40125/dir/index.html": net/http: HTTP/1.x transport connection broken: http: ContentLength=41 with Body length 0]
    /home/icepie/Projects/resty-fix/resty_test.go:842: Expected [200], got [0]
    /home/icepie/Projects/resty-fix/request_test.go:740: Result Success: &{"" ""}
    /home/icepie/Projects/resty-fix/resty_test.go:877: Response Status: 
    /home/icepie/Projects/resty-fix/resty_test.go:878: Response Time: 353.067µs
    /home/icepie/Projects/resty-fix/resty_test.go:879: Response Headers: map[]
    /home/icepie/Projects/resty-fix/resty_test.go:880: Response Cookies: []
    /home/icepie/Projects/resty-fix/resty_test.go:881: Response Body: 
FAIL
FAIL    github.com/go-resty/resty/v2    0.002s
FAIL

new code

Running tool: /home/icepie/.go/bin/go test -timeout 30s -run ^TestRequestDigestAuthWithBody$ github.com/go-resty/resty/v2

ok      github.com/go-resty/resty/v2    (cached)
codecov[bot] commented 10 months ago

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (6242e6f) 96.62% compared to head (d3026f9) 96.51%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## v2 #730 +/- ## ========================================== - Coverage 96.62% 96.51% -0.11% ========================================== Files 12 12 Lines 1630 1637 +7 ========================================== + Hits 1575 1580 +5 - Misses 35 36 +1 - Partials 20 21 +1 ``` | [Files](https://app.codecov.io/gh/go-resty/resty/pull/730?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=go-resty) | Coverage Δ | | |---|---|---| | [digest.go](https://app.codecov.io/gh/go-resty/resty/pull/730?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=go-resty#diff-ZGlnZXN0Lmdv) | `94.48% <71.42%> (-1.17%)` | :arrow_down: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.