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
Feature/range send file #1115
Merged
purplefox
merged 5 commits into
eclipse-vertx:master
from
pmlopes:feature/range-send-file
Aug 19, 2015
Merged
Feature/range send file #1115
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
31a9de9
Implement range support for serving files, this will allow us for exa…
pmlopes b92a11b
do not duplicate content length calculation
pmlopes 55f6b70
Move tests to HTTPTest
pmlopes 9875644
Sync branches
pmlopes dd34c7d
Added documentation
pmlopes File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -262,7 +262,40 @@ public interface HttpServerResponse extends WriteStream<Buffer> { | |
* @return a reference to this, so the API can be used fluently | ||
*/ | ||
@Fluent | ||
HttpServerResponse sendFile(String filename); | ||
default HttpServerResponse sendFile(String filename) { | ||
return sendFile(filename, 0); | ||
} | ||
|
||
/** | ||
* Ask the OS to stream a file as specified by {@code filename} directly | ||
* from disk to the outgoing connection, bypassing userspace altogether | ||
* (where supported by the underlying operating system. | ||
* This is a very efficient way to serve files.<p> | ||
* The actual serve is asynchronous and may not complete until some time after this method has returned. | ||
* | ||
* @param filename path to the file to serve | ||
* @param offset offset to start serving from | ||
* @return a reference to this, so the API can be used fluently | ||
*/ | ||
@Fluent | ||
default HttpServerResponse sendFile(String filename, long offset) { | ||
return sendFile(filename, offset, Long.MAX_VALUE); | ||
} | ||
|
||
/** | ||
* Ask the OS to stream a file as specified by {@code filename} directly | ||
* from disk to the outgoing connection, bypassing userspace altogether | ||
* (where supported by the underlying operating system. | ||
* This is a very efficient way to serve files.<p> | ||
* The actual serve is asynchronous and may not complete until some time after this method has returned. | ||
* | ||
* @param filename path to the file to serve | ||
* @param offset offset to start serving from | ||
* @param length length to serve to | ||
* @return a reference to this, so the API can be used fluently | ||
*/ | ||
@Fluent | ||
HttpServerResponse sendFile(String filename, long offset, long length); | ||
|
||
/** | ||
* Like {@link #sendFile(String)} but providing a handler which will be notified once the file has been completely | ||
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. e.g. here's an example of using {@link} |
||
|
@@ -273,7 +306,36 @@ public interface HttpServerResponse extends WriteStream<Buffer> { | |
* @return a reference to this, so the API can be used fluently | ||
*/ | ||
@Fluent | ||
HttpServerResponse sendFile(String filename, Handler<AsyncResult<Void>> resultHandler); | ||
default HttpServerResponse sendFile(String filename, Handler<AsyncResult<Void>> resultHandler) { | ||
return sendFile(filename, 0, resultHandler); | ||
} | ||
|
||
/** | ||
* Like {@link #sendFile(String, long)} but providing a handler which will be notified once the file has been completely | ||
* written to the wire. | ||
* | ||
* @param filename path to the file to serve | ||
* @param offset the offset to serve from | ||
* @param resultHandler handler that will be called on completion | ||
* @return a reference to this, so the API can be used fluently | ||
*/ | ||
@Fluent | ||
default HttpServerResponse sendFile(String filename, long offset, Handler<AsyncResult<Void>> resultHandler) { | ||
return sendFile(filename, offset, Long.MAX_VALUE, resultHandler); | ||
} | ||
|
||
/** | ||
* Like {@link #sendFile(String, long, long)} but providing a handler which will be notified once the file has been | ||
* completely written to the wire. | ||
* | ||
* @param filename path to the file to serve | ||
* @param offset the offset to serve from | ||
* @param length the length to serve to | ||
* @param resultHandler handler that will be called on completion | ||
* @return a reference to this, so the API can be used fluently | ||
*/ | ||
@Fluent | ||
HttpServerResponse sendFile(String filename, long offset, long length, Handler<AsyncResult<Void>> resultHandler); | ||
|
||
/** | ||
* Close the underlying TCP connection corresponding to the request. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
When creating an overloaded method, instead of duplicating the javadoc, it's preferable to use {@link} to refer to the version with the full javadoc and just explain the differences.