Board index » delphi » Need Expert Help: Winsock/HTTP

Need Expert Help: Winsock/HTTP

I'm writing a small, task-specific web server and seem to be getting
some strange
 events & event sequences on my sockets.  I havn't been able to find
much relevant documentation on HTTP, could anyone help out?

I have a single listening socket, that spawns another socket to accept a
connection, then write out a large (usually 4k to 20k) document.

My event log is looking like this:
****************************************************
Socket          Event
------------   --------
SocketListen   Accept

[create SocketSend1]  Accept Connection on SocketSend1

SocketListen   Write    (???)
SocketListen   Read     (???)  Message: GET /test2.htm HTTP/1.0

SocketSend1    Read     (???) Shouldn't this be where the GET message
is?
SocketSend1    Write    (???)
SocketSend1    Read     (???)
SocketSend1    Write    (???)

SocketSend1    Write    
  Send 256k chunk of document, then wait
  for the next write event to be triggered
  until document is finished.

[Document has been completely sent at this point]

SocketSend1    Write   (???)
****************************************************

The events flagged with (???) don't make sense to me, I think I'm
probably missing a concept or two here.

What would the 'model' HTTP transaction look like for a large document?
I'd appreciate any help!!

db...@alaska.net

 

Re:Need Expert Help: Winsock/HTTP


Quote
David Bush wrote:

> I'm writing a small, task-specific web server and seem to be getting
> some strange
>  events & event sequences on my sockets.  I havn't been able to find
> much relevant documentation on HTTP, could anyone help out?

> ...
> db...@alaska.net

Hello David,

I am not a HTTP guru, but I think you need to have a number of HTTP headers
preceeding your 256k block of data. Such as:

   HTTP/1.0 200 OK
   Date: Sun, 30 Mar 1997 18:35:00
   Server: "your servers id"
   Content-type:  application/octet-stream   (or whatever type you send)
   Content-length: 256000
   Last-modified: Sat, 29 Mar 1997 ...

   data...

The HTTP header needs to be there because the client requested a HTTP ver 1.0
document.

I hope I am not way out of line here..

/Christer

Re:Need Expert Help: Winsock/HTTP


Quote
David Bush <db...@alaska.net> wrote:
>I'm writing a small, task-specific web server and seem to be getting
>some strange
> events & event sequences on my sockets.  I havn't been able to find
>much relevant documentation on HTTP, could anyone help out?

Hypertext Transfer Protocol -- HTTP/1.0
http://www.w3.org/hypertext/WWW/

Quote
>What would the 'model' HTTP transaction look like for a large document?

The HTTP/1.0 document that i have dictates that the protocol uses MIME
headers to facilitate communication. You make no mention of this in
you message, so something seems amiss.

---
RFC 1945, HTTP/1.0, May  1996
       Full-Response   = Status-Line             ; Section 6.1
                             *( General-Header       ; Section 4.3
                             | Response-Header      ; Section 6.2
                             | Entity-Header )      ; Section 7.1
                          CRLF
                           [ Entity-Body ]         ; Section 7.2
---
Mention is made that the 'Simple-Response' was a feature of HTTP/0.9
From the sound of things, you might want to read this document fully
before you continue ;-)

Does the data *have* to be sent to a web-browser, or can the
application you are writing receive the data internally?
Are you writing only the Server, or the client also?
Many questions remain unanswered ;-)

ps: Feel free to mail me if you wish. I have a general interest in
Winsock and http in general. (Notice INTEREST, not skill)

---
Clayton J Andrews (candr...@iafrica.com)
Trac Software Consultants
Gauteng, South Africa

Other Threads