Skip to content

Refactor Parsing Content Encoding Http Headers #15245

Open
Hrushi20 wants to merge 3 commits intoNixOS:masterfrom
Hrushi20:parse-filetransfer-encoding
Open

Refactor Parsing Content Encoding Http Headers #15245
Hrushi20 wants to merge 3 commits intoNixOS:masterfrom
Hrushi20:parse-filetransfer-encoding

Conversation

@Hrushi20
Copy link

@Hrushi20 Hrushi20 commented Feb 15, 2026

Support parsing following encodings in case-insensitive manner -
gzip, x-gzip, compress, x-compress, br, zstd, bzip2, and identity

Throw Exception for Stacked/Unsupported encodings.

Based on conversation #15238

Signed-off-by: Hrushi20 <hrushikesh20thegreat@gmail.com>
Signed-off-by: Hrushi20 <hrushikesh20thegreat@gmail.com>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will refactor the function to return CompressionAlgo instead of string based on #15238

@xokdvium
Copy link
Contributor

Also fixes #14324

@xokdvium
Copy link
Contributor

Could you also run maintainers/format.sh to make clang-format happy?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
throw nix::Error("Stacked contentEncoding is not supported: %s", contentEncoding);
throw nix::Error("Stacked Content-Encoding is not supported: %s", contentEncoding);


else if (name == "content-encoding")
encoding = trim(line.substr(i + 1));
encoding = parseContentEncoding(toLower(trim(line.substr(i + 1))));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a comment referring to the spec paragraph about case insensitivity?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this.

Copy link
Contributor

@xokdvium xokdvium left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also modify Accept-Encoding to not send xz as it's really not supported by anything out there?

Comment on lines 296 to 297
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should have a placeholder for deflate and/or check if it's really broken? I have a suspicion that it is, but would be nice to check. There's already some infra in content-encoding.nix test for testing various compression methods. Could be hard to check it with nginx's support for deflate.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or I can add a placeholder for deflate for now.

@Hrushi20 Hrushi20 closed this Feb 15, 2026
@Hrushi20
Copy link
Author

Should we also modify Accept-Encoding to not send xz as it's really not supported by anything out there?

We can remove xz from accept-encoding as we are removing support from content-encoding.

@xokdvium
Copy link
Contributor

Closed accidentally?

@Hrushi20 Hrushi20 reopened this Feb 15, 2026
…, run clang-formatter

Signed-off-by: Hrushi20 <hrushikesh20thegreat@gmail.com>
@Hrushi20
Copy link
Author

Yeah. Laptop slipped from my hand and accidentally closed the PR 🙃

@Hrushi20
Copy link
Author

Should we also modify Accept-Encoding to not send xz as it's really not supported by anything out there?

Removed xz from Accept-Encoding.

result.urls.push_back(effectiveUriCStr);
}

std::string parseContentEncoding(std::string_view contentEncoding)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be static?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments