aboutsummaryrefslogtreecommitdiff
path: root/src/net/http/transfer.go
diff options
context:
space:
mode:
authorSegflow <asselmeher@gmail.com>2020-08-24 13:42:45 +0000
committerEmmanuel Odeke <emm.odeke@gmail.com>2020-08-24 16:53:02 +0000
commitfb5c3eabd16bbeea28ee8a11d29a31cf5ed124dd (patch)
tree1d807a3fddceb63edb1e836e469d06692cfd6294 /src/net/http/transfer.go
parent494ec85d9fd6deea388c454dfd836d9f845f7153 (diff)
downloadgo-fb5c3eabd16bbeea28ee8a11d29a31cf5ed124dd.tar.xz
net/http: set Content-Length:0 for empty PATCH requests as with POST, PATCH
Sets Content-Length:0 for nil bodies in PATCH requests, as we already do for POST and PUT requests. RFC 2616 mentions that unless a method’s Content-Length is forbidden it can send one. In the wild, we’ve found that Microsoft Azure’s DataLake Gen2 storage API https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update deliberately rejects PATCH requests without a Content-Length, yet there is no workaround for setting that header when trying to flush the content of a file which was uploaded in a previous request. Fixes #40978 Change-Id: Ib0a623b907d827a1c5ee431dca3c41024fa291c5 GitHub-Last-Rev: 12a3903f2bc22bcc4f5f8e2abcc3922b612b8871 GitHub-Pull-Request: golang/go#40991 Reviewed-on: https://go-review.googlesource.com/c/go/+/250039 Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Diffstat (limited to 'src/net/http/transfer.go')
-rw-r--r--src/net/http/transfer.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/net/http/transfer.go b/src/net/http/transfer.go
index 50d434b1fb..ab009177bc 100644
--- a/src/net/http/transfer.go
+++ b/src/net/http/transfer.go
@@ -258,7 +258,7 @@ func (t *transferWriter) shouldSendContentLength() bool {
return false
}
// Many servers expect a Content-Length for these methods
- if t.Method == "POST" || t.Method == "PUT" {
+ if t.Method == "POST" || t.Method == "PUT" || t.Method == "PATCH" {
return true
}
if t.ContentLength == 0 && isIdentity(t.TransferEncoding) {