From fcc9ce81ba75d7638b4f9838ec7e843b6d824aef Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Thu, 8 Mar 2018 22:14:12 +0100 Subject: [PATCH] rest: Really set Content-Length HTTP header --- internal/backend/rest/rest.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/backend/rest/rest.go b/internal/backend/rest/rest.go index 5f8c5d137..f5254f3cc 100644 --- a/internal/backend/rest/rest.go +++ b/internal/backend/rest/rest.go @@ -9,7 +9,6 @@ import ( "net/http" "net/url" "path" - "strconv" "strings" "golang.org/x/net/context/ctxhttp" @@ -119,10 +118,13 @@ func (b *restBackend) Save(ctx context.Context, h restic.Handle, rd restic.Rewin if err != nil { return errors.Wrap(err, "NewRequest") } - req.Header.Set("Content-Length", strconv.FormatInt(rd.Length(), 10)) req.Header.Set("Content-Type", "application/octet-stream") req.Header.Set("Accept", contentTypeV2) + // explicitly set the content length, this prevents chunked encoding and + // let's the server know what's coming. + req.ContentLength = rd.Length() + b.sem.GetToken() resp, err := ctxhttp.Do(ctx, b.client, req) b.sem.ReleaseToken()