HttpWebRequest object does not send Port in the host header

  • Thread starter Thread starter Ruchita Ghaskadvi
  • Start date Start date
R

Ruchita Ghaskadvi

Hi,

I have identified the problem in my situation which is
HttpWebRequest object does not send port in the Host
header. In my case, server requires this information from
client. According to HTTP 1.1 specifications (which is
default for HttpWebRequest object), a Host header is of
the following format:

Host: <host>[:<port>]

where the port is equal to 80 if unspecified.

But in my case, port is different and it needs to be
specified. So the HttpWebRequest object should send the
correct port number based on the specified url. Also,
there is no property to change the value of Host header
unlike most of the other restricted headers.

Can we get a fix for this problem as soon as possible?

I am using .Net Framework SP2.

Thanks
Ruchita
 
Ruchita Ghaskadvi said:
Hi,

I have identified the problem in my situation which is
HttpWebRequest object does not send port in the Host
header. In my case, server requires this information from
client. According to HTTP 1.1 specifications (which is
default for HttpWebRequest object), a Host header is of
the following format:

Host: <host>[:<port>]

where the port is equal to 80 if unspecified.

But in my case, port is different and it needs to be
specified. So the HttpWebRequest object should send the
correct port number based on the specified url. Also,
there is no property to change the value of Host header
unlike most of the other restricted headers.

Can we get a fix for this problem as soon as possible?

http://msdn.microsoft.com/netframework/downloads/redist.aspx


Looks like this works under the 1.1 framework.


This request

Dim req As Net.HttpWebRequest =
Net.WebRequest.Create(http://localhost:8000/appdir/test.aspx)

generated this HTTP request

GET /appdir/test.aspx HTTP/1.1
Connection = Keep-Alive
Host = localhost:8000

You shouldn't even have to recompile, just run your code under the 1.1
framework.

David
 
Back
Top