@@ -35,6 +35,15 @@ func (azureBlob *AzureBlob) putBlobAbstract(writer http.ResponseWriter, request
35
35
func (azureBlob * AzureBlob ) putBlob (writer http.ResponseWriter , request * http.Request ) {
36
36
key := request .PathValue ("key" )
37
37
38
+ // Parse the Content-Length header
39
+ contentLength , err := strconv .ParseUint (request .Header .Get ("Content-Length" ), 10 , 64 )
40
+ if err != nil {
41
+ fail (writer , request , http .StatusBadRequest , "failed to parse the Content-Length header value" ,
42
+ "key" , key , "err" , err , "value" , contentLength )
43
+
44
+ return
45
+ }
46
+
38
47
// Generate cache upload URL
39
48
generateCacheUploadURLResponse , err := client .CirrusClient .GenerateCacheUploadURL (
40
49
request .Context (),
@@ -60,6 +69,9 @@ func (azureBlob *AzureBlob) putBlob(writer http.ResponseWriter, request *http.Re
60
69
return
61
70
}
62
71
72
+ // Content-Length is required to avoid HTTP 411
73
+ req .ContentLength = int64 (contentLength )
74
+
63
75
resp , err := http .DefaultClient .Do (req )
64
76
if err != nil {
65
77
fail (writer , request , http .StatusInternalServerError , "failed to perform request to proxy " +
@@ -153,6 +165,9 @@ func (azureBlob *AzureBlob) putBlock(writer http.ResponseWriter, request *http.R
153
165
return
154
166
}
155
167
168
+ // Content-Length is pre-signed, so we need to provide it
169
+ req .ContentLength = int64 (contentLength )
170
+
156
171
resp , err := http .DefaultClient .Do (req )
157
172
if err != nil {
158
173
fail (writer , request , http .StatusInternalServerError , "failed to perform request to proxy " +
0 commit comments