HTTP/S Post Get Head

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

HTTP/S Post Get Head

Edward Stow
Hi all,

Using Dolphin X6 Community Edition

Does Dolphin have classes that support provide client side HTTP/S Post
Get Head functionality

I was hoping that I could avoid looking at the MS interfaces and MSDN
-- afterall that is why I use Smalltalk :)

Any cookbook code to get me going?

Regards


Reply | Threaded
Open this post in threaded view
|

Re: HTTP/S Post Get Head

Chris Uppal-3
[hidden email] wrote:

> Does Dolphin have classes that support provide client side HTTP/S Post
> Get Head functionality

It has some ability, in the box, to use MS's APIs.  See URLMonLibrary and
references to it.

As far as I know, those APIs don't include the ability to do a HEAD (not sure
about POST either); and Dolphin doesn't provide wrappers even if they do exist.

A rather nice and complete HTTP client library is by Steve Waring.  Quite a few
people use that and are happy with it.  I'm not sure where the latest and
greatest version is (I think OA made some modifications to it for D6).

However that doesn't do HTTPS.  I don't know of a Dolphin library which does.
Presumably it would be possible to wrap an existing SSL library like OpenSSL,
and then plug that into Steve's stuff.  But I don't know of anyone who has done
that.  Alternatively, I suppose, you could uses something external like
Stunnel, but I have no experience of that.

    -- chris


Reply | Threaded
Open this post in threaded view
|

Re: HTTP/S Post Get Head

Chris Uppal-3
In reply to this post by Edward Stow
[hidden email] wrote:

> Does Dolphin have classes that support provide client side HTTP/S Post
> Get Head functionality

Another approach I've just been playing with.  You could use a IWinHttpRequest
COM/ActiveX object.  It's easiest if you tell Dolphin to generate a wrapper
package first.  Steps to do so:

Open the ActiveX Compent Wizard
 Click Browse
 Select "Microsoft WinHTTP Services, version 5.1"
 Click OK
 Click Next
 Uncheck 'Class prefix" (not needed in this case)
 Click Next
 (You may have to resize the next page, because of a bug in D6)
 *** DON'T CLICK FINISH YET ***
 Click Generate
 Now you can click Finish.

With that generated, you can do:

"simple GET"
 r := IWinHttpRequest new.
 r open: 'GET' url: 'http://www.microsoft.com/' async: false.  "--> 0 "
 r send. "--> 0 "
 r status. "--> 200 "
 r statusText. "--> 'OK' "
 r responseText.

"a HEAD"
 r := IWinHttpRequest new.
 r open: 'HEAD' url: 'http://www.object-arts.com/' async: false. "--> 0 "
 r send. "--> 0 "
 r status. "--> 200 "
 r statusText. "--> 'OK' "
 r responseText. --> ''

"an HTTPS request"
 r := IWinHttpRequest new.
 r open: 'GET' url: 'https://portal.acm.org/poplogin.cfm' async: false. "--> 0
"
 r send.  "--> 0 "
 r status. " --> 200 "
 r statusText. " --> 'OK' "
 r responseText.

See
 http://msdn.microsoft.com/library/en-us/winhttp/http/winhttprequest.asp
and

http://msdn.microsoft.com/library/en-us/winhttp/http/using_the_winhttprequest_com_object.asp
for more information, including how to use these things asynchronously (which
you would probably want to do in a real application).

    -- chris


Reply | Threaded
Open this post in threaded view
|

Re: HTTP/S Post Get Head

David Gorisek-5
In reply to this post by Chris Uppal-3
The simplest thing to do is to use SSLTunnel which will tunnel your HTTP
request to a HTTP server.

Best regards,

David Gorisek


Chris Uppal wrote:

> [hidden email] wrote:
>
>> Does Dolphin have classes that support provide client side HTTP/S Post
>> Get Head functionality
>
> It has some ability, in the box, to use MS's APIs.  See URLMonLibrary and
> references to it.
>
> As far as I know, those APIs don't include the ability to do a HEAD (not sure
> about POST either); and Dolphin doesn't provide wrappers even if they do exist.
>
> A rather nice and complete HTTP client library is by Steve Waring.  Quite a few
> people use that and are happy with it.  I'm not sure where the latest and
> greatest version is (I think OA made some modifications to it for D6).
>
> However that doesn't do HTTPS.  I don't know of a Dolphin library which does.
> Presumably it would be possible to wrap an existing SSL library like OpenSSL,
> and then plug that into Steve's stuff.  But I don't know of anyone who has done
> that.  Alternatively, I suppose, you could uses something external like
> Stunnel, but I have no experience of that.
>
>     -- chris
>
>


Reply | Threaded
Open this post in threaded view
|

Re: HTTP/S Post Get Head

John Rubier
In reply to this post by Chris Uppal-3
Chris Uppal wrote:

> [hidden email] wrote:
>
> > Does Dolphin have classes that support provide client side HTTP/S Post
> > Get Head functionality
>
> It has some ability, in the box, to use MS's APIs.  See URLMonLibrary and
> references to it.
>
> As far as I know, those APIs don't include the ability to do a HEAD (not sure
> about POST either); and Dolphin doesn't provide wrappers even if they do exist.
>
> A rather nice and complete HTTP client library is by Steve Waring.  Quite a few
> people use that and are happy with it.  I'm not sure where the latest and
> greatest version is (I think OA made some modifications to it for D6).
>
> However that doesn't do HTTPS.  I don't know of a Dolphin library which does.
> Presumably it would be possible to wrap an existing SSL library like OpenSSL,
> and then plug that into Steve's stuff.  But I don't know of anyone who has done
> that.  Alternatively, I suppose, you could uses something external like
> Stunnel, but I have no experience of that.
>
>     -- chris


I haven't tested this extensively however a quick test worked fine:
Use Steve's HTTP client.

Install Chris Double's SSLSocket package:
http://www.double.co.nz/smalltalk/
Originally designed for D4 but works under 6 (in my limited testing).
Should probable be updated to use the v2 sockets...

Evaluate this in a wordspace:
Smalltalk at: #OpenSSLSocket put: SSLSocket.

Then Steve's awesome HTTP client "just works":
        request := SptHTTPRequest new.
        request openGetTo: 'https://www.elliottwave.com'.
        request addHeader: 'Accept' value: '*/*'.
        request send.
        request waitOnReady.
        request responseBody. "Inspect It"

Sniffing with Ethereal shows the traffic is indeed encrypted.

No idea how stable it is, YMMV, IANAL, etc.

Take care,

John