Jump to Downloads | Online Documentation
- HTTP/1.1 support including chunked encoding and persistent connections (aka Keep-Alive's).
- SSL support including SSL via proxy servers.
- Compression support, including the ability to compress the request body. (both gzip & deflate)
- Proxy server support including authentication (Basic Authentication only).
- Server authentication (Basic Authentication only).
- Session cookies.
Latest Version : PocketHTTP v1.3.4, released Saturday, September 15, 2012
Easy to use
' do a HTTP GET from http://www.pocketsoap.com set req = CreateObject("pocket.HTTP") set res = req.GetResponse("http://www.pocketsoap.com/", "") ' show the response as a string wscript.echo res.String ' what was the status code returned ? wscript.echo res.StatusCode ' what was the Content-Type header set to ? wscript.echo res.Headers.Find("Content-Type").Value ' generates this request GET / HTTP/1.1 Host: www.pocketsoap.com Accept-Encoding: gzip, deflate User-Agent: PocketHTTP/1.2.5
' do a HTTP PUT to www.pocketsoap.com/store/1 set req = CreateObject("pocket.HTTP") req.method = "PUT" req.Headers.Create "Content-Type", "text/xml" set res = req.GetResponse("http://www.pocketsoap.com/store/1", "<root>Hello World!</root>" ) wscript.echo res.statusCode ' generates this HTTP request PUT /store/1 HTTP/1.1 Host: www.pocketsoap.com Accept-Encoding: gzip, deflate Content-Type: text/xml User-Agent: PocketHTTP/1.2.6 Content-Length: 25 <root>Hello World!</root>
' get a GIF and write it direct to disk set req = CreateObject("Pocket.HTTP") set res = req.getResponse("http://www.pocketsoap.com/logo.gif", "") res.SaveAs "c:\logo.gif"
Use the Method property on the request object to change the HTTP Verb used in the request, this defaults to GET, e.g. to change it to POST do
set req = CreateObject("pocket.HTTP") set res = req.GetResponse("http://www.pocketsoap.com/","")
Use the Headers collection property to manipulate the HTTP headers sent in the request, for example to set a content-type header for the above POST, you would use the create method to create a new header, e.g.
req.method = "POST"
To alter the existing User-Agent header, you use the Find method to find the existing header and modify its value, e.g.
req.headers.create "Content-Type", "text/xml"
For HTTP requests that include a body (such as POST or PUT), the 2nd parameter to the GetResponse method is used to pass this data. It can be either a string (which is automatically transcoded to utf-8), an array of bytes, or a stream (IStream or IResetableStream), e.g.
req.headers.find("User-Agent").Value = "Simon's Super Slurper/0.42"
set res = req.GetResponse("http://www.pocketsoap.com/store/1", "<root>Hello Again!</root>")
Proxy ServersIf you want the request to go via a HTTP proxy server, use the SetProxy method to indicate the name (or IP address) and port where the proxy server is running, e.g.
If the proxy requires authentication, use the ProxyAuthentication method to set the proxy authentication credenitals, e.g.
req.setProxy "proxy.corp.com", 8080
To cancel a previously set proxy configuration, use the NoProxy method, e.g.
req.ProxyAuthentication "myProxyAccount", "yeahright"
AuthenticationTo set authentication credentials for the target server, use the authentication method
req.authentication "myServerAccount", "foo"
TimeoutsTo alter the timeout from its default of 15 seconds, alter the timeout property (this is in milliseconds), e.g.
req.timeout = 5000
Working with the ResponseOnce the request object is configured as required, use the GetResponse method to make a request to a particular server and get the response object. You can call GetResponse multiple times to re-use the same configuration to make multiple requests. The response object can return the response data in 3 different formats, as a String using the String method, as an array of bytes using the Bytes method or as a stream using the Stream method, e.g.
Note that the 3 methods are alternatives, for a particular response you should use just one of them, and use it just once (the component does not copy the response data).
set req = CreateObject("Pocket.HTTP") set res = req.GetResponse("http://www.pocketsoap.com/") wscript.echo res.string
The response object also contains a headers collection property to allow you to examine the response headers, e.g.
The headers collection also supports a standard COM enumerator, so that you can examine all the headers in the collection, e.g.
The response object also includes a statusCode property, so that you can examine the value of the HTTP status code set by the server, e.g.
for each h in res.Headers wscript.echo h.Name & ": " & h.Value next
For diagnostic purposes you can ask it to keep a disk log of the request & response messages, e.g.
If you have a large file that you want to PUT or POST, then to make that easier there a ReaderFactory class that will create a stream for you from the file, you can then pass this stream object as the parameter to GetResponse.
req.option("tracing.file") = "c:\http.log"
Dim f As New PocketHTTP.CoFileReaderFactory Dim stream As IUnknown Set stream = fac.CreateReaderFromFile("c:\myLargeFile.bin") req.Method = "PUT" set res = req.GetResponse("http://my.server.org/files/myLargeFile.bin", stream);
Compressionby default PocketHTTP will send an Accept-Encoding: gzip, deflate header indicating that it can handled a compressed response, if the server returns a compressed response PocketHTTP will automatically un-compress it for you. You can use the following option values to alter the compression settings.
- compression.accept (true/false) - send the Accept-Encoding indicating that we'll handle a compressed response.
- compression.enabled (true/false) - enables the compression of the request body.
- compression.level (0-9) - compression level if rquest compression is turned on, 1 is best speed, 9 is best compression, defaults to the gzip default (6).
- compression.method (gzip/deflate) - the compression method if request compression is on.
Dim f As New PocketHTTP.CoFileReaderFactory Dim stream As IUnknown Set stream = fac.CreateReaderFromFile("c:\myLargeFile.bin") req.Method = "PUT" req.option("compress.enabled") = true set res = req.GetResponse("http://my.server.org/files/myLargeFile.bin", stream);
CookiesYou can access the internal cookies collection that each request object maintains, e.g.
You can copy cookies from one request object to another, e.g.
set req = createObject("Pocket.HTTP") set res = req.GetResponse("http://www.pocketsoap.com/", "") wscript.echo "html body is " & len(res.String) & " bytes long" set cc = req.option("cookies") for each c in cc wscript.echo c.domain & " : " & c.path & " : " & c.name & " -> " & c.value next
You can create bake new cookies from scratch, e.g.
' req is an existing request you want to copy the cookies from set cc = req.option("cookies") set req2 = createObject("Pocket.HTTP") req2.option("cookies").copy(cc)
Mozila Public License v1.1 (MPL)
set req = createObject("Pocket.HTTP") set cc = req.option("cookies") cc.SetCookie "simon", "foo", "/", "www.pocketsoap.com"
|Win32 Version v1.3.4 Packaged Install||151||supports Windows 95 OSR2 / 98 / Me / NT4 / 2000 / XP / 2003||
Windows 95 requires DCOM95 Installing first
Windows 95/98 requires additional installs for SSL support, see this KB article for details.
|PocketPC Version v1.3.4 Packaged Install||355||supports ARM, SH3 & MIPS running PocketPC and ARM devices running PocketPC, PocketPC 2002, PocketPC 2003 and Windows Mobile 5.0||requires ActiveSync 3.0 or greater to install, tested on Compaq iPaq H3650 (ARM) with a CF ethernet card.|
|v1.3.4 Source Code||1876||Single source tree for both PocketPC & desktop versions||Read the building the source notes first !
Source code is also available via the SVN repository at google code.
|v1.3.4 Binaries for the PocketPC 2000 emulator||74||Built binaries suitable for installation into the pocketPC 2000 emulator.||Run regsvrce on pocketHTTP.dll|
|v1.3.4 Binaries for the PocketPC 2002 emulator||74||Built binaries suitable for installation into the pocketPC 2002 emulator.||Run regsvrce on pocketHTTP.dll|
Release HistoryVersion 1.3.4, Sept 15, 2012
- Fix bug in decompressing server responses that would sometime end up reporting that the server hadn't responded, when it had.
- Don't send full URL's in the request when proxies SSL requests.
- Fixed a bug that would cause occasional gzip decompression errors.
- Fixed a bug where the connection pooling for SSL connections that are being proxied would re-use the wrong connection.
- Fixed a bug that would cause occasional bogus gzip errors while reading large responses.
- Fix for the problem using SSL on Windows Mobile 5.0 devices.
- Ability to set and read cookies (in addition to the existing support for round-tripping cookies)
- Calling Read on a response stream that was already fully read would cause an access violation (Thanks to Albert Chau for the patch)
- Improved error message for connection failures.
- Fixed a bug in the tracing option that would cause the HTTP response to not be logged.
- Many thanks to Chris P. Vigelius for contributing the IStream support and the ReaderFactory support
- Added the tracing file option to write a trace file to disk
- Fixed a problem with write's not correctly timing out on PocketPC's
- Can now have timeouts much longer than 32 seconds.
- Added a SaveAs method to the response object so that you can save the HTTP response body directly to disk.
- failures during CONNECT (SSL via Proxy) now include the HTTP status code returned by the proxy server to aid in diagnostics.
- Integrated fixes from Paul Runstedler for a memory leak and error handling in the compression code, thanks Paul!
- Fixed a PocketPC SSL problem that was introduced in 1.2.1.
- Dependencies are all now statically linked, PocketHTTP now consists of a single DLL, PocketHTTP.dll
- Upgraded to zlib 1.2.1, see the zlib website for details on the speed and memory improvements.
- The IHttpResponse.String method will now correctly transcode UTF-8 & UTF-16 encoded responses.
- The installer has been updated to NSIS 2.0
- In certain cases on PocketPC SSL connections wouldn't correctly timeout, this is fixed.
- A few missing AtlReportError calls were added.
- The ability to turn off the accept-encoding header is added ( set the compression.accept option to false)
- A VB friendly version of IReadableStream was added, IReadableStreamVB.
- Fixes the problem using SSL on PocketPC 2003.
- Adds support for handling gzip compression (in addition to the existing support for deflate).
- Handles deflates compressed responses that are missing the zlib header.
- zlib.dll is renamed to pszlib.dll to stop conflicts with OS provided zlib.dll on some WinCE4.2 platforms.
- Added ability to delete request headers.
- Fixed bug where it will try and resolve the address of the server when using a proxied connection.
- Releases request stream as soon as its no longer needed.
- status codes outside of 2xx,30x,500 no longer throw errors.
- a bug with handling whitespace around HTTP header values is fixed.
- a bug with multiple concurrent requests to the same server/port is fixed.
- specific errors codes returned in many places rather than generic error codes.
- Original release based on the HTTP code from PocketSOAP 1.4.2
- Fix for problem resolving host names that start with a number
- Fix for SSL problems with Apache/OpenSSL