-
Notifications
You must be signed in to change notification settings - Fork 80
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
Improve Request Handling on Requests with Trailing Headers #8753
base: master
Are you sure you want to change the base?
Conversation
Attached printing from the logs as an example: In the headers of the request we can see
We added some printings in the function
The client is using PutObject with body "body for example", it is 16 characters (decimal) in hexadecimal base it is 10.
|
057ec16
to
d7251c3
Compare
…AD-TRAILER, STREAMING-AWS4-HMAC-SHA256-PAYLOAD-TRAILER) Signed-off-by: shirady <[email protected]>
…he end instead of failing it) Signed-off-by: shirady <[email protected]>
Signed-off-by: shirady <[email protected]>
Signed-off-by: shirady <[email protected]>
Signed-off-by: shirady <[email protected]>
Signed-off-by: shirady <[email protected]>
a12235c
to
385f83c
Compare
this.chunk_size -= content.length; | ||
index += content.length - 1; | ||
if (content.length) this.push(content); | ||
if (!this.chunk_size) this.state = STATE_WAIT_CR_DATA; | ||
if (!this.chunk_size) { | ||
this.state = this.last_chunk ? STATE_READ_TRAILER_DATA : STATE_WAIT_CR_DATA; |
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.state = this.last_chunk ? STATE_READ_TRAILER_DATA : STATE_WAIT_CR_DATA; | |
this.state = this.last_chunk ? STATE_CHECK_TRAILER : STATE_WAIT_CR_DATA; |
this.state = STATE_WAIT_NL_TRAILER; | ||
break; | ||
} | ||
this.chunk_trailer_str = buf.toString('utf8', start_trailer, index); |
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.
since it might overlap a buffer, we need to append the string
this.chunk_trailer_str = buf.toString('utf8', start_trailer, index); | |
this.chunk_trailer_str += buf.toString('utf8', start_trailer, index); |
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.
also this needs to be outside the loop...
} | ||
} else if (this.state === STATE_WAIT_NL_TRAILER) { | ||
if (buf[index] !== NL_CODE) return this.error_state(); | ||
this.trailers.push(this.chunk_trailer_str); |
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.
also need to set chunk_trailer_str to '' here.
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.
I would write like this
this.trailers.push(this.chunk_trailer_str); | |
if (this.chunk_trailer_str) { | |
this.trailers.push(this.chunk_trailer_str); | |
this.chunk_trailer_str = ''; | |
} |
Explain the changes
STREAMING-UNSIGNED-PAYLOAD-TRAILER
,STREAMING-AWS4-HMAC-SHA256-PAYLOAD-TRAILER
), as without those headers on clients that add the checksum headers with trailing we would fail.if (header_items[1])
to make sure we won't run thesplit
function onundefined
value.slice
function withsubarray
as the functionslice
was deprecated (see reference).Issues:
List of GAPs:
STATE_WAIT_NL_DATA
just to avoid the parsing from failing, but we need to improve it and ensure that it is the trailer that we expect to see according to the request header (else we shouldreturn this.error_state();
).Testing Instructions:
go run script/client_script.go -bucket fourteen.bucket -key test-key -mpu test-mpu-key -endpoint "https://localhost:12443" -disable-deletion
and expect to see all tests passing: