Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/main/java/co/cask/http/BodyProducer.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public abstract class BodyProducer {
* won't be set and {@code Transfer-Encoding: chunked} will be used.
* </p>
* By default, {@code -1L} is returned.
*
* @return the size of the content in bytes
*/
public long getContentLength() {
return -1L;
Expand All @@ -41,6 +43,7 @@ public long getContentLength() {
* Returns a {@link ByteBuf} representing the next chunk of bytes to send. If the returned
* {@link ByteBuf} is an empty buffer, it signals the end of the streaming.
*
* @return the next chunk of bytes to send
* @throws Exception if there is any error
*/
public abstract ByteBuf nextChunk() throws Exception;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/co/cask/http/HttpResponder.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public interface HttpResponder {
* using the {@link ChunkResponder} returned.
*
* @param status the status code to respond with
* @return chunk responder for sending the response
*/
ChunkResponder sendChunkStart(HttpResponseStatus status);

Expand All @@ -104,6 +105,7 @@ public interface HttpResponder {
*
* @param status the status code to respond with
* @param headers additional headers to send with the response.
* @return chunk responder for sending the response
*/
ChunkResponder sendChunkStart(HttpResponseStatus status, HttpHeaders headers);

Expand Down
19 changes: 19 additions & 0 deletions src/main/java/co/cask/http/NettyHttpService.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ private NettyHttpService(String serviceName,
* Creates a {@link Builder} for creating new instance of {@link NettyHttpService}.
*
* @param serviceName name of the http service. The name will be used to name threads created for the service.
* @return builder for creating a NettyHttpService
*/
public static Builder builder(String serviceName) {
return new Builder(serviceName);
Expand Down Expand Up @@ -625,26 +626,44 @@ public Builder setHost(String host) {
return this;
}

/**
* Set the HTTP chunk limit.
*
* @param value the chunk limit
* @return instance of {@code Builder}.
*/
public Builder setHttpChunkLimit(int value) {
this.httpChunkLimit = value;
return this;
}

/**
* Enable SSL by using the provided SSL information.
*
* @param sslConfig the SSL configuration
* @return instance of {@code Builder}.
*/
public Builder enableSSL(SSLConfig sslConfig) {
return enableSSL(new SSLHandlerFactory(sslConfig));
}

/**
* Enable SSL by using the given {@link SSLHandlerFactory} to create {@link SslHandler}.
*
* @param sslHandlerFactory the factory for creating SslHandlers
* @return instance of {@code Builder}.
*/
public Builder enableSSL(SSLHandlerFactory sslHandlerFactory) {
this.sslHandlerFactory = sslHandlerFactory;
return this;
}

/**
* Set the {@link ExceptionHandler} for the service.
*
* @param exceptionHandler the exception handler to use
* @return instance of {@code Builder}.
*/
public Builder setExceptionHandler(ExceptionHandler exceptionHandler) {
if (exceptionHandler == null) {
throw new IllegalArgumentException("exceptionHandler cannot be null");
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/co/cask/http/SSLConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ public String getTrustKeyStorePassword() {
}

/**
* Creates a builder for the SSLConfig.
*
* @param keyStore the keystore
* @param keyStorePassword the password for the keystore
* @return instance of {@code Builder}
*/
public static Builder builder(File keyStore, String keyStorePassword) {
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/co/cask/http/SSLHandlerFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ private static KeyStore getKeyStore(File keyStore, String keyStorePassword) thro
}

/**
* Creates an SslHandler
*
* @param bufferAllocator the buffer allocator
* @return instance of {@code SslHandler}
*/
public SslHandler create(ByteBufAllocator bufferAllocator) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/co/cask/http/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* {@code NettyHttpService} sets up the necessary pipeline and manages starting, stopping,
* state-management of the web service.
*
* <p/>
* <p>
* In-order to handle http requests, {@code HttpHandler} must be implemented. The methods
* in the classes implemented from {@code HttpHandler} must be annotated with Jersey annotations to
* specify http uri paths and http methods.
Expand Down