digitalmars.D.learn - Specifying content-type for a POST request using std.net.curl
- Joseph Rushton Wakeling (16/16) Aug 09 2016 Hello all,
- ketmar (3/3) Aug 09 2016 http://dpldocs.info/experimental-docs/std.net.curl.HTTP.setPostData.html
- Joseph Rushton Wakeling (8/11) Aug 09 2016 Yea, mea culpa. I had actually glanced at that but was asking on
- Seb (5/21) Aug 09 2016 There is also
- Joseph Rushton Wakeling (3/6) Aug 09 2016 Interesting, I'd not come across that before. Thanks -- I'll
Hello all, I'm currently writing a little client app whose job is to make a POST request to a vibe.d webserver and output the response. However, vibe.d is picky about the content-type of the request body, and so far as I can see there is no way to specify this via the `std.net.curl.post` API. So far as I can see from the vibe.d log output, `post` is using the `text/plain` content type, to which vibe.d objects (rightly) because the content is not UTF8. It's a little bizarre that `text/plain` is chosen, because the input data is `void[]` or `ubyte[]` data. Can anyone advise (if it's possible at all) how to specify the content type for the post request body using std.net.curl (or an alternative)? Thanks & best wishes, -- Joe
Aug 09 2016
http://dpldocs.info/experimental-docs/std.net.curl.HTTP.setPostData.html https://dlang.org/phobos/std_net_curl.html#.HTTP.setPostData reading documentation rox!
Aug 09 2016
On Tuesday, 9 August 2016 at 14:21:09 UTC, ketmar wrote:http://dpldocs.info/experimental-docs/std.net.curl.HTTP.setPostData.html https://dlang.org/phobos/std_net_curl.html#.HTTP.setPostData reading documentation rox!Yea, mea culpa. I had actually glanced at that but was asking on the assumption that I might have misunderstood something about the simpler functions -- it was a bit odd that (for example) a `post` call whose input data was `void[]` or `ubyte[]` would still be treated as text content-type. In any case, I now have a working solution using HTTP.setPostData, so all's well ;-) Thanks!
Aug 09 2016
On Tuesday, 9 August 2016 at 14:07:48 UTC, Joseph Rushton Wakeling wrote:Hello all, I'm currently writing a little client app whose job is to make a POST request to a vibe.d webserver and output the response. However, vibe.d is picky about the content-type of the request body, and so far as I can see there is no way to specify this via the `std.net.curl.post` API. So far as I can see from the vibe.d log output, `post` is using the `text/plain` content type, to which vibe.d objects (rightly) because the content is not UTF8. It's a little bizarre that `text/plain` is chosen, because the input data is `void[]` or `ubyte[]` data. Can anyone advise (if it's possible at all) how to specify the content type for the post request body using std.net.curl (or an alternative)? Thanks & best wishes, -- JoeThere is also https://github.com/ikod/dlang-requests Which I find in general more intuitive to use ;-)
Aug 09 2016
On Tuesday, 9 August 2016 at 14:30:21 UTC, Seb wrote:There is also https://github.com/ikod/dlang-requests Which I find in general more intuitive to use ;-)Interesting, I'd not come across that before. Thanks -- I'll give it a glance some time ...
Aug 09 2016