trait Responder extends AnyRef
When responding text, charset is automatically set, as advised by Google: http://code.google.com/speed/page-speed/docs/rendering.html#SpecifyCharsetEarly
- Self Type
- Action
- Alphabetic
- By Inheritance
- Responder
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- def isDoneResponding: Boolean
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
def
onDoneResponding(): Unit
Called when the response or the last chunk (in case of chunked response) has been sent to the client.
- def respond(): ChannelFuture
- def respond404Page(): Unit
- def respond500Page(): Unit
-
def
respondBinary(byteBuf: ByteBuf): ChannelFuture
If Content-Type header is not set, it is set to "application/octet-stream".
If Content-Type header is not set, it is set to "application/octet-stream".
- byteBuf
Will be released
-
def
respondBinary(bytes: Array[Byte]): ChannelFuture
If Content-Type header is not set, it is set to "application/octet-stream".
- def respondDefault404Page(): ChannelFuture
- def respondDefault500Page(): ChannelFuture
-
def
respondEventSource(data: Any, event: String = "message"): ChannelFuture
To respond event source, call this method as many time as you want.
To respond event source, call this method as many time as you want. Event Source response is a special kind of chunked response, data must be UTF-8. See: - http://sockjs.github.com/sockjs-protocol/sockjs-protocol-0.3.3.html#section-94 - http://dev.w3.org/html5/eventsource/
No need to call setChunked() before calling this method.
-
def
respondFile(path: String): ChannelFuture
Sends a file using X-SendFile.
Sends a file using X-SendFile. If Content-Type header is not set, it is guessed from the file name.
- path
absolute or relative to the current working directory In some cases, the current working directory is not always the root directory of the project (https://github.com/xitrum-framework/xitrum/issues/47), you may need to use xitrum.Config.root to calculate the correct absolute path from a relative path. To sanitize the path, use xitrum.util.PathSanitizer.
-
def
respondHtml(any: Any): ChannelFuture
Content-Type header is set to "text/html".
-
def
respondJs(any: Any): ChannelFuture
Content-Type header is set to "application/javascript".
-
def
respondJson(ref: AnyRef): ChannelFuture
Converts the given Scala object to JSON object, and responds it.
Converts the given Scala object to JSON object, and responds it. If you just want to respond a text with "application/json" as content type, use respondJsonText(text).
Content-Type header is set to "application/json". "text/json" would make the browser download instead of displaying the content. It makes debugging a pain.
-
def
respondJsonP(ref: AnyRef, function: String): ChannelFuture
Converts the given Scala object to JSON object, wraps it with the given JavaScript function name, and responds.
Converts the given Scala object to JSON object, wraps it with the given JavaScript function name, and responds. If you already have a JSON text, thus no conversion is needed, use respondJsonPText.
Content-Type header is set to "application/javascript".
-
def
respondJsonPText(text: Any, function: String): ChannelFuture
Wraps the text with the given JavaScript function name, and responds.
Wraps the text with the given JavaScript function name, and responds.
Content-Type header is set to "application/javascript".
-
def
respondJsonText(any: Any): ChannelFuture
Content-Type header is set to "application/json".
-
def
respondLastChunk(trailingHeaders: HttpHeaders = EmptyHttpHeaders.INSTANCE): ChannelFuture
See setChunked.
-
def
respondResource(path: String): ChannelFuture
Sends a file from public directory in one of the entry (may be a JAR file) in classpath.
Sends a file from public directory in one of the entry (may be a JAR file) in classpath. If Content-Type header is not set, it is guessed from the file name.
- path
Relative to an entry in classpath, without leading "/"
-
def
respondText(text: Any, fallbackContentType: String = null, convertXmlToXhtml: Boolean = true): ChannelFuture
- fallbackContentType
Only used if Content-Type header has not been set. If not given and Content-Type header is not set, it is set to "application/xml" if text param is Node or NodeSeq, otherwise it is set to "text/plain".
- convertXmlToXhtml
.toString by default returns
which is rendered as 2
tags on some browsers! Set to false if you really want XML, not XHTML. See http://www.scala-lang.org/node/492 and http://www.ne.jp/asahi/hishidama/home/tech/scala/xml.html
-
def
respondXml(any: Any): ChannelFuture
Content-Type header is set to "application/xml".
-
def
setChunked(): Unit
To respond chunks (http://en.wikipedia.org/wiki/Chunked_transfer_encoding): 1.
To respond chunks (http://en.wikipedia.org/wiki/Chunked_transfer_encoding): 1. Call setChunked() to mark that the response will be chunked 2. Call respondXXX as normal, but as many times as you want 3. Lastly, call respondLastChunk()
If Content-Type header is not set, it is set to "application/octet-stream".
-
def
setClientCacheAggressively(): Unit
Tells the browser to cache static files for a long time.
Tells the browser to cache static files for a long time. This works well even when this is a cluster of web servers behind a load balancer because the URL created by urlForResource is in the form: resource?etag
Don't worry that browsers do not pick up new files after you modified them, see the doc about static files.
Google recommends 1 year: http://code.google.com/speed/page-speed/docs/caching.html
Both Max-age and Expires header are set because IEs use Expires, not max-age: http://mrcoles.com/blog/cookies-max-age-vs-expires/
-
def
setNoClientCache(): Unit
Prevents client cache.
Prevents client cache. Note that "pragma: no-cache" is linked to requests, not responses: http://palizine.plynt.com/issues/2008Jul/cache-control-attributes/
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )