Jump to content
Xtreme .Net Talk

How can I communicate with a webpage on the low level.. (aka using GET, HTTP/1.1, Hos


Recommended Posts

Posted

Hello, I need to communicate with a webpage to authenticate a user via "Basic" authentication.

 

If I do this via telnet servername.com 80 here is how the converstation would go..

 

 

me:

GET /FooService/basiconly/Service1.asmx HTTP/1.1

Accept: */*

Host: localhost:8100

Connection: Keep-Alive

 

The server responds with a challenge:

HTTP/1.1 401 Unauthorized

WWW-Authenticate: Digest realm="Login_page", nonce="Ny8yLzIwMDIgMzoyNjoyNCBQTQ", opaque="0000000000000000", stale=false, algorithm=MD5, qop="auth"

 

Then I reply

GET /FooService/basiconly/Service1.asmx HTTP/1.1

Accept: */*

Host: localhost:8100

Authorization: Digest username="test", realm="RassocDigestSample", qop="auth", algorithm="MD5", uri="/FooService/basiconly/Service1.asmx", nonce="Ny8yLzIwMDIgMzoyNjoyNCBQTQ", nc=00000001, cnonce="c51b5139556f939768f770dab8e5277a", opaque="0000000000000000", response="afa30c6445a14e2817a423ca4a143792"

 

 

 

 

 

So basically I need to know how to custome make the request and recieve the answers. (I am not talking about getting HTML data.. I am talking about talking directly to the webserver before the HTML data comes into play)

 

 

thanks!

Lee

Posted

I am not sure if this will help. But a little over a year ago cyclonebri needed to script interaction with a website to gather metrics. I wrote a testbed for him here that utilized System.Net, specifically the HttpWebRequest and HttpWebResponse classes.

 

Take a look at the class posted in the last response.

Joe Mamma

Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized.

Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.

Posted
By the way . . . cyclonebri are you still around? did that work for you?

Joe Mamma

Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized.

Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.

Posted

Very cool!

 

I did something like:

 

   Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
       Dim client As New WebClient
       Dim username As String = "myusername"
       Dim password As String = "mypw"


       Dim bytes = Encoding.ASCII.GetBytes(username & ":" & password)
       client.Headers.Add("Authorization", "Basic " & Convert.ToBase64String(bytes))

       Dim googlelogin = "https://mail.google.com/mail/feed/atom"
       Dim feedStream As Stream = client.OpenRead(googlelogin)
       Dim reader As New StreamReader(feedStream)
       Dim feedAsXml As String = reader.ReadToEnd
       feedStream.Close()

       textbox2.Text = feedAsXml

       End Sub

 

But the only problem with this is.. I want to open up a new IE window.. so the user can see the results. (If the webpage is downloaded the opened from C:\, the user will not see the pictures or style sheets that were refered too).

So basically I would want the user to end up at:

https://mail.google.com/mail/feed/atom

(as well as logged in via my header.add )

 

How can I do this?

 

thanks!

 

Lee

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...