-
-
Notifications
You must be signed in to change notification settings - Fork 772
Closed
Description
The SetFile() and SetFileReader() functions always set the content-type to application/octet-stream but I need to set it to text/plain. There is no obvious way to set individual content types for multiple parts attached to a request. SetHeader() with content-type affects the main request.
For the web-service I try to use I need a request that looks like the following:
POST http://127.0.0.1:4110/sendmessage
Content-Length = 187
Proxy-Connection = Keep-Alive
Accept = */*
User-Agent = curl/7.47.0
Host = 127.0.0.1:4110
Content-Type = multipart/form-data; boundary=------------------------ff98ce2f2af09ab5
Accept-Encoding = identity
--------------------------ff98ce2f2af09ab5
Content-Disposition: form-data; name="message"
Content-Type: text/plain;charset=utf-8
msg 1
--------------------------ff98ce2f2af09ab5--
The following code comes quite close:
message := "msg 1"
resp, err := resty.R().SetFileReader("message", "message1", bytes.NewReader([]byte(message))).Post("http://localhost:4110/sendmessage")
Producing the following POST request:
POST http://localhost:4110/restful/meshms/3B52DDA010E1ECF8BCBDFECF8B231A49759CEA71A452525C2EAAE96D7B5EEF5D/761353EE496B911E72BDFB390E124C8C03057BCB20E41EC68802502FBCF8330A/sendmessage
Content-Length = 248
Accept-Encoding = gzip
User-Agent = go-resty v1.0 - https://github.com/go-resty/resty
Host = localhost:4110
Content-Type = multipart/form-data; boundary=1086b448cee8019bec34a9b227a7f2073af301c3aba18ce8351c6ba1a76b
--1086b448cee8019bec34a9b227a7f2073af301c3aba18ce8351c6ba1a76b
Content-Disposition: form-data; name="message"; filename="message1"
Content-Type: application/octet-stream
msg 1
--1086b448cee8019bec34a9b227a7f2073af301c3aba18ce8351c6ba1a76b--
Am I overlooking something or is this functionality simply not implemented?
The rest of the API is very straight forward and easy to use, great work!