1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2024-12-25 17:27:25 +00:00

Merge pull request #1661 from restic/fix-rest-content-length

rest: Really set Content-Length HTTP header
This commit is contained in:
Alexander Neumann 2018-03-10 20:34:30 +01:00
commit e77d8c64a7

View file

@ -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()