-
Notifications
You must be signed in to change notification settings - Fork 866
accept "default" keyword in extension directive #1414
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
Conversation
kazuho
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR. It looks mostly fine.
I have left in-line comments. Please let me know what you think.
| if (strcmp(node->data.scalar, "default") == 0) { | ||
| return node->data.scalar; | ||
| } else if (assert_is_extension(cmd, node) == 0) { | ||
| return node->data.scalar + 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function seems to either return "default" or return the extension stripping the preceding dot.
Does the fact mean that we can no longer register .default as an extension?
t/50file-file.t
Outdated
| my ($proto, $port, $cmd) = @_; | ||
| my $resp = `$cmd --silent $proto://127.0.0.1:$port/robots.txt?name=Tobor`; | ||
| is $resp, "Hello Tobor"; | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test tests if the custom handler works well with file.file.
Could we also have a test case that maps all files under a directory to CGI? To rephrase, I would appreciate it if we could have a test case covering the use-case of SetHandler cgi-script in Apache.
<Directory "/home/*/public_html/cgi-bin">
Options ExecCGI
SetHandler cgi-script
</Directory>
lib/core/configurator.c
Outdated
| h2o_configurator_errprintf(cmd, node, "given extension \"%s\" does not start with a \".\"", node->data.scalar); | ||
| return -1; | ||
| } | ||
| if (strlen(node->data.scalar) == 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is definitely a nitpick, but how about changing to node->data.scalar[1] == '\0'?
lib/core/configurator.c
Outdated
| return 0; | ||
| } | ||
|
|
||
| static const char *get_ext(h2o_configurator_command_t *cmd, yoml_t *node) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about changing the name of the function to normalize_ext or something?
| my $server = spawn_h2o(<< "EOT"); | ||
| file.custom-handler: | ||
| extension: ["default", ".cgi"] | ||
| fastcgi.spawn: "exec \$H2O_ROOT/share/h2o/fastcgi-cgi" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use possibly do file.mime.settypes: {} as well to reset the existing mime-type here, and see that a file with .html extension gets treated as a CGI?
e6b4076 to
e84b551
Compare
3653f6f to
b0b7701
Compare
|
Thank you for the changes. |
Related to #1371, this PR allows h2o to assign custom handler to the files with no extension.
As an example: