From 921749cd8a95c857ccacdeb44cad08649d10698b Mon Sep 17 00:00:00 2001 From: David Helder Date: Mon, 8 Apr 2013 18:21:56 +0000 Subject: [PATCH] [split] finagle-http: add Response(status) RB_ID=138147 --- CHANGES | 1 + .../src/main/scala/com/twitter/finagle/http/Message.scala | 6 +++--- .../main/scala/com/twitter/finagle/http/Response.scala | 8 ++++++-- .../com/twitter/finagle/http/netty/HttpMessageProxy.scala | 6 +++--- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/CHANGES b/CHANGES index dd9d9e7a056..0ce8d5d2c88 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,7 @@ as it is included in Finagle's user's guide. 6.x ----- +- `finagle-http`: Add Response.apply(status) 6.3.0 ~~~~~ diff --git a/finagle-http/src/main/scala/com/twitter/finagle/http/Message.scala b/finagle-http/src/main/scala/com/twitter/finagle/http/Message.scala index bac1aa5a2b5..e854c709865 100644 --- a/finagle-http/src/main/scala/com/twitter/finagle/http/Message.scala +++ b/finagle-http/src/main/scala/com/twitter/finagle/http/Message.scala @@ -382,11 +382,11 @@ abstract class Message extends HttpMessage { object Message { private[http] val Utf8 = Charset.forName("UTF-8") - @deprecated("Use MediaType.Json") + @deprecated("Use MediaType.Json", "6.1.5") val MediaTypeJson = "application/json" - @deprecated("Use MediaType.Javascript") + @deprecated("Use MediaType.Javascript", "6.1.5") val MediaTypeJavascript = "application/javascript" - @deprecated("Use MediaType.WwwForm") + @deprecated("Use MediaType.WwwForm", "6.1.5") val MediaTypeWwwForm = "application/x-www-form-urlencoded" val CharsetUtf8 = "charset=utf-8" val ContentTypeJson = MediaType.Json + ";" + CharsetUtf8 diff --git a/finagle-http/src/main/scala/com/twitter/finagle/http/Response.scala b/finagle-http/src/main/scala/com/twitter/finagle/http/Response.scala index 002ad106d20..1a6df551bcc 100644 --- a/finagle-http/src/main/scala/com/twitter/finagle/http/Response.scala +++ b/finagle-http/src/main/scala/com/twitter/finagle/http/Response.scala @@ -52,14 +52,18 @@ object Response { Response(httpResponse) } - /** Create Response. Convenience method for testing. */ + /** Create Response. */ def apply(): Response = apply(Version.Http11, Status.Ok) - /** Create Response from version and status. Convenience method for testing. */ + /** Create Response from version and status. */ def apply(version: HttpVersion, status: HttpResponseStatus): Response = apply(new DefaultHttpResponse(version, status)) + /** Create Response from status. */ + def apply(status: HttpResponseStatus): Response = + apply(new DefaultHttpResponse(Version.Http11, status)) + /** Create Response from HttpResponse. */ def apply(httpResponseArg: HttpResponse): Response = new Response { diff --git a/finagle-http/src/main/scala/com/twitter/finagle/http/netty/HttpMessageProxy.scala b/finagle-http/src/main/scala/com/twitter/finagle/http/netty/HttpMessageProxy.scala index ede2997ead3..f11028a1fa0 100644 --- a/finagle-http/src/main/scala/com/twitter/finagle/http/netty/HttpMessageProxy.scala +++ b/finagle-http/src/main/scala/com/twitter/finagle/http/netty/HttpMessageProxy.scala @@ -28,14 +28,14 @@ trait HttpMessageProxy extends HttpMessage { def getContent(): ChannelBuffer = httpMessage.getContent() def setContent(content: ChannelBuffer) { httpMessage.setContent(content) } - @deprecated("deprecated in netty") + @deprecated("deprecated in netty", "6.1.5") def getContentLength(): Long = httpMessage.getContentLength() - @deprecated("deprecated in netty") + @deprecated("deprecated in netty", "6.1.5") def getContentLength(defaultValue: Long): Long = httpMessage.getContentLength(defaultValue) def isChunked: Boolean = httpMessage.isChunked() def setChunked(chunked: Boolean) { httpMessage.setChunked(chunked) } - @deprecated("deprecated in netty") + @deprecated("deprecated in netty", "6.1.5") def isKeepAlive: Boolean = httpMessage.isKeepAlive() }