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 = '';
}
Xml parsing
I need a suggestion about parsing xml with multiply parts like pervious... i.e. different devices has a similar configuration, but how I can discern it by device? Code: <config><device
What am I missing here? Help!
Hello all!. I can't seem to get this working right. Well - it renders right, but something is going wrong. It's a set of filters for events. The filter marked "type" (category) works
exclude characters from counting?
Hello, I wanted to ask if you have a string like:Code: $my_s='ASRGREGTGTR----REGREGRE+++RRRRRR....';is there a way to count the length of the string, excluding non-word characters (+,- or .)?thank you
Displaying different page content, depending on the logged in user.
Hi all, I am new to ASP.net (and web development in general), and have a question about how I can display different page content depending on the current user.I wish to create a digg style social news
Problem writing URL into database
How would I write this into the database?<?php echo "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; ?>I tried this:Code: $url =
Simple Question
I know this is a simple question, that if I knew what it was technically called i could probably look up and find the answer for myself. However, I don't know what its called, and of all the books I
Simple image grab script.
I was wondering if it was possible and if anyone knew how to make a simple php script that looks at one specified directory and makes <img src="*.*" \> type links out of it?ive
Table sorting
Hi,I'm trying to modify the following in order to make the output table sorted alphabetically according to $event_name but so far have not succeeded. Any pointers?Code: function display_all_events(){
Business Health Check
Hello I need to create an online business health check for a client it will be multiple choice and about 50 questions but the client has requested that the output/results of the health check needs to
Sufficient protection from bad input?
I am writing a simple script to let people upload 'pages' of their own content, be it simply a few bits of HTML, pictures and whatnot, and recieve their own url.. I've without testing, wrote this part