5
1
In bash, this code posts String to post to http://www.example.com/target:
curl -d "String to post" "http://www.example.com/target"
NOTE: You should use http://www.example.com/target as the URL to POST to, without any change.
I think all other languages that I have knowledge in need a lot more code than this. I'm not blaming other languages. Let's see the interesting answers that reduce the effort.
Your task is to write the shortest code possible to send a POST request to a sample server, http://www.example.com/target, and the request data should be the string String to post.
It's not clear that the title and the body are asking for the same thing, let alone what you consider to be sufficient and necessary to qualify as a solution. – Peter Taylor – 2014-02-22T12:42:03.787
Dont you understand the question? this is the best i can explain. the title and body are clear for me – Viswanath Lekshmanan – 2014-02-22T12:45:40.700
1@Peter Taylor I have edited the question to try to make it more clear. – user12205 – 2014-02-22T12:52:29.913
Another one of the same size:
– manatwork – 2014-02-22T14:08:17.683POST http://www.example.com/target<<<'String to send'. (POSTis either a stand-alone script or symlink tolwp-request, a command line tool delivered with the LWPperlmodule.)@manatwork why don't you post it as an answer? – user12205 – 2014-02-22T14:17:05.373
@ace, I felt it's not valuable enough for an answer. – manatwork – 2014-02-22T14:47:54.087
Is it sufficient that the request be permitted by the HTTP spec (and if so, which?), or is there a set of additional minimal headers to make it useful to the server? – Peter Taylor – 2014-02-22T15:04:15.460
I've reduced my answer by 3 bytes. Can you check it? – Ismael Miguel – 2014-02-23T05:17:03.703
Yeah, updated... :) – Viswanath Lekshmanan – 2014-02-23T05:26:21.527
I've reduced my answer by 9 characters! – Toothbrush – 2014-02-24T10:36:10.387
@toothbrush Yeah updaetd that :) – Viswanath Lekshmanan – 2014-02-24T13:39:57.217
Some of the answers are posting to
example.com, and some towww.example.com. You may wish to clarify that requirement, one way or the other. – TRiG – 2014-02-25T03:31:10.833@ViswanathL Yes, I suggest you clarify. – Toothbrush – 2014-02-25T11:04:53.963
Yeah i updated the url, Please change and update th answers accordingly – Viswanath Lekshmanan – 2014-02-25T11:30:25.260
@ViswanathL OK. I've updated my solution, too. Do we really need the
http:part, too? – Toothbrush – 2014-02-25T18:36:45.427@toothbrush. The
http:part is the protocol. I'd presume that if your language infers the protocol, that's fine. But there is a real difference betweenexample.comandwww.example.com: they're two different names. – TRiG – 2014-02-26T14:18:14.950