mirror of
https://github.com/restic/restic.git
synced 2024-12-23 16:26:11 +00:00
rest: Really set Content-Length HTTP header
This commit is contained in:
parent
ab5ef600a2
commit
fcc9ce81ba
1 changed files with 4 additions and 2 deletions
|
@ -9,7 +9,6 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"path"
|
"path"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"golang.org/x/net/context/ctxhttp"
|
"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 {
|
if err != nil {
|
||||||
return errors.Wrap(err, "NewRequest")
|
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("Content-Type", "application/octet-stream")
|
||||||
req.Header.Set("Accept", contentTypeV2)
|
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()
|
b.sem.GetToken()
|
||||||
resp, err := ctxhttp.Do(ctx, b.client, req)
|
resp, err := ctxhttp.Do(ctx, b.client, req)
|
||||||
b.sem.ReleaseToken()
|
b.sem.ReleaseToken()
|
||||||
|
|
Loading…
Reference in a new issue