How does HTTP file upload work?

Let’s take a look at what happens when you select a file and submit your form (I’ve truncated the headers for brevity): POST /upload?upload_progress_id=12344 HTTP/1.1 Host: localhost:3000 Content-Length: 1325 Origin: http://localhost:3000 … other headers … Content-Type: multipart/form-data; boundary=—-WebKitFormBoundaryePkpFF7tjBAqx29L ——WebKitFormBoundaryePkpFF7tjBAqx29L Content-Disposition: form-data; name=”MAX_FILE_SIZE” 100000 ——WebKitFormBoundaryePkpFF7tjBAqx29L Content-Disposition: form-data; name=”uploadedfile”; filename=”hello.o” Content-Type: application/x-object … contents of file goes … Read more

What’s the difference between Cache-Control: max-age=0 and no-cache?

I had this same question, and found some info in my searches (your question came up as one of the results). Here’s what I determined… There are two sides to the Cache-Control header. One side is where it can be sent by the web server (aka. “origin server”). The other side is where it can … Read more

Error: request entity too large

I had the same error recently, and all the solutions I’ve found did not work. After some digging, I found that setting app.use(express.bodyParser({limit: ’50mb’})); did set the limit correctly. When adding a console.log(‘Limit file size: ‘+limit); in node_modules/express/node_modules/connect/lib/middleware/json.js:46 and restarting node, I get this output in the console: Limit file size: 1048576 connect.multipart() will be … Read more

How do I send a POST request with PHP?

CURL-less method with PHP5: $url=”http://server.com/path”; $data = array(‘key1’ => ‘value1’, ‘key2’ => ‘value2’); // use key ‘http’ even if you send the request to https://… $options = array( ‘http’ => array( ‘header’ => “Content-type: application/x-www-form-urlencoded\r\n”, ‘method’ => ‘POST’, ‘content’ => http_build_query($data) ) ); $context = stream_context_create($options); $result = file_get_contents($url, false, $context); if ($result === FALSE) … Read more

How do I implement basic “Long Polling”?

It’s simpler than I initially thought.. Basically you have a page that does nothing, until the data you want to send is available (say, a new message arrives). Here is a really basic example, which sends a simple string after 2-10 seconds. 1 in 3 chance of returning an error 404 (to show error handling … Read more

Are HTTP headers case-sensitive?

Header names are not case sensitive. From RFC 2616 – “Hypertext Transfer Protocol — HTTP/1.1”, Section 4.2, “Message Headers”: Each header field consists of a name followed by a colon (“:”) and the field value. Field names are case-insensitive. The updating RFC 7230 does not list any changes from RFC 2616 at this part.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)