http.PostForm with custom headers

1,724 views
Skip to first unread message

Dobrosław Żybort

unread,
Jan 14, 2013, 10:48:33 AM1/14/13
to golan...@googlegroups.com
Hello,

is there a way to use http.PostForm with custom headers?

I would like to add to it "Accept": "application/json" header. Nothing more.

Best regards

minux

unread,
Jan 14, 2013, 11:29:03 AM1/14/13
to Dobrosław Żybort, golan...@googlegroups.com
On Mon, Jan 14, 2013 at 11:48 PM, Dobrosław Żybort <matr...@gmail.com> wrote:
is there a way to use http.PostForm with custom headers?

I would like to add to it "Accept": "application/json" header. Nothing more.
you will need to construct a http.Request (it is easier than what you might expect, 
refer to http://golang.org/src/pkg/net/http/client.go#L299 for an example) and then

Dobrosław Żybort

unread,
Jan 14, 2013, 1:55:40 PM1/14/13
to golan...@googlegroups.com, Dobrosław Żybort
Thank you for that, but I thought there will be something shorter.

I miss Python Requests simplicity...

Best regards

minux

unread,
Jan 14, 2013, 2:05:39 PM1/14/13
to Dobrosław Żybort, golan...@googlegroups.com
On Tue, Jan 15, 2013 at 2:55 AM, Dobrosław Żybort <matr...@gmail.com> wrote:
Thank you for that, but I thought there will be something shorter.
i think with complete error handling, one can write that in less than 10 lines.
Reply all
Reply to author
Forward
0 new messages