|
You last visited: Today at 11:01
Advertisement
[VB.NET] Httpwebrequest "Location" in Response herausfinden?
Discussion on [VB.NET] Httpwebrequest "Location" in Response herausfinden? within the .NET Languages forum part of the Coders Den category.
04/26/2013, 17:30
|
#1
|
elite*gold: 2049
Join Date: May 2012
Posts: 4,593
Received Thanks: 441
|
[VB.NET] Httpwebrequest "Location" in Response herausfinden?
Ich habe hier folgenden Code aus Livehttpheaders:
Code:
HTTP/1.1 302 FOUND
Content-Language: de
Content-Type: text/html; charset=utf-8
Date: Tue, 23 Apr 2013 14:54:47 GMT
Location: http://statigr.am?code=c19309934fg45e178d0f8581ec5a9318
Server: nginx
Set-Cookie: csrftoken=MEINTOKEN; expires=Tue, 22-Apr-2014 14:54:47 GMT; Max-Age=31449600; Path=/
Set-Cookie: ccode=DE; Path=/
Vary: Cookie, Accept-Language
Content-Length: 0
Connection: keep-alive
Doch wie komme ich jzt in der Response auf die Location?
Code:
Location: http://statigr.am?code=c19309934fg45e178d0f8581ec5a9318
Würde mich über schnelle Hilfe freuen :-)
MfG, maxasoft
|
|
|
04/26/2013, 17:43
|
#2
|
elite*gold: 0
Join Date: Sep 2005
Posts: 426
Received Thanks: 87
|
PHP Code:
HttpWebResponse response = (HttpWebResponse)request.GetResponse(); string url= response.Headers["Location"];
|
|
|
04/26/2013, 20:52
|
#3
|
elite*gold: 2932
Join Date: Oct 2009
Posts: 6,966
Received Thanks: 1,097
|
da das einer der normalen header ist bekommste den über response.location wenn ich mich recht entsinne
|
|
|
04/26/2013, 21:47
|
#4
|
elite*gold: 2049
Join Date: May 2012
Posts: 4,593
Received Thanks: 441
|
Quote:
Originally Posted by kissein
PHP Code:
HttpWebResponse response = (HttpWebResponse)request.GetResponse(); string url= response.Headers["Location"];
|
Wenn ich mir das dann in ner Msgbox auswerfen lasse, bleibt diese leer.
Code:
Code:
response = CType(request.GetResponse(), HttpWebResponse)
Dim url As String = response.Headers("Location")
MsgBox(url)
Quote:
Originally Posted by tolio
da das einer der normalen header ist bekommste den über response.location wenn ich mich recht entsinne
|
Ich habs mal so probiert:
Code:
Dim str as string = Response.Headers(0)
Ich hab mir mal die Werte 0-9 ausspucken lassen, allerdings kommt nirgends ne URL und ab 5 oder 6 kommt nur noch das Datum + Uhrzeit
|
|
|
04/27/2013, 00:59
|
#5
|
elite*gold: 2932
Join Date: Oct 2009
Posts: 6,966
Received Thanks: 1,097
|
dann hast du automatische weiterleitung nicht deaktiviert im request
schau mal die eigenschaften des request elements durch
|
|
|
04/27/2013, 10:32
|
#6
|
elite*gold: 2049
Join Date: May 2012
Posts: 4,593
Received Thanks: 441
|
Quote:
Originally Posted by tolio
dann hast du automatische weiterleitung nicht deaktiviert im request
schau mal die eigenschaften des request elements durch
|
Ok wie ich stell ich das an?
Kenn mich mit Requests nicht so aus & finde nichts was mit Weiterleitung zu tun haben könnte ://
|
|
|
04/27/2013, 10:41
|
#7
|
elite*gold: 1
Join Date: Jun 2012
Posts: 5,819
Received Thanks: 3,200
|
PHP Code:
Request.AllowAutoRedirect = True
bzw
PHP Code:
Request.AllowAutoRedirect = False
|
|
|
04/27/2013, 11:09
|
#8
|
elite*gold: 2049
Join Date: May 2012
Posts: 4,593
Received Thanks: 441
|
Also ich hab hier jzt noch den 1. Teil von meinem Code:
Quote:
POST /accounts/login/?next=/oauth/authorize%3Fclient_id%3Dd9494686198d4dfeb954979a3e 270e5e%26redirect_uri%3Dhttp%253A%252F%252Fstatigr .am%26response_type%3Dcode%26scope%3Dlikes%2Bcomme nts%2Brelationships HTTP/1.1
Host: instagram.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Referer:
Cookie: __utma=1.587282930.1364898967.1366655494.136672880 4.18; __utmz=1.1366728804.18.8.utmcsr=statigr.am|utmccn= (referral)|utmcmd=referral|utmcct=/; sessionid=IGSC81397fce99fa901ce1352a22044521f0abb4 739bf4fefbf8291a76c33eb9b0f9%3A2CONbTw6EPQOdXM7zzg BR3ShOrM4mXv6%3A%7B%7D; __utma=227057989.1301201774.1364921187.1366535981. 1366644849.4; __utmz=227057989.1364921187.1.1.utmcsr=(direct)|ut mccn=(direct)|utmcmd=(none); mid=UWxICf__AAEW7kr-skD5RclybnUI; csrftoken=7d08a95f7c246738d05c4da3e3de9260; __utmb=1.1.10.1366728804; __utmc=1
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 95
csrfmiddlewaretoken=7de5a9527cd46738d65c4de3e3de92 60&username=USERNAME&password=PASSWORT
HTTP/1.1 302 FOUND
Cache-Control: max-age=0
Content-Language: de
Content-Type: text/html; charset=utf-8
Date: Tue, 23 Apr 2013 14:54:47 GMT
Expires: Tue, 23 Apr 2013 14:54:46 GMT
Last-Modified: Tue, 23 Apr 2013 14:54:46 GMT
Location:
Server: nginx
Set-Cookie: csrftoken=7de5a9527cd46738d65c4de3e3de9260; expires=Tue, 22-Apr-2014 14:54:46 GMT; Max-Age=31449600; Path=/
Set-Cookie: sessionid=IGSCabf2b84ce1517fc0c9fffdecd26607eb4edb b7a9afe0751f5ca82161a3a3b731%3AfgOSujluz72uXkqLecf lcLML6rK8QcqT%3A%7B%22_token%22%3A%22323476982%3AQ F7Ftup9cGPra3NqMw2AwsHqKy4zmrWJ%3A4716a97aa7fded1a 24d8636cdd6c4ee0cd19f0e54b139f67ed9ef40fce8780fc%2 2%2C%22last_refreshed%22%3A1366728886.992144%2C%22 _auth_user_backend%22%3A%22distillery.accounts.bac kends.CaseInsensitiveModelBackend%22%2C%22_auth_us er_id%22%3A323476982%7D; expires=Mon, 22-Jul-2013 14:54:46 GMT; Max-Age=7776000; Path=/;HttpOnly
Vary: Cookie, Accept-Language
Content-Length: 0
Connection: keep-alive
|
Die übergebe ich mit:
Code:
Dim Request2 As HttpWebRequest = CType(HttpWebRequest.Create(tokenURL), HttpWebRequest)
'Proxy
'Request.Proxy = New WebProxy("159.255.166.29:8080")
Request2.Method = "POST"
Request2.ContentType = "application/x-www-form-urlencoded"
Request2.Referer = tokenURL
Request2.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
Request2.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0"
Request2.CookieContainer = cookieCon
Dim Post As String = "csrfmiddlewaretoken=" & token & "&username=" & TextBox1.Text & "&password=" & TextBox2.Text
Dim byteArray() As Byte = Encoding.UTF8.GetBytes(Post)
Request2.ContentLength = byteArray.Length
Dim DataStream As Stream = Request2.GetRequestStream()
DataStream.Write(byteArray, 0, byteArray.Length)
DataStream.Close()
Dim Response2 As HttpWebResponse = Request2.GetResponse()
DataStream = Response2.GetResponseStream()
Dim reader As New StreamReader(DataStream)
Dim ServerResponse As String = reader.ReadToEnd()
reader.Close()
DataStream.Close()
Response2.Close()
RichTextBox1.Text = ServerResponse
Wenn ich allerdings den Quelltext anzeigen lasse, ist das fast der selbe wie vor der Request, also der von der Instagram-Login-Form. ^^
Wenn ich bei einer der Requests AllowAutoRedirect = False verwende, wird aber gar kein Quelltext angezeigt.
Und wenn ich bei der Request oben im 1. Post AllowAutoRedirect = False verwende, bekomm ich unter Location nicht den Statigr.am Link, sondern den Link, an die ich das token & die Logindaten gesendet habe. Der ganze Code für die Request vom 1. Post:
Code:
request = CType(HttpWebRequest.Create("https://instagram.com/oauth/authorize?client_id=" & id & "&redirect_uri=http%3A%2F%2Fstatigr.am&response_type=code&scope=likes+comments+relationships"), HttpWebRequest)
request.CookieContainer = cookieCon
request.AllowAutoRedirect = False
response = CType(request.GetResponse(), HttpWebResponse)
Dim url As String = response.Headers("Location")
MsgBox(url)
Dim sr As New StreamReader(response.GetResponseStream())
Dim quelltext As String = sr.ReadToEnd
If quelltext = RichTextBox1.Text Then
MsgBox("same")
Else
MsgBox("other")
RichTextBox1.Text = quelltext
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
|
|
|
04/27/2013, 15:22
|
#9
|
elite*gold: 2932
Join Date: Oct 2009
Posts: 6,966
Received Thanks: 1,097
|
sinds eventuell mehrere weiterleitungen hintereinander?
|
|
|
04/27/2013, 16:01
|
#10
|
elite*gold: 2049
Join Date: May 2012
Posts: 4,593
Received Thanks: 441
|
ich hab hier jzt mal den kompletten Code aus Lhttpheaders:
Code:
https://instagram.com/accounts/login/?next=/oauth/authorize%3Fclient_id%3Dd9494686198d4dfeb954979a3e270e5e%26redirect_uri%3Dhttp%253A%252F%252Fstatigr.am%26response_type%3Dcode%26scope%3Dlikes%2Bcomments%2Brelationships
POST /accounts/login/?next=/oauth/authorize%3Fclient_id%3Dd9494686198d4dfeb954979a3e270e5e%26redirect_uri%3Dhttp%253A%252F%252Fstatigr.am%26response_type%3Dcode%26scope%3Dlikes%2Bcomments%2Brelationships HTTP/1.1
Host: instagram.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Referer: https://instagram.com/accounts/login/?next=/oauth/authorize%3Fclient_id%3Dd9494686198d4dfeb954979a3e270e5e%26redirect_uri%3Dhttp%253A%252F%252Fstatigr.am%26response_type%3Dcode%26scope%3Dlikes%2Bcomments%2Brelationships
Cookie: __utma=1.587282930.1364898967.1366655494.1366728804.18; __utmz=1.1366728804.18.8.utmcsr=statigr.am|utmccn=(referral)|utmcmd=referral|utmcct=/; sessionid=IGSC81397fce99fa901ce1352a22044521f0abb4739bf4fefbf8291a76c33eb9b0f9%3A2CONbTw6EPQOdXM7zzgBR3ShOrM4mXv6%3A%7B%7D; __utma=227057989.1301201774.1364921187.1366535981.1366644849.4; __utmz=227057989.1364921187.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); mid=UWxICf__AAEW7kr-skD5RclybnUI; csrftoken=7d08a95f7d456d338d05c4da3e3de9260; __utmb=1.1.10.1366728804; __utmc=1
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 95
csrfmiddlewaretoken=7d08a95f7d456d338d05c4da3e3de9260&username=USERNAME&password=PASSWORT
HTTP/1.1 302 FOUND
Cache-Control: max-age=0
Content-Language: de
Content-Type: text/html; charset=utf-8
Date: Tue, 23 Apr 2013 14:54:47 GMT
Expires: Tue, 23 Apr 2013 14:54:46 GMT
Last-Modified: Tue, 23 Apr 2013 14:54:46 GMT
Location: https://instagram.com/oauth/authorize?client_id=d9494686198d4dfeb954979a3e270e5e&redirect_uri=http%3A%2F%2Fstatigr.am&response_type=code&scope=likes+comments+relationships
Server: nginx
Set-Cookie: csrftoken=7d08a95f7d456d338d05c4da3e3de9260; expires=Tue, 22-Apr-2014 14:54:46 GMT; Max-Age=31449600; Path=/
Set-Cookie: sessionid=IGSCabf2b84ce1517fc0c9fffdecd26607eb4edbb7a9afe0751f5ca82161a3a3b731%3AfgOSujluz72uXkqLecflcLML6rK8QcqT%3A%7B%22_token%22%3A%22323476982%3AQF7Ftup9cGPra3NqMw2AwsHqKy4zmrWJ%3A4716a97aa7fded1a24d8636cdd6c4ee0cd19f0e54b139f67ed9ef40fce8780fc%22%2C%22last_refreshed%22%3A1366728886.992144%2C%22_auth_user_backend%22%3A%22distillery.accounts.backends.CaseInsensitiveModelBackend%22%2C%22_auth_user_id%22%3A323476982%7D; expires=Mon, 22-Jul-2013 14:54:46 GMT; Max-Age=7776000; Path=/;HttpOnly
Vary: Cookie, Accept-Language
Content-Length: 0
Connection: keep-alive
----------------------------------------------------------
https://instagram.com/oauth/authorize?client_id=d9494686198d4dfeb954979a3e270e5e&redirect_uri=http%3A%2F%2Fstatigr.am&response_type=code&scope=likes+comments+relationships
GET /oauth/authorize?client_id=d9494686198d4dfeb954979a3e270e5e&redirect_uri=http%3A%2F%2Fstatigr.am&response_type=code&scope=likes+comments+relationships HTTP/1.1
Host: instagram.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Referer: https://instagram.com/accounts/login/?next=/oauth/authorize%3Fclient_id%3Dd9494686198d4dfeb954979a3e270e5e%26redirect_uri%3Dhttp%253A%252F%252Fstatigr.am%26response_type%3Dcode%26scope%3Dlikes%2Bcomments%2Brelationships
Cookie: __utma=1.587282930.1364898967.1366655494.1366728804.18; __utmz=1.1366728804.18.8.utmcsr=statigr.am|utmccn=(referral)|utmcmd=referral|utmcct=/; sessionid=IGSCabf2b84ce1517fc0c9fffdecd26607eb4edbb7a9afe0751f5ca82161a3a3b731%3AfgOSujluz72uXkqLecflcLML6rK8QcqT%3A%7B%22_token%22%3A%22323476982%3AQF7Ftup9cGPra3NqMw2AwsHqKy4zmrWJ%3A4716a97aa7fded1a24d8636cdd6c4ee0cd19f0e54b139f67ed9ef40fce8780fc%22%2C%22last_refreshed%22%3A1366728886.992144%2C%22_auth_user_backend%22%3A%22distillery.accounts.backends.CaseInsensitiveModelBackend%22%2C%22_auth_user_id%22%3A323476982%7D; __utma=227057989.1301201774.1364921187.1366535981.1366644849.4; __utmz=227057989.1364921187.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); mid=UWxICf__AAEW7kr-skD5RclybnUI; csrftoken=7d08a95f7c246738d05c4da3e3de9260; __utmb=1.1.10.1366728804; __utmc=1
Connection: keep-alive
HTTP/1.1 302 FOUND
Content-Language: de
Content-Type: text/html; charset=utf-8
Date: Tue, 23 Apr 2013 14:54:47 GMT
Location: http://statigr.am?code=c19309934c8f4e178d0f8581ec5a9318
Server: nginx
Set-Cookie: csrftoken=7d08a95f7d456d338d05c4da3e3de9260; expires=Tue, 22-Apr-2014 14:54:47 GMT; Max-Age=31449600; Path=/
Set-Cookie: ccode=DE; Path=/
Vary: Cookie, Accept-Language
Content-Length: 0
Connection: keep-alive
----------------------------------------------------------
http://statigr.am/?code=c19309934c8f4e178d0f8581ec5a9318
GET /?code=c19309934c8f4e178d0f8581ec5a9318 HTTP/1.1
Host: statigr.am
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Cookie: __utma=161556734.905460235.1366484677.1366728599.1366728750.8; __utmz=161556734.1366550157.2.2.utmcsr=elitepvpers.com|utmccn=(referral)|utmcmd=referral|utmcct=/forum/elite-gold-trading/2551622-suche-visual-basic-sourcecode-bild-auf-statigr-am-liken-biete-50-e-gold.html; STATISESSID=st07b3vnfbleagm72m9ted0er5; __utmb=161556734.2.9.1366728800782; __utmc=161556734
Connection: keep-alive
HTTP/1.1 302 Found
X-Powered-By: PHP/5.3.3-7+squeeze14
P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Pragma: no-cache
Set-Cookie: sgli=323476982+800345c6d0da3bd0e7f4677ee213d0dafc2bcb9f; expires=Thu, 23-May-2013 14:54:48 GMT; path=/; domain=.statigr.am
Location: http://statigr.am/viewer.php
Vary: Accept-Encoding,User-Agent
Content-Encoding: gzip
Content-Type: text/html; charset=utf-8
Content-Length: 20
Accept-Ranges: bytes
Date: Tue, 23 Apr 2013 14:54:48 GMT
X-Varnish: 1782578728
Connection: keep-alive
X-Cache: C:Off A:0 MISS
Server: SylvainHTTP
----------------------------------------------------------
Danach kommt dann Teil von Statigr.am
Was mir übrigens am meisten Sorgen macht, ist, dass im Cookie ein Link von epvp übergeben wird:
Code:
http://statigr.am/?code=c19309934c8f4e178d0f8581ec5a9318
Cookie: __utma=161556734.905460235.1366484677.1366728599.1366728750.8; __utmz=161556734.1366550157.2.2.utmcsr=elitepvpers.com|utmccn=(referral)|utmcmd=referral|utmcct=/forum/elite-gold-trading/2551622-suche-visual-basic-sourcecode-bild-auf-statigr-am-liken-biete-50-e-gold.html;
----------------------------------------------------------
|
|
|
04/27/2013, 16:31
|
#11
|
elite*gold: 2932
Join Date: Oct 2009
Posts: 6,966
Received Thanks: 1,097
|
sind oben drei weiterleitungen -> (request machen, lokation auslesen auf die lokation nen request machen) und das quasi mal 3
@cookies, das die datenstasi überall ist, ist ja nix neues, sollte jedem klar sein der sich im inet bewegt
|
|
|
04/27/2013, 16:31
|
#12
|
elite*gold: 1
Join Date: Jun 2012
Posts: 5,819
Received Thanks: 3,200
|
PHP Code:
Response.GetResponseHeader("Location")
Wäre auch noch ne lösung, die klappen sollte(sofern alle requests richtig gesendet wurden)
|
|
|
04/27/2013, 17:34
|
#13
|
elite*gold: 2049
Join Date: May 2012
Posts: 4,593
Received Thanks: 441
|
Quote:
Originally Posted by 'Heaven.
PHP Code:
Response.GetResponseHeader("Location")
Wäre auch noch ne lösung, die klappen sollte( sofern alle requests richtig gesendet wurden)
|
Das bezweifle ich ^^
|
|
|
All times are GMT +2. The time now is 11:01.
|
|