-
Notifications
You must be signed in to change notification settings - Fork 88
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
Add support for fixed ContentLength #32
base: main
Are you sure you want to change the base?
Changes from 4 commits
0a00d7b
9c518a4
a23d56a
a5754cf
9940d3c
9daad1e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,7 +77,8 @@ private void openConnection() throws IOException, ProtocolException { | |
} | ||
|
||
connection.setDoOutput(true); | ||
connection.setChunkedStreamingMode(0); | ||
if (client.chunkedTransferEncoding()) | ||
gbonnefille marked this conversation as resolved.
Show resolved
Hide resolved
|
||
connection.setChunkedStreamingMode(0); | ||
try { | ||
output = connection.getOutputStream(); | ||
} catch(java.net.ProtocolException pe) { | ||
|
@@ -176,7 +177,15 @@ public int getRequestPayloadSize() { | |
public int uploadChunk() throws IOException, ProtocolException { | ||
openConnection(); | ||
|
||
int bytesToRead = Math.min(getChunkSize(), bytesRemainingForRequest); | ||
final int bytesToRead; | ||
if (client.chunkedTransferEncoding()) | ||
bytesToRead = Math.min(getChunkSize(), bytesRemainingForRequest); | ||
else { | ||
// No chunked tranfer encoding, so we upload a single chunk. | ||
bytesToRead = getChunkSize(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there is still some confusion about the chunk size vs payload size. Traditionally the payload size determines how big the body of a HTTP can get. The chunk size on the other hand says, how much data is read from the input stream and written to the TCP connection in one iteration. Usually, you write multiple chunks per HTTP request, so the payload size is bigger than the chunk size. However, if I understand this correctly, the chunk size now determines how big a HTTP request gets and the payload size is not used anymore. This would be contrary to how tus-java-client behaves when chunked transfer is enabled. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did the opposite reasoning: Furthermore, as a dumb user, I only wish things work without having to fine tune chunk size or payload size, depending on the server's capabilities. I like automagical approach. :-) But I'm completly new to all of this. So I don't know what sort of logic is expected. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That's not entirely true. The reason for chunk size is that the user can control how much data is read from the input source in one go. This is important to control how big the in-memory buffer of tus-java-client is, in order to avoid excess memory usage. You are referring to the payload size when you say "something [e.g. a proxy] in the chain does not support more than that". Does that make sense?
Yes, I would like that as well and it will likely come in the next major release but not right now :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
OK, so you state that client (memory) is "something in the chain does not support more than that", first part of the chain. |
||
// The connection should be closed after single write. | ||
bytesRemainingForRequest = 0; | ||
} | ||
|
||
int bytesRead = input.read(buffer, bytesToRead); | ||
if(bytesRead == -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.
Could you expand the comment a bit to explain what the advantages/disadvantages/impacts of enabling/disabling chunked transfer encoding has?