Go Back  Xtreme Visual Basic Talk > Visual Basic .NET (2002/2003/2005/2008, including Express editions) > .NET General > Webserver: HTTP header


Reply
 
Thread Tools Display Modes
  #1  
Old 02-03-2004, 04:54 PM
Devil-ubber Devil-ubber is offline
Newcomer
 
Join Date: Feb 2004
Posts: 2
Default 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.
Reply With Quote
  #2  
Old 02-04-2004, 06:44 PM
Devil-ubber Devil-ubber is offline
Newcomer
 
Join Date: Feb 2004
Posts: 2
Default

Anyone?
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
HTTP Header: Content-Type declarations chart xXxRUxXx Tech Discussions 2 01-10-2004 08:15 PM
return header on http xtremist525 Communications 8 10-28-2003 07:15 PM
getting the full header of an http connection pelegk2 Web Programming 0 10-19-2003 12:35 AM
Ensuring HTTP header included for all WebBrowser navigation your face Communications 0 03-28-2003 01:44 PM
Retrieve HTTP Response Header Flare General 0 12-15-2000 12:58 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->