-
Notifications
You must be signed in to change notification settings - Fork 110
feat: add max_header_len
& validate_handshake
options
#94
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
base: master
Are you sure you want to change the base?
Conversation
884133b
to
9710364
Compare
- Added `max_header_len` option to limit the maximum allowed header size during the WebSocket upgrade process. - Added `validate_handshake` option to enforce that the WebSocket handshake response must return HTTP 101. - Improved HTTP response parsing by checking the status line and extracting response headers properly. - Added new test cases
9710364
to
2db11ae
Compare
m, err = re_match(header, [[^\s*HTTP/1\.1\s+]], "jo") | ||
if not m then | ||
-- Validate HTTP status line. | ||
local status_line_end = header:find("\r?\n") |
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.
use nginx.re to get the status code directly.
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.
Thanks for the review. Are you stating that you wish to revert to the previous re_match()
behavior & not validate the HTTP status line per HTTP spec?
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 original implementation is more efficient and already meets the requirements, so we can keep it as is.
^error: "response headers too large \(limit: 1024 bytes\)" | ||
--- no_error_log | ||
[error] | ||
[warn] |
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.
require a newline at the end of file.
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.
Will update, thanks!
m, err = re_match(header, [[^\s*HTTP/1\.1\s+]], "jo") | ||
if not m then | ||
-- Validate HTTP status line. | ||
local status_line_end = header:find("\r?\n") |
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 original implementation is more efficient and already meets the requirements, so we can keep it as is.
Introducing new functionality to add two new options to
client:new()
. Changes have been implemented in a way to retain backward compatibility.max_header_len
option to limit the maximum allowed header size during the WebSocket upgrade process.validate_handshake
option to enforce that the WebSocket handshake response must return HTTP 101.Not all existing tests are passing, but that's unrelated to this improvement. I had to re-generate a new certificate to get Nginx happy, this likely should be fixed in another pull request & add the below to the
Makefile
:$ openssl req -new -key test.key -out test.csr -subj "/C=US/ST=California/L=San Francisco/O=OpenResty/OU=OpenResty/CN=test.com/emailAddress=agentzh@gmail.com" $ openssl x509 -req -days 365 -in test.csr -signkey test.key -out test.crt
Thanks for considering this change!