Dropzone.js Почему заголовок запроса включает «Content-Length» при чанкинге: true - PullRequest
0 голосов
/ 27 марта 2019

Мне нужен запрос чанка от клиента к серверу, но в заголовок запроса не входит «Transfer-Encoding: chunked».

Включите запрос чанка, как показано ниже:

dropzoneOptions: {
        url: process.env.BASE_URL + '/upload',
        thumbnailWidth: 200,
        addRemoveLinks: true,
        uploadMultiple: false,
        chunking: true,
        chunkSize: 10000,
        forceChunking: false,
        maxFiles: 1000,
        withCredentials: true,

В API, как показано ниже:

fmt.Printf("Header: %v\n", c.Request.Header)
-> Header: map[Accept:[application/json] Accept-Encoding:[gzip, deflate, br] Accept-Language:[ja-JP,ja;q=0.9,en-US;q=0.8,en;q=0.7] Cache-Control:[no-cache] Content-Length:[11071] Content-Type:[multipart/form-data; boundary=----WebKitFormBoundaryR3nyT2hp5fP3wETc] Cookie:[_ga=GA1.1.739076998.1535606573; _gid=GA1.1.2036091497.1553667440; _gat=1] Origin:[http://localhost:8080] Referer:[http://localhost:8080/] User-Agent:[Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36] X-Forwarded-For:[::1] X-Requested-With:[XMLHttpRequest]]

fmt.Printf("TE: %v\n", c.Request.TransferEncoding)
-> TE: []

через curl:

$ curl -X POST -T "hoge.txt" -H 'Content-type: text/plain' --header "Transfer-Encoding: chunked" --header "Connection: Keep-Alive" http://localhost:3000/upload

server
-> TE: [chunked]

Я ожидал "Transfer-Encoding: chunked" в заголовке запроса и не нужно "Content-Length".

Что означает "кусок" в dropzone.js?

...