Skip to content

Commit

Permalink
deprecate HTTP codec in builder, move it to "http" instead.
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusae committed Feb 25, 2011
1 parent 4cf1057 commit b0a212b
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 0 deletions.
Expand Up @@ -5,6 +5,7 @@

import com.twitter.finagle.Codec;

@Deprecated
public class Codec4J {
public static Codec<HttpRequest, HttpResponse> Http = new Http(0);
public static Codec<HttpRequest, HttpResponse> HttpWithCompression = new Http(6);
Expand Down
Expand Up @@ -6,6 +6,7 @@ import org.jboss.netty.handler.codec.http._
import com.twitter.finagle.Codec
import com.twitter.finagle.http._

@deprecated("Use com.twitter.finagle.http.Http instead")
class Http(compressionLevel: Int = 0) extends Codec[HttpRequest, HttpResponse] {
val clientPipelineFactory: ChannelPipelineFactory =
new ChannelPipelineFactory {
Expand Down
71 changes: 71 additions & 0 deletions finagle-core/src/main/scala/com/twitter/finagle/http/Codec.scala
@@ -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()
}
@@ -1,5 +1,11 @@
package com.twitter.finagle.http

/**
* The HTTP connection manager implements connection management in
* accordance with RFC 2616 § 8. This is just the state machine: the
* codec implementations are in {Server,Client}ConnectionManager.
*/

import org.jboss.netty.handler.codec.http._

class ConnectionManager {
Expand Down

0 comments on commit b0a212b

Please sign in to comment.