New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new test: chunked response #5

Closed
Geal opened this Issue Oct 3, 2018 · 4 comments

Comments

Projects
None yet
2 participants
@Geal
Member

Geal commented Oct 3, 2018

  • the client does a GET / request
  • the server sends a file as chunked response
  • the client receives all the packets and verify the file hash (we should have received the entire file)

it might be interesting to have variations in chunk size and frequency (example: send some 1 byte chunks, or wait a few milliseconds before sending the next chunk)

@Geal

This comment has been minimized.

Member

Geal commented Oct 3, 2018

example server code:

const fs = require('fs');

require('http').createServer((req, res) => {
  console.log(req.method);
  console.log(req.headers);
	if (req.method === 'POST') {
		let body = '';
		req.on('data', chunk => {
			console.log("received chunk: "+chunk.length);
			//console.log("chunk");
			body += chunk.toString(); // convert Buffer to string
		});
		req.on('end', () => {
			console.log("end");
			//console.log(body);
			res.end('ok');
		});
	} else {
		//console.log(req);
		//req.pipe(res);
		const src = fs.createReadStream('../lib/src/network/protocol/http.rs', { highWaterMark: 4096 });
		//src.pipe(res);
		src.on('data', (chunk) => {
			console.log("chunk: "+chunk.length);
			res.write(chunk);
		});
		src.on('end', () => {
			console.log("end");
			res.end();
		})
	}
}).listen(1026);

@NotBad4U NotBad4U added this to the first test suite milestone Oct 5, 2018

@NotBad4U

This comment has been minimized.

Member

NotBad4U commented Oct 11, 2018

Done in f421858

@NotBad4U

This comment has been minimized.

Member

NotBad4U commented Nov 7, 2018

I close this one with the merge of #23

@NotBad4U NotBad4U reopened this Nov 7, 2018

@NotBad4U NotBad4U closed this Nov 7, 2018

@Geal

This comment has been minimized.

Member

Geal commented Nov 7, 2018

technically, this does not verify that the response is chunked, only the presence of the header. But if the client is spec compliant it should refuse a content that is not chunked.
Also, there should be no Content-length header in a chunked response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment