Bug 10911 – std.net.curl.HTTP: should allow user code to indicate content type of POST data

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-08-27T11:06:00Z
Last change time
2014-07-16T05:29:42Z
Keywords
pull
Assigned to
nobody
Creator
hsteoh

Comments

Comment #0 by hsteoh — 2013-08-27T11:06:36Z
Currently, std.net.curl.HTTP.postData hardcodes the content type to application/octet-stream for ubyte[] and text/plain for [unqual,const,immutable](char)[]. The method that lets you specify content type, _postData, is a private function. The workaround is unreasonably complicated: since headers are a singly-linked list, you can't just use addHeader to replace the default Content-Type header; you have to iterate over them and add them back, substituting Content-Type with the desired value. Either that, or use the low-level Curl object directly, which defeats the purpose of having a high-level API.
Comment #1 by sean — 2013-10-21T10:11:21Z
This one has caused me a lot of trouble as well. I'll sort out a pull request.
Comment #2 by hsteoh — 2013-10-21T10:17:52Z
I've already done a pull request, but it's being held up because we're not sure what's the best API for this. See: https://github.com/D-Programming-Language/phobos/pull/1527
Comment #3 by hsteoh — 2014-07-16T05:29:42Z
PR has been merged. Yay!