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

Can not return {header, {accept_ranges, "bytes"}} #352

Closed
leoliu opened this issue Dec 7, 2018 · 8 comments
Closed

Can not return {header, {accept_ranges, "bytes"}} #352

leoliu opened this issue Dec 7, 2018 · 8 comments

Comments

@leoliu
Copy link
Contributor

leoliu commented Dec 7, 2018

Returning {header, {accept_ranges, "bytes"}} from out/1 causes a crash:

Yaws process died: {function_clause,
                       [{yaws,accumulate_header,
                            [{accept_ranges,"bytes"}],
                            [{file,"yaws.erl"},{line,1916}]},
                        {yaws_server,deepforeach,2,
                            [{file,"yaws_server.erl"},{line,1429}]},
                        {yaws_server,handle_ut,4,
                            [{file,"yaws_server.erl"},{line,2295}]},
                        {yaws_server,handle_method_result,7,
                            [{file,"yaws_server.erl"},{line,1408}]},
                        {yaws_server,acceptor0,2,
                            [{file,"yaws_server.erl"},{line,1074}]},
                        {proc_lib,init_p_do_apply,3,
                            [{file,"proc_lib.erl"},{line,249}]}]}
@vinoski
Copy link
Collaborator

vinoski commented Dec 7, 2018

The accept_ranges header is not documented as a header that Yaws treats specially, so you must specify it as a string, not an atom:

{header, {"Accept-Ranges", "bytes"}}

See the yaws_api(5) man page or the yaws pdf documentation, section 7.6 for a list of headers for which Yaws allows atom names.

@leoliu
Copy link
Contributor Author

leoliu commented Dec 8, 2018

accept_ranges appears in #headers but not #outh in yaws.hrl.

@vinoski
Copy link
Collaborator

vinoski commented Dec 8, 2018

Correct, which is why it'll work fine if you specify it as a string. And even if I add it to #outh, specifying it as a string will still work.

@leoliu
Copy link
Contributor Author

leoliu commented Dec 9, 2018

But it is a bit confusing though where you can specify the atom accept_range when reading but not when writing the header.

@vinoski vinoski closed this as completed in 62279e7 Dec 9, 2018
@leoliu
Copy link
Contributor Author

leoliu commented Dec 9, 2018

Thanks, @vinoski.

@leoliu
Copy link
Contributor Author

leoliu commented Dec 10, 2018

Hi @vinoski

I just discovered something unusual after the change. The following no longer outputs the accept-ranges header. But if I revert to 576ba9c5dd7233ee061a85245475c90edf332378 it works again.

{page, {[{header, {"Accept-Ranges", <<"bytes">>}}], Page}}

vinoski added a commit that referenced this issue Dec 10, 2018
Add a new unit test for accept_ranges to return both atom form and
string form for the header and verify the presence of "Accept-Ranges"
in the response.
@vinoski
Copy link
Collaborator

vinoski commented Dec 10, 2018

Thanks, this was my mistake. Fixed on master now, and with a new unit test.

@leoliu
Copy link
Contributor Author

leoliu commented Dec 10, 2018

Thanks for the fix.

vladdu pushed a commit to vladdu/yaws that referenced this issue Jan 26, 2021
Add special treatment for the atom accept_ranges in output header
specifications for setting the standard "Accept-Ranges" header. Add
accept_ranges to the documentation.
vladdu pushed a commit to vladdu/yaws that referenced this issue Jan 26, 2021
Add a new unit test for accept_ranges to return both atom form and
string form for the header and verify the presence of "Accept-Ranges"
in the response.
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

No branches or pull requests

2 participants