You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I have found what I think is a bug in HTTP.put() when making a multi-part request.
POST multi-part requests work fine, I will provide an example to illustrate my point.
I am using HTTP.jl to interact with the REST API of Cordra. REST API Documentation. But I think this is a general issue.
POST Request
My code
port = "http://localhost:8000"
open("hw.txt") do io
headers = []
data = [
"content" => JSON.json(Dict("This is a" => "test")),
"File1" => HTTP.Multipart("MyFile", io)
]
body = HTTP.Form(data)
HTTP.post(port, headers, body; require_ssl_verification = false, status_exception = false)
end
Request
Notice how the content-type is automatically defined.
PUT Request
My code
port = "http://localhost:8000"
open("hw.txt") do io
headers = []
data = [
"content" => JSON.json(Dict("This is a" => "test")),
"File1" => HTTP.Multipart("MyFile", io)
]
body = HTTP.Form(data)
HTTP.put(port, headers, body; require_ssl_verification = false, status_exception = false)
end
Request
Notice how content-type is missing.
In this specific case, if I try to pass this request to Cordra, Cordra will be unable to parse the content of the request. My guess is that the issue is the missing content-type (and therefore, the missing "boundary" argument) in the headers.
Manual Fix
This problem can be fixed by manually specifying the content-type header (including manually choosing a boundary):
port = "http://localhost:8000"
open("hw.txt") do io
headers = ["Content-type" => "multipart/form-data; boundary=myboundary"]
data = [
"content" => JSON.json(Dict("This is a" => "test")),
"File1" => HTTP.Multipart("MyFile", io)
]
body = HTTP.Form(data; boundary = "myboundary")
HTTP.put(port, headers, body; require_ssl_verification = false, status_exception = false)
end
Request
This request looks similar to the POST request. Cordra will accept it.
I think HTTP.put() needs some tuning to be able to generate the content-type headers when working with HTTP.Form multi-part requests.
Please let me know if any additional information is needed.
Thank you!
The text was updated successfully, but these errors were encountered:
Julia 1.6.1
HTTP.jl 0.9.13
MbedTLS.jl 1.0.3
Hello, I have found what I think is a bug in HTTP.put() when making a multi-part request.
POST multi-part requests work fine, I will provide an example to illustrate my point.
I am using HTTP.jl to interact with the REST API of Cordra. REST API Documentation. But I think this is a general issue.
POST Request
My code
Request
Notice how the content-type is automatically defined.
PUT Request
My code
Request
Notice how content-type is missing.
In this specific case, if I try to pass this request to Cordra, Cordra will be unable to parse the content of the request. My guess is that the issue is the missing content-type (and therefore, the missing "boundary" argument) in the headers.
Manual Fix
This problem can be fixed by manually specifying the content-type header (including manually choosing a boundary):
Request
This request looks similar to the POST request. Cordra will accept it.
I think HTTP.put() needs some tuning to be able to generate the content-type headers when working with HTTP.Form multi-part requests.
Please let me know if any additional information is needed.
Thank you!
The text was updated successfully, but these errors were encountered: