Writing Webserver

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
David_Irving
Forum Newbie
Posts: 8
Joined: Wed Jun 28, 2006 2:55 am

Writing Webserver

Post by David_Irving »

I'm writing a webserver for the heck of it, going quite well ( i don't expect to use it, since i'm a fan of Apache ) and now i'm adding PHP support. Its currently using CGI on it which is cool. I can compiled the requested page and send the output to the client. But now, i'm up to 'client sending the php' back, according to one of my friends who has no idea either. Anyway, i need to work out, what part(s) of this 'message' i need to get compiled by PHP-CGI.exe .

Code: Select all

POST /index.php HTTP/1.1
Host: 127.0.0.1:800
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.4) Gecko/20060508 Firefox/1.5.0.4
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://127.0.0.1:800/index.php
Content-Type: multipart/form-data; boundary=---------------------------265001916915724
Content-Length: 9213

-----------------------------265001916915724
Content-Disposition: form-data; name="single"; filename="AccessibleMarshal.dll"
Content-Type: application/x-msdownload

MZ
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Writing Webserver

Post by alex.barylski »

[quote="David_Irving"]I'm writing a webserver for the heck of it, going quite well ( i don't expect to use it, since i'm a fan of Apache ) and now i'm adding PHP support. Its currently using CGI on it which is cool. I can compiled the requested page and send the output to the client. But now, i'm up to 'client sending the php' back, according to one of my friends who has no idea either. Anyway, i need to work out, what part(s) of this 'message' i need to get compiled by PHP-CGI.exe .

Code: Select all

POST /index.php HTTP/1.1
Host: 127.0.0.1:800
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.4) Gecko/20060508 Firefox/1.5.0.4
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://127.0.0.1:800/index.php
Content-Type: multipart/form-data; boundary=---------------------------265001916915724
Content-Length: 9213

-----------------------------265001916915724
Content-Disposition: form-data; name="single"; filename="AccessibleMarshal.dll"
Content-Type: application/x-msdownload

MZ
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Sessions/Cookies?
David_Irving
Forum Newbie
Posts: 8
Joined: Wed Jun 28, 2006 2:55 am

Post by David_Irving »

okay, I was told it wasn't hard to add PHP to a WebServer as long as i knew how CGI/CLI worked. Now, First when the .php script (+arguments) are requested, the information is sent to my webserver, then the webserver sends it to php-cgi.exe, then the output is sent back to the webserver, then transfered to the client. NEXT, say theres a form, username and password, and a submit button underneath it. Once both forms are filled and the client clicks submit, something similar to what i posted in code tags in post one, is sent to my webserver. I figured some part of it needed to be forwarded to php-cgi.exe, so i had a go at extracting peices of it but no go.

So what am i supposed to do now? Does the server have to handle this part, or does php?

Sorry for the confusion,

Dave

P.S, what i just don't understand is a 52KB Webserver, thats simple and basic and only displays html/php files in the directory, with an icon 34kb big, uses PHP. So i swear php-cgi, must have a role at this part.
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

Well thats totally relative...if you've written a web server 3-4 times...obviously writting one again isn't difficult... :P

I suggest you read this article on how HTTP works...

http://www.codeproject.com/internet/http_calls.asp

Cheers :)
David_Irving
Forum Newbie
Posts: 8
Joined: Wed Jun 28, 2006 2:55 am

Post by David_Irving »

I know how HTTP functions, i don't quite know how PHP functions.. am i to call the php class file? What part am i meant to disect? What part do i compile?

As i said..
IE connects to webserver
Webserver sends welcome page
IE Can click on a link to the php upload file
Webserver gets the upload php script compiled by php-cgi.exe
Output is sent to IE
The user on IE clicks on the button to upload a file located at "C:/whatever.txt"
Information is sent to the Webserver
Webserver refers it to the php script to do what it needs to do x
Done x
Post Reply