Hi everyone. We have been using WinHttpSession to screen scrape wholesaler's web sites to get stock levels and also to obtain stock images of products. We have been doing this for some years without any problems. Obtaining images is just a matter of getting the html stream for the jpg and saving all of the characters into a file. What we get out the end is a fully formed jpeg file. Nice and easy.
I have just installed a streaming web cam on our apartment balcony and it has a snapshot option which I want to grab every 7 seconds for a WebConnection page of the weather. You can see this at http://www.waterfrontweather.co.uk/ipadweather.
The web cam requires a log in to serve a snapshot. I am using our SocketSet product to do this as I had it already set up but it is not the fastest at getting connections and as I have to do this every 7 seconds, I decided to use WinHttpSession instead. We have this all set up to download jpegs so it was only a case of putting in the username/password and everything should have worked. Unlucky me!
You can check that the snapshot works by putting the following url into the browser.
I am using the following code:
| server session realUrl f stream result url|
url := 'http://guest:guest@...:81/media?action=snapshot'.
session := WinHttpSession new.
realUrl := url winHttpAsUrl.
[
| connection response contentLength |
connection := session connectToUrl: realUrl.
stream := WriteStream on: String new.
response := connection submitGetRequest: realUrl absolutePath using: stream.
contentLength := response headerContentLength.
result := stream contents
] ensure: [
session release
] .
^ result
When inspected, result should contain the jpeg data stream. However, what I get is the following:
'<html><head><title>Document Error: Unauthorized</title></head>
<body><h2>Access Error: Unauthorized</h2>
<p>Access to this document requires a User ID</p></body></html>
'
which is the standard html returned by the webcam when it doesn't like the login. Obviously, the username and password isn't getting through using WinHttpSession.
I would be grateful for any help in getting this to work.
David
--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
[hidden email].
To post to this group, send email to
[hidden email].
Visit this group at
http://groups.google.com/group/va-smalltalk?hl=en.
For more options, visit
https://groups.google.com/groups/opt_out.