Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

It Runs & Responds!

The output buffer returned from MyResponse.outputBuffer's flush method is entertaining...needs to be much improved in order to work better.
  • Loading branch information...
commit c4a9a4c11e3e03418860a11d4eae63c5111ae314 1 parent b755cda
@jrwest authored
View
2  src/main/scala/com/something/lift/NothingServer.scala
@@ -66,7 +66,7 @@ object NothingServer extends App {
bootstrap.setOption("child.keepAlive", true)
val boundChannel = bootstrap.bind(new InetSocketAddress(8080))
- println("TIME Server Started")
+ println("Lift-Netty Server Started")
allChannels.add(boundChannel)
View
12 src/main/scala/com/something/lift/NothingServerHandler.scala
@@ -10,6 +10,7 @@ import net.liftweb.http._
import java.util.Locale
import net.liftweb.util.{Helpers, Schedule, LoanWrapper}
import java.net.{InetSocketAddress, URI, URL}
+import org.jboss.netty.buffer.ChannelBuffers
/**
* Created by IntelliJ IDEA.
@@ -338,7 +339,11 @@ class NettyHttpRequest extends HTTPRequest {
class MyResponse extends HTTPResponse {
- lazy val nettyResponse: HttpResponse = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK)
+ lazy val nettyResponse: HttpResponse = {
+ val r = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK)
+ r.setContent(ChannelBuffers.dynamicBuffer(1024)) // TODO this is just some random choice, do something more intelligent?
+ r
+ }
/**
* Add cookies to the response
@@ -391,6 +396,11 @@ class NettyHttpRequest extends HTTPRequest {
def write(i: Int) {
nettyResponse.getContent.writeByte(i)
}
+
+ override def flush() {
+ val future = ctx.getChannel.write(nettyResponse)
+ future.addListener(ChannelFutureListener.CLOSE)
+ }
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.