public class Reply
extends java.lang.Object
header(String, String)
, code(String)
and
finally output()
. If you call the code(String)
or
output()
method, the reply will flush output, so then you won't be
able to do an asynchronous reply, call Event.hold()
to keep the reply open until
Output.finish()
is called. To wakeup a dormant asynchronous event use wakeup()
.Modifier and Type | Field and Description |
---|---|
static int |
CLOSED
If the reply has been closed, try increasing timeout variable.
|
static int |
COMPLETE
If the reply has been completed.
|
static int |
OK
The reply was successfully awakened.
|
static int |
WORKING
If the reply has a thread writing already you can automatically queue wakeup with
wakeup(boolean) to assure the wakeup is successful. |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
code() |
void |
code(java.lang.String code)
Important: call
header(String, String) before you call this. |
void |
header(java.lang.String name,
java.lang.String value)
This has to be called before
output() to have effect. |
Output |
output()
Calls
output(0) . |
Output |
output(long length)
Important: call
header(String, String) and code(String)
first, in that order, this method is the point of no return for delivery
of a request. |
java.lang.String |
toString() |
java.lang.String |
type() |
void |
type(java.lang.String type)
This has to be called before
output() to have effect. |
int |
wakeup() |
int |
wakeup(boolean queue)
To send data asynchronously, call this and the event will be re-filtered.
|
public static final int WORKING
wakeup(boolean)
to assure the wakeup is successful.public static final int OK
public static final int COMPLETE
Event
is no longer available
for wakeup and should probably be removed from the list, wakeup(boolean)
ignores this.public static final int CLOSED
Event
is no longer available for wakeup and should probably be removed from the list.public java.lang.String code()
public void code(java.lang.String code) throws java.io.IOException
header(String, String)
before you call this. If
you manually set a code, the reply will flush even if empty. So do not
call this if you wan't to reply asynchronously. For example if you want
to redirect a browser.
public void filter(Event event) throw Event { event.reply().header("Location", "/login"); event.reply().code("302 Found"); throw event; // stop the chain }
code
- java.io.IOException
public java.lang.String type()
public void type(java.lang.String type)
output()
to have effect.type
- public void header(java.lang.String name, java.lang.String value)
output()
to have effect.name
- value
- public Output output() throws java.io.IOException
output(0)
.java.io.IOException
public Output output(long length) throws java.io.IOException
header(String, String)
and code(String)
first, in that order, this method is the point of no return for delivery
of a request. It enables OP_WRITE and writes the headers immediately.length
- if you want to write fixed length datajava.io.IOException
public int wakeup()
public int wakeup(boolean queue)
Service.filter(Event)
!public java.lang.String toString()
toString
in class java.lang.Object