Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deprecate HTTP codec in builder, move it to "http" instead.
- Loading branch information
Showing
4 changed files
with
79 additions
and
0 deletions.
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
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
71 changes: 71 additions & 0 deletions
71
finagle-core/src/main/scala/com/twitter/finagle/http/Codec.scala
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 |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package com.twitter.finagle.http | ||
|
||
/** | ||
* This puts it all together: The HTTP codec itself. | ||
*/ | ||
|
||
import org.jboss.netty.channel.{Channels, ChannelPipelineFactory} | ||
import org.jboss.netty.handler.codec.http._ | ||
|
||
import com.twitter.util.StorageUnit | ||
import com.twitter.conversions.storage._ | ||
|
||
import com.twitter.finagle.Codec | ||
|
||
case class Http( | ||
_compressionLevel: Int = 0, | ||
_maxChunkAggregationBufferSize: StorageUnit = 1.megabyte) | ||
extends Codec[HttpRequest, HttpResponse] { | ||
|
||
def compressionLevel(level: Int) = copy(_compressionLevel = level) | ||
def maxChunkAggregationBufferSize(bufferSize: StorageUnit) = | ||
copy(_maxChunkAggregationBufferSize = bufferSize) | ||
|
||
val clientPipelineFactory: ChannelPipelineFactory = | ||
new ChannelPipelineFactory { | ||
def getPipeline() = { | ||
val pipeline = Channels.pipeline() | ||
pipeline.addLast("httpCodec", new HttpClientCodec()) | ||
pipeline.addLast( | ||
"httpDechunker", | ||
new HttpChunkAggregator(_maxChunkAggregationBufferSize.inBytes.toInt)) | ||
|
||
pipeline.addLast("httpDecompressor", new HttpContentDecompressor) | ||
|
||
pipeline.addLast( | ||
"connectionLifecycleManager", | ||
new ClientConnectionManager) | ||
|
||
pipeline | ||
} | ||
} | ||
|
||
val serverPipelineFactory = | ||
new ChannelPipelineFactory { | ||
def getPipeline() = { | ||
val pipeline = Channels.pipeline() | ||
pipeline.addLast("httpCodec", new HttpServerCodec) | ||
if (_compressionLevel > 0) { | ||
pipeline.addLast( | ||
"httpCompressor", | ||
new HttpContentCompressor(_compressionLevel)) | ||
} | ||
|
||
// Response to ``Expect: Continue'' requests. | ||
pipeline.addLast("respondToExpectContinue", new RespondToExpectContinue) | ||
pipeline.addLast( | ||
"httpDechunker", | ||
new HttpChunkAggregator(_maxChunkAggregationBufferSize.inBytes.toInt)) | ||
|
||
pipeline.addLast( | ||
"connectionLifecycleManager", | ||
new ServerConnectionManager) | ||
|
||
pipeline | ||
} | ||
} | ||
} | ||
|
||
object Http { | ||
def apply() = new Http() | ||
} |
6 changes: 6 additions & 0 deletions
6
finagle-core/src/main/scala/com/twitter/finagle/http/ConnectionManager.scala
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