
02-03-2004, 04:54 PM
|
|
Newcomer
|
|
Join Date: Feb 2004
Posts: 2
|
|
Webserver: HTTP header
|
I am developing an http webserver in VB.Net using TCPListener, TCPClient, and the Network stream classes. The server is working fine right now except that when I try to send the http headers (content type, redirection, etc) the client does not respond properly (e.g doesn't treat show images, does not get redirected, etc).
All seems fine (IF) I don't send the headers before the rest of response.
I am constructing the headers as strings and then converting them to bytes:
Code:
Private Sub WriteHttpHeader( _
ByRef stmData As System.Net.Sockets.NetworkStream, _
ByVal strHeader As String, ByVal strValue As String)
Dim strTemp As String = ""
If strHeader <> "" Then
strTemp = strHeader & ": " & strValue & ControlChars.Cr
Else
strTemp = ControlChars.Cr
End If
Dim bytTemp(strTemp.Length) As Byte
Dim enc As New System.Text.ASCIIEncoding
enc.GetBytes(strTemp, 0, strTemp.Length, bytTemp, 0)
If stmData.CanWrite Then
stmData.Write(bytTemp, 0, bytTemp.Length)
End If
End Sub
Any help is greatly appreciated.
|
|