HTTPWebResponse Raw Response using Reflection

HTTPWebResponse provides the properties of the headers, is it possible to get a raw response, as soon as we get to use the socket , header and content combined using Reflection , I think there should be a way.

I can use a socket, but a lot of work is needed to use them, such as proxy support, https, progress events, etc. The list is long, I strongly recommend using HTTPWebRequest, only the problem is that I need raw response headers, the sites I'm trying to load send a very long and strange cookie that is not processed by HTTPWebRequest, WebClient. Wordpress blogs that cannot log into any Wordpress blog using WebClient, but it works fine with Sockets cookies, can be a bug in WebClient.

1) You just need the original headers to do the trick.

2) And also the article link

The article says that HTTPWebRequest exists, only one thread is loaded, while others are waiting , if this is true, then sockets are better?

The article says: This code works well, but it has a very serious problem, since the function of the WebRequest GetResponse class blocks access to all other processes, WebRequest reports the received response as closed, as in the last line of the previous code. Therefore, I noticed that only one thread is always loaded, while others are waiting for GetResponse. To solve this serious problem, I applied my two classes MyWebRequest and MyWebResponse using Socket.

+5
source share
1

:

var rawHeaders = request.GetResponse().Headers.ToString();

:

Pragma: no-cache
X-Frame-Options: SAMEORIGIN
Cache-Control: no-cache, must-revalidate, max-age=0
Date: Wed, 03 Aug 2011 12:08:49 GMT
Expires: Wed, 11 Jan 1984 05:00:00 GMT
Set-Cookie: wordpress_test_cookie=WP+Cookie+check;     path=/,wordpress_c2d1208bd3bc2294298da94d67693495=+; expires=Tue, 03-Aug-2010 12:08:49 GMT; path=/wp-admin,wordpress_sec_c2d1208bd3bc2294298da94d67693495=+; expires=Tue, 03-Aug-2010 12:08:49 GMT; path=/wp-admin,wordpress_c2d1208bd3bc2294298da94d67693495=+; expires=Tue, 03-Aug-2010 12:08:49 GMT; path=/wp-content/plugins,wordpress_sec_c2d1208bd3bc2294298da94d67693495=+; expires=Tue, 03-Aug-2010 12:08:49 GMT; path=/wp-content/plugins,wordpress_logged_in_c2d1208bd3bc2294298da94d67693495=+; expires=Tue, 03-Aug-2010 12:08:49 GMT; path=/,wordpress_logged_in_c2d1208bd3bc2294298da94d67693495=+; expires=Tue, 03-Aug-2010 12:08:49 GMT; path=/,wordpress_c2d1208bd3bc2294298da94d67693495=+; expires=Tue, 03-Aug-2010 12:08:49 GMT; path=/,wordpress_c2d1208bd3bc2294298da94d67693495=+; expires=Tue, 03-Aug-2010 12:08:49 GMT; path=/,wordpress_sec_c2d1208bd3bc2294298da94d67693495=+; expires=Tue, 03-Aug-2010 12:08:49 GMT; path=/,wordpress_sec_c2d1208bd3bc2294298da94d67693495=+; expires=Tue, 03-Aug-2010 12:08:49 GMT; path=/,wordpressuser_c2d1208bd3bc2294298da94d67693495=+; expires=Tue, 03-Aug-2010 12:08:49 GMT; path=/,wordpresspass_c2d1208bd3bc2294298da94d67693495=+; expires=Tue, 03-Aug-2010 12:08:49 GMT; path=/,wordpressuser_c2d1208bd3bc2294298da94d67693495=+; expires=Tue, 03-Aug-2010 12:08:49 GMT; path=/,wordpresspass_c2d1208bd3bc2294298da94d67693495=+; expires=Tue, 03-Aug-2010 12:08:49 GMT; path=/
Server: Apache
X-Powered-By: PHP/5.2.17
Last-Modified: Wed, 03 Aug 2011 12:08:49 GMT
Content-Type: text/html; charset=UTF-8
X-Cache: MISS from localhost
X-Cache-Lookup: MISS from localhost:3128
Via: 1.0 localhost (squid/3.1.6)
Connection: close

?

WebRequests - . .

UPDATE

, ( . ). , HttpWebRequest.GetResponse().

System.Net.WebHeaderCollection.ParseHeaders() System.Net.WebHeaderCollection.ParseHeadersStrict() ( System.Net.Configuration.SettingsSectionInternal.Section.UseUnsafeHeaderParsing), . , (System.Net.Connection.m_ReadBuffer), . .

, System.Net.Connection, ServicePoint, , HttpWebRequest. , .

, - cookie, Socket. , .

+8

All Articles