problem with an HTTP request using a username and password.

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

problem with an HTTP request using a username and password.

Long Haired David
I have a web cam running and want to capture a snapshot every 7 or so seconds. I have no problems doing this on ordinary web access using WinHttpSession. However, my web cam insists on a login/password combination.

I can access the snapshot by using the following url.

http://guest:[hidden email]:81/media?action=snapshot

I should add that waterfrontweather.co.uk us my own web site running on a server in my apartment.

When I try to do the same using some code I get an html response that tells me that I need to log in. What I should get is a text stream which, when saved as a raw file, becomes a jpeg. (I have done this thousands of times before when accessing stock photos of items at a wholesaler's web site so I am happy that, generally, this works.The code is as follows.

|   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


You can try this from your browser and should get the same http text response.

This is what I get

'<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>

 

'

Any thoughts would be helpful.


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.
 
 
David
Totally Objects
Doing Smalltalk since 1989