-
Notifications
You must be signed in to change notification settings - Fork 29
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
Allow to extract filename from http request body #1613
Conversation
6e49667
to
03278f9
Compare
test/unit/utils_test.lua
Outdated
} | ||
local payload, err, meta = utils.http_read_body(req) | ||
t.assert_equals(payload, 'Content file') | ||
t.assert_equals(err, nil) |
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.
t.assert_equals(err, nil) | |
t.assert_not(err) |
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.
Applied
test/unit/utils_test.lua
Outdated
'Content-Disposition: form-data; name="file"; filename="sample.txt"\r\n' .. | ||
'Content-Type: text/plain\r\n' .. | ||
'\r\n' .. | ||
'Content file\r\n' .. | ||
'--c187dde3e9318fcc6509f45f76a89424--' |
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.
'Content-Disposition: form-data; name="file"; filename="sample.txt"\r\n' .. | |
'Content-Type: text/plain\r\n' .. | |
'\r\n' .. | |
'Content file\r\n' .. | |
'--c187dde3e9318fcc6509f45f76a89424--' | |
'Content-Disposition: form-data; name="file"; filename="sample.txt"\r\n' .. | |
'Content-Type: text/plain\r\n' .. | |
'\r\n' .. | |
'Content file\r\n' .. | |
'--c187dde3e9318fcc6509f45f76a89424--' |
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.
Applied
test/unit/utils_test.lua
Outdated
|
||
function g.test_http_read_body() | ||
local body = '--c187dde3e9318fcc6509f45f76a89424\r\n'.. | ||
'Content-Disposition: form-data; name="file"; filename="sample.txt"\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.
If I remember correctly, filename is an optional directive. Could you cover a case when there is none?
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.
Good point. Added.
03278f9
to
23ecdd9
Compare
This patch introduces the third argument for metadata of http request parsing (the second is reserved for an error). Before this patch function http_read_body returned only file content. However some of our customers want to know filename as well. It's not so hard to implement because body headers have such info and the main goal of this patch is to implement needed logic for header extraction.
23ecdd9
to
de4b8c8
Compare
This patch introduces the third argument for metadata of http
request parsing (the second is reserved for an error). Before this
patch function http_read_body returned only file content. However
some of our customers want to know filename as well. It's not so
hard to implement because body headers have such info and the main
goal of this patch is to implement needed logic for header
extraction.
Need for https://github.com/tarantool/tdg2/issues/1207