Skip to content

Fix response header for content served via jekyll serve#8965

Merged
jekyllbot merged 7 commits intojekyll:masterfrom
ashmaroli:fix-local-webserver-response-content-type
Feb 25, 2022
Merged

Fix response header for content served via jekyll serve#8965
jekyllbot merged 7 commits intojekyll:masterfrom
ashmaroli:fix-local-webserver-response-content-type

Conversation

@ashmaroli
Copy link
Copy Markdown
Member

  • This is a 🐛 bug fix.

Summary

Use script/vendor-mimes to generate a JSON version of the data used to generate lib/jekyll/mime.types and use that JSON during jekyll serve to determine whether charset= has to be injected to the "content-type " in the response-header.

  • Enhance script/vendor-mimes to generate lib/jekyll/commands/serve/mime_types.json.
  • Enhance script/vendor-mimes to log statements during runtime.
  • Update servlet to use generated JSON file during jekyll serve.
  • Update lib/jekyll/mime.types with current data at upstream repository.

Context

Closes #8938
Resolves #8936

@ashmaroli ashmaroli requested review from mattr- and parkr February 10, 2022 16:45
Copy link
Copy Markdown
Member

@parkr parkr left a comment

Choose a reason for hiding this comment

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

This is great, thank you! My primary feedback is to consider slimming down the database to just the data we need. More detailed comment left in-line.

ashmaroli and others added 3 commits February 11, 2022 16:15
emulating Jekyll's DataReader
Co-authored-by: Parker Moore <237985+parkr@users.noreply.github.com>
Copy link
Copy Markdown
Member

@parkr parkr left a comment

Choose a reason for hiding this comment

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

Thanks for updating! I like the smaller list. Oddly... it feels like we're missing some MIME types like text/html which are clearly text-based and would likely . 🤔 Left a comment inline.


config = File.expand_path "../lib/jekyll/mime.types", __dir__
File.write(config, output)
log_info "Done! See: #{config.inspect.white}"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For the other file, you have log_success when you've completed. Should you use log_success here, too?

Screen Shot 2022-02-11 at 10 08 05 AM

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It was initially. =)
But the green in the middle kinda felt like it broke the flow for me.. :)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

:)

@ashmaroli
Copy link
Copy Markdown
Member Author

it feels like we're missing some MIME types like text/html which are clearly text-based and would likely...

Yeah. I agree.
But that's how the upstream JSON database is..

@parkr
Copy link
Copy Markdown
Member

parkr commented Feb 14, 2022

The DB provides the default charset that IANA specified for a MIME type. This code was introduced to fix the bug where a lot of text documents don't have a default charset (which generally means it uses ASCII). I think we found a good solution for adding the charset to files with characters (text files mostly) and remove the charset header from files without characters like WASM. Great work! 👍

@parkr
Copy link
Copy Markdown
Member

parkr commented Feb 25, 2022

@jekyllbot: merge +fix

@jekyllbot jekyllbot merged commit 034d3e9 into jekyll:master Feb 25, 2022
jekyllbot added a commit that referenced this pull request Feb 25, 2022
github-actions bot pushed a commit that referenced this pull request Feb 25, 2022
Ashwin Maroli: Fix response header for content served via `jekyll serve` (#8965)

Merge pull request 8965
parkr pushed a commit that referenced this pull request Feb 26, 2022
@ashmaroli ashmaroli deleted the fix-local-webserver-response-content-type branch February 27, 2022 09:21
parkr pushed a commit that referenced this pull request Feb 27, 2022
ashmaroli added a commit that referenced this pull request Feb 28, 2022
Backport #8965 for v3.9.x: Fix response header for content served via `jekyll serve`
@jekyll jekyll locked and limited conversation to collaborators Feb 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: jekyll serve sets the wrong content type for .wasm files

4 participants