Add transfer-encoding to watchdog env-vars if present

The Content-Type header must be ignored when the Transfer
Encoding is set to "chunked" because the length is unknown

Go sets this to -1 and we pass that onto the user:
https://golang.org/src/net/http/transfer.go

The value of Content_Length is currently set to -1 in this
scenario, however it caused some confusion for at least one
user in issue: #1422.

The Http_Transfer_Encoding value was tested by running the
watchdog on Linux with "env" as the fprocess and an extra
header to "curl"

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
This commit is contained in:
Alex Ellis (OpenFaaS Ltd)
2020-01-05 19:05:08 +00:00
committed by Alex Ellis
parent 09b867559d
commit 6a30ce1e36
2 changed files with 9 additions and 4 deletions

View File

@ -237,6 +237,10 @@ func getAdditionalEnvs(config *WatchdogConfig, r *http.Request, method string) [
envs = append(envs, fmt.Sprintf("Http_ContentLength=%d", r.ContentLength))
envs = append(envs, fmt.Sprintf("Http_Content_Length=%d", r.ContentLength))
if len(r.TransferEncoding) > 0 {
envs = append(envs, fmt.Sprintf("Http_Transfer_Encoding=%s", r.TransferEncoding[0]))
}
if config.writeDebug {
log.Println("Query ", r.URL.RawQuery)
}