Skip to content
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

Support incorrect deflate content encoding that browser is supporting #1019

Closed
heroboy opened this issue Sep 3, 2021 · 9 comments
Closed
Labels
bug Something isn't working enhancement New feature or request good first issue Good for newcomers Status: help-wanted This issue/pr is open for contributions

Comments

@heroboy
Copy link

heroboy commented Sep 3, 2021

Look at the code.

  1. Use the deflateRawSync is not conform to the http standard. But most browser can correctly open it.
  2. The error AboutError is not clearly.
  3. I have a question. Why undici.request not support deflate encoding?
const zlib = require('zlib');
const http = require('http');
const undici = require('undici');
let server = http.createServer((req, res) =>
{
	console.log('request');
	res.writeHead(200, { 'Content-Type': 'text/plain', 'content-encoding': 'deflate' });
	res.end(zlib.deflateRawSync('abc'));
	//res.end(zlib.deflateSync('abc'));
});
server.listen(8989, '0.0.0.0', async function ()
{
	try
	{
		let resp = await undici.fetch('http://127.0.0.1:8989');
		let text = await resp.text();
		console.log(text);
	}
	catch (e)
	{
                //AbortError: The operation was aborted
		console.log('request error');
		console.log(e);
	}
});
@heroboy heroboy added the enhancement New feature or request label Sep 3, 2021
@ronag
Copy link
Member

ronag commented Sep 3, 2021

PR welcome

@ronag ronag added Status: help-wanted This issue/pr is open for contributions bug Something isn't working labels Sep 3, 2021
@ronag
Copy link
Member

ronag commented Sep 3, 2021

The AbortError seems like a bug. Should probably be another error. So this issue is actually 2 different problems.

@heroboy
Copy link
Author

heroboy commented Sep 3, 2021

@szmarczak
Copy link
Member

I'm -1 on this one. https://datatracker.ietf.org/doc/html/rfc7230#section-4.2.2

The "deflate" coding is a "zlib" data format
[...]
Note: Some non-conformant implementations send the "deflate"
compressed data without the zlib wrapper.

@heroboy
Copy link
Author

heroboy commented Sep 4, 2021

But can we just add a flag, just like the strictContentLength.

@ronag
Copy link
Member

ronag commented Sep 13, 2021

@mcollina
Copy link
Member

I think those http servers are still around, so we should unfortunately support it.

I would mark this as "good first issue", so if somebody needs this they know they can implement it.

@ronag ronag added the good first issue Good for newcomers label Sep 13, 2021
@edward0414
Copy link

This issue is the same as the one linked below.
#2128

@Uzlopak
Copy link
Contributor

Uzlopak commented Jan 27, 2024

This can be closed. I had a wrong issue linked with my PR #2650

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request good first issue Good for newcomers Status: help-wanted This issue/pr is open for contributions
Projects
None yet
Development

No branches or pull requests

6 participants