http requests.

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
npocmaka_
Posts: 512
Joined: 24 Jun 2013 17:10
Location: Bulgaria
Contact:

http requests.

#1 Post by npocmaka_ » 03 Apr 2015 07:00

Here's a jscript/bat wrapper of WinHttp.WinHttpRequest . Needed this to test some REST apis - can perform POST,GET,... requests, custom header properties can be set and etc. , can be used for files download also.

Of course it's far from perfect ,but is usable.

At the moment my main problem is that I don't know how to save ResponceStream as a file.\
At the moment only ResponseBody can be saved as binary (and the ResponseText as a text ) , but this loads the whole response in the memory and for sure will fail if the Responce is bigger.With the streams (https://msdn.microsoft.com/en-us/library/windows/desktop/aa380038(v=vs.85).aspx) it should be more robust but I still don't know how to use streams (any ideas ? ).


Here's how it can be tested:

Code: Select all

call winhhtpjs.bat "http://requestb.in/113nz4r1"  -method POST   -header hdrs.txt -reportfile reportfile2.txt -saveTo responsefile2 -ua "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"  -body-file some.json


requestb.in can create http request swallowers and convenient to test such tools.

btw. without explicit set of user-agent property automatically some useragent header and it's not accepted by some sites.

Post Reply