mirror of https://github.com/gofiber/fiber.git
Add Content-Length to app.Test() (#387)
* Add Content-Length if not provided with Bodypull/406/head
parent
884cd40245
commit
1f52b51dca
4
app.go
4
app.go
|
@ -445,6 +445,10 @@ func (app *App) Test(request *http.Request, msTimeout ...int) (*http.Response, e
|
||||||
if len(msTimeout) > 0 {
|
if len(msTimeout) > 0 {
|
||||||
timeout = msTimeout[0]
|
timeout = msTimeout[0]
|
||||||
}
|
}
|
||||||
|
// Add Content-Length if not provided with body
|
||||||
|
if request.Body != http.NoBody && request.Header.Get("Content-Length") == "" {
|
||||||
|
request.Header.Add("Content-Length", strconv.FormatInt(request.ContentLength, 10))
|
||||||
|
}
|
||||||
// Dump raw http request
|
// Dump raw http request
|
||||||
dump, err := httputil.DumpRequest(request, true)
|
dump, err := httputil.DumpRequest(request, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue