opened 10:56AM - 02 Mar 22 UTC
bug
**Describe the bug**
http.request() fails for POST/PUT requests for payloads ov…er 16K if the server doesn't support chunked transfer-encoding, which is the method that the Defold client uses for transfers of that size (see https://github.com/defold/defold/issues/4669).
This includes uploads to the Playfab file entity system, which uses Microsoft Azure Blob storage.
**To Reproduce**
Reproducing this is difficult in isolation as it requires a server that behaves in a particular way. I presume that it's possible to modify the Playfab example as described here, but I haven't run this as I don't want to leave data on the Playfab server in a bad state.
1. After login, initiate a file upload:
```
local req = {
Entity = <this is EntityToken.Entity from the auth response>,
FileNames = {"file.txt"}
}
local req = PlayFabDataApi_Defold.InitiateFileUploads(req, on_initiate_upload_success, on_initiate_upload_err)
```
2. Do the HTTP PUT request in the success callback where payload exists and is > 16K:
```
local function on_initiate_upload_success(result)
local len = string.len(payload)
local requestHeaders = {
["x-ms-original-content-length"] = len
}
http.request(result.UploadDetails[1].UploadUrl, "PUT", handle_response, requestHeaders, payload)
end
```
where handle_response is of the form
```
local function handle_response(self, id, response)
pprint(response)
local req = {
Entity = <this is EntityToken.Entity from the auth response>,
FileNames = {"file.txt"}
}
PlayFabDataApi_Defold.FinalizeFileUploads(req, nil, nil)
end
```
**Expected behavior**
The request succeeds / the content is transferred.
**Defold version:**
- Version 1.2.189
**Platforms:**
- Platforms: Windows
- OS: Windows 10
**Logs:**
```
{
headers = {
["content-length"] = "239",
["content-type"] = "application/xml",
date = "Wed, 02 Mar 2022 10:35:33 GMT",
server = "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
["x-ms-error-code"] = "NotImplemented",
["x-ms-request-id"] = "4c28eb9e-001e-0073-3921-2e6c87000000",
["x-ms-version"] = "2020-04-08"
},
response = '<?xml version="1.0" encoding="utf-8"?><Error><Code>NotImplemented</Code><Message>Value provided for Transfer-Encoding is not implemented.\nRequestId:4c28eb9e-001e-0073-3921-2e6c87000000\nTime:2022-03-02T10:35:34.2090776Z</Message></Error>',
status = 501
}
```
**Additional context:**
I don't know enough about HTTP to know if transfer-encoding is something that is normally negotiated, and/or if clients are required to support methods other than chunked.