Webserver: HTTP header

Devil-ubber
02-03-2004, 04:54 PM
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:


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.

Devil-ubber
02-04-2004, 06:44 PM
Anyone?

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum