I have a socket server, and I am having a problem at the moment...
A browser sends a http header request to the server, but... some browsers send one request for one file, and others want 2. For example, Google Chrome asks for two parts: The headers, and the post data.
Whereas Firefox sends it all at once.
Chrome Part 1:
Code: POST /postdata.php HTTP/1.1
Host: localhost:3333
User-Agent: Some Chrome string here
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
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://localhost:3333/postdata.php
Chrome Part 2:
Code: ------WebKitFormBoundaryHigb2TwanNRf4WQK
Content-Disposition: form-data; name="name"
ryan
------WebKitFormBoundaryHigb2TwanNRf4WQK
Content-Disposition: form-data; name="comment"
hello
------WebKitFormBoundaryHigb2TwanNRf4WQK
Content-Disposition: form-data; name="myFile"; filename="test.txt"
Content-Type: text/plain
hello! This is a test document!
Line 2
Line 3
Line 5
Line 6
End File!
------WebKitFormBoundaryHigb2TwanNRf4WQK
Content-Disposition: form-data; name="submit"
Post It!
------WebKitFormBoundaryHigb2TwanNRf4WQK--
Firefox Whole thing:
Code: POST /postdata.php HTTP/1.1
Host: localhost:3333
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 GTB5
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
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://localhost:3333/postdata.php
Content-Type: multipart/form-data; boundary=---------------------------491299511942
Content-Length: 566
-----------------------------491299511942
Content-Disposition: form-data; name="name"
ryan
-----------------------------491299511942
Content-Disposition: form-data; name="comment"
adfafqa
-----------------------------491299511942
Content-Disposition: form-data; name="myFile"; filename="test.txt"
Content-Type: text/plain
hello! This is a test document!
Line 2
Line 3
Line 5
Line 6
End File!
-----------------------------491299511942
Content-Disposition: form-data; name="submit"
Now the problem is that since firefox sends it once, my code makes Firefox hang because I have two socket_recv() one for the headers, and one for the post data, where the second socket_recv() just sits and waits but nothing is sent to it. In Chrome this works just fine, because data is send at two different times (headers and post data).
I don't really want to write code that checks a browser to see what the browser is and do something according the browser type, so is there a better way then what I have to get the data no matter what browser the user is using, and the code doesn't hang if the browser only sends headers once?
socket_recv($client, $headers, $max_post_size, 0);
if(preg_match("~^POST~", $headers)){
socket_recv($client, $post, $max_post_size, 0);
}else{
$post = '';
}
[Need Help] php timing issues
I don't know what is going wrong. I need some help with being able to set an image at 9:00am Colorado time if my server is in California and it would be 8:00am. I tried to echo the image below, but
UDP server recvfrom() always returns -1? :(
Hello all,I am getting a very strange error in my code :( I am writing a server application in C, to send and receive UDP packets to/from a client. Right now, im just running a loop in which the
Tree Menu
Hi guys,Can anyone help me making a tree navigation system? I have a site where I'm allowing users to upload their files to share with each other. They can create folders, but I'm having real
foreach loop, assistance request
I would like some guidance on the usage of foreach as I try to parse through a large database and whittle down to a few select stocks. I'm currently doing this with vb, but I'm wanting to get it
Just cannot get 'area' to submit to db using same php code as already used
Basically all i have done is just modified some code and added an area section.The form is allready submitting other things like location price etc.And i have simply added a field in db called area
Downloading file (Headers)
I'm trying to make users download a file, but they must wait 60 seconds before it begins.But, I'm stuck - the file isn't downloading, and no error is being shown (I've enabled E_ALL error
JQuery, Masterpage, and Control issue
Hey everyone, I am using JQuery in several sites so I thought it would be best to place the library reference in the masterpage. It works great everywhere, except when my javascrip is called from
PHP Upload issue
Hi guys,I have stumble across an interesting issue with my script and is doing my head in.A little background on the application.I've got a document repository site which uses Jupload to upload
post to self
Trying to get my form to submit to itself. However I am also trying to use an image for my submit button, when I set the type='image' it will not submit to itself. Can someone help me figure out
Help With Showing Users On the Index Page
Ive got this code which works just how i want it to.Code: <? $timenow=time();$select = mysql_query("SELECT * FROM users WHERE online > '$timenow' ORDER by id ASC");$num =