Ответ 1
Я воспроизвел его с помощью go
SDK, чтобы подтвердить, что именно так себя ведет API, а не что-то конкретное от nodejs
.
Как я могу видеть из моих экспериментов, это нормальное поведение сейчас, оно ничего не вернет из запроса PUT
.
OBS: Я замаскировал некоторые чувствительные ценности!
Код:
package main
import (
"crypto/tls"
"fmt"
"log"
"net/http"
"net/url"
"strings"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3"
)
func main() {
sess, err := session.NewSession(&aws.Config{
Region: aws.String("eu-west-1")},
)
svc := s3.New(sess)
req1, _ := svc.PutObjectRequest(&s3.PutObjectInput{
Bucket: aws.String("bucketversioningenabled"),
Key: aws.String("myKey"),
Body: strings.NewReader("EXPECTED CONTENTS"),
})
presignURL, err := req1.Presign(time.Minute * 1)
if err != nil {
log.Println("Error on presign", err)
return
}
fmt.Println("Presign: ", presignURL, err)
fmt.Println("")
req2, err := http.NewRequest("PUT", presignURL, strings.NewReader("EXPECTED CONTENTS"))
if err != nil {
log.Println("error creating request", err)
return
}
fmt.Println("NewRequest: ", req2, err)
fmt.Println("")
proxyURL, err := url.Parse("http://myfiddler.proxy.com:8888")
if err != nil {
log.Println("Error on proxy parse", err)
return
}
tr := &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
Proxy: http.ProxyURL(proxyURL),
}
client := &http.Client{
Transport: tr,
Timeout: time.Duration(5 * time.Second),
}
resp, err := client.Do(req2)
if err != nil {
log.Println("error on request put", err)
return
}
fmt.Println("Do: ", resp, err)
}
Выход выполнения:
Посмотрите Content-Length:[0]
на последней строке.
$ ./s3put
Presign: https://bucketversioningenabled.s3.eu-west-1.amazonaws.com/myKey?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=XXXXX%2F20180531%2Feu-west-1%2Fs3%2Faws4_request&X-Amz-Date=20180531T112707Z&X-Amz-Expires=60&X-Amz-Security-Token=XXXX&X-Amz-SignedHeaders=content-length%3Bhost&X-Amz-Signature=XXXX <nil>
NewRequest: &{PUT https://bucketversioningenabled.s3.eu-west-1.amazonaws.com/myKey?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=XXXX%2F20180531%2Feu-west-1%2Fs3%2Faws4_request&X-Amz-Date=20180531T112707Z&X-Amz-Expires=60&X-Amz-Security-Token=XXXX&X-Amz-SignedHeaders=content-length%3Bhost&X-Amz-Signature=XXXX HTTP/1.1 1 1 map[] {0xc42010d020} 0x5f2040 17 [] false bucketversioningenabled.s3.eu-west-1.amazonaws.com map[] map[] <nil> map[] <nil> <nil> <nil> <nil>} <nil>
Do: &{200 OK 200 HTTP/1.1 1 1 map[X-Amz-Version-Id:[3I4txVUgi4ObULr8EVadA4U3cfvdVwQM] Etag:["952973475e3f4d992fe48578086c1e17"] Content-Length:[0] Server:[AmazonS3] X-Amz-Id-2:[yGUZtjttGKwv0uJxQcG7bIkGRqxhPxKeW71jWIGkmwt73oZY/+r3HWyr2uK07nR8xTDQyzbM3Hw=] X-Amz-Request-Id:[509F1785D0383ADA] Date:[Thu, 31 May 2018 11:27:09 GMT]] 0xc42000c0e0 0 [] false false map[] 0xc42019c400 0xc420199290} <nil>
Ниже вы можете увидеть запрос и ответ от Fiddler
Запрос:
PUT https://bucketversioningenabled.s3.eu-west-1.amazonaws.com/myKey?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=XXXX%2F20180531%2Feu-west-1%2Fs3%2Faws4_request&X-Amz-Date=20180531T112707Z&X-Amz-Expires=60&X-Amz-Security-Token=XXXX&X-Amz-SignedHeaders=content-length%3Bhost&X-Amz-Signature=XXXX HTTP/1.1
Host: bucketversioningenabled.s3.eu-west-1.amazonaws.com
User-Agent: Go-http-client/1.1
Content-Length: 17
Accept-Encoding: gzip
EXPECTED CONTENTS
Ответ (посмотрите Content-Length):
HTTP/1.1 200 OK
x-amz-id-2: yGUZtjttGKwv0uJxQcG7bIkGRqxhPxKeW71jWIGkmwt73oZY/+r3HWyr2uK07nR8xTDQyzbM3Hw=
x-amz-request-id: 509F1785D0383ADA
Date: Thu, 31 May 2018 11:27:09 GMT
x-amz-version-id: 3I4txVUgi4ObULr8EVadA4U3cfvdVwQM
ETag: "952973475e3f4d992fe48578086c1e17"
Content-Length: 0
Server: AmazonS3