Bind HttpWebRequest/-Response to a specific stream?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kellox
    New Member
    • Jul 2007
    • 2

    Bind HttpWebRequest/-Response to a specific stream?

    I'm implementing a propiertary protocol for a company which is actually an extension of HTTP (extended with some specific headers). If I use the .NET class HttpWebRequest and HttpWebResponse respectively I can easily communicate with the server by setting the necessary headers.
    Since any further requests/responses should be sent over the connection, established after the first request, for receiving events from the server, I have to left the stream in HttpWebRequest be opened (I cannot change the server application).
    Unfortunately the stream by calling the method GetRequestStrea m is closed after one request/response.
    The KeepAlive property is also not an option, since the server has to be HTTP/1.1 compliant for that to work and it will break the connection somewhere in time (even on non-fatal errors).
    My question if there is a change to introduce something like a method "SetRequestStre am" into a subclass of HttpWebRequest for example to specify which stream has to be used for the connection.
    But I doubt that this works since one has no access to the socket-level in the class HttpWebRequest. Using the source code (ROTOR project) of HttpWebRequest is also not an option since this application is going to be commercial.
    I hope someone has some useful ideas...
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Implementing HTTP at the socket level really isn't all that bad.
    I've been working on the server side of it for awhile now.

    See the RFC for HTTP to make sure you follow at least minimal implementation standards.

    HTTP/1.0 is really really simple since it's without much of the headers.

    For example in HTTP/1.0 you can get away with:
    Code:
    "GET / HTTP/1.0\r\n"
    as a valid request

    Comment

    Working...