Welcome to the chicken scheme pasting service

http-client slow with 304 response code added by caolanm on Wed Aug 23 10:00:20 2017

caolan@caolan-laptop:~/Desktop$ cat server.js 
var http = require('http');

var server = http.createServer(function (req, res) {
	if (req.url == '/200.html') {
		res.writeHead(200, { 'Content-Type': 'text/plain' });
		res.end('ok\n');
	}
	if (req.url == '/304.html') {
		res.writeHead(304, { 'Content-Type': 'text/plain' });
		res.end('not modified\n');
	}
});

server.listen(8080);


caolan@caolan-laptop:~/Desktop$ cat example200.scm 
(use http-client intarweb uri-common utils)

(receive (body final-uri response)
  (call-with-response
    (make-request
      method: 'GET
      uri: (uri-reference "http://localhost:8080/200.html"))
    (lambda (request) #f)
    (lambda (response)
      (read-all (response-port response))))
  (display body))


caolan@caolan-laptop:~/Desktop$ cat example304.scm 
(use http-client intarweb uri-common utils)

(receive (body final-uri response)
  (call-with-response
    (make-request
      method: 'GET
      uri: (uri-reference "http://localhost:8080/304.html"))
    (lambda (request) #f)
    (lambda (response)
      (read-all (response-port response))))
  (display body))


caolan@caolan-laptop:~/Desktop$ time csi -s example200.scm 
ok

real	0m0.176s
user	0m0.168s
sys	0m0.004s


caolan@caolan-laptop:~/Desktop$ time csi -s example304.scm 

real	0m5.193s
user	0m0.176s
sys	0m0.008s


caolan@caolan-laptop:~/Desktop$ time curl http://localhost:8080/200.html
ok

real	0m0.010s
user	0m0.004s
sys	0m0.000s


caolan@caolan-laptop:~/Desktop$ time curl http://localhost:8080/304.html

real	0m0.010s
user	0m0.004s
sys	0m0.000s

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
Type in the text below:
 _           _         _   
| |__   ___ | | ____ _| |_ 
| '_ \ / _ \| |/ / _` | __|
| |_) | (_) |   < (_| | |_ 
|_.__/ \___/|_|\_\__, |\__|
                 |___/     
Visually impaired? Let me spell it for you (wav file) download WAV