WebRes¶
Doc Home > API Index > web > WebRes
Inheritance¶
sys::Obj sys::Virtual sys::OutStream web::WebRes
public class WebRes
WebRes models the response side of an HTTP transaction. All responses should be ordered as:
1. res.writeStatus
2. zero or more calls to res.writeHeader
3. res.finishHeaders
4. write body
Fields¶
bufLen¶
public static const define int bufLen
service¶
public WebService service
Parent web service component
Methods¶
close¶
public override void close()
encode64¶
Print the buf contents using base64 encoding and return this.
esc¶
Print the specified string escaping <, >, and & into the <, >, and &
finishHeaders¶
public WebRes finishHeaders()
This call closes the header section and readys the output stream for the response content.
flush¶
public override void flush()
html¶
public WebRes html()
Write out 200 OK status, text/html content type, and opening HTML markup.
htmlEnd¶
public WebRes htmlEnd()
Write closing HTML markup.
json¶
public WebRes json()
Write out 200 OK status, application/json content type, and opening JSON markup.
jsonEsc¶
Print the specified JSON string escaping ", \, \n, \r, \t Others (\f, \b) are ignored
jsonKV¶
public WebRes jsonKV(Str key, Str val)
Print the specified JSON key/ value pair on a new line without indent
jsonKVI¶
public WebRes jsonKVI(int indent, Str key, Str val)
Print the specified JSON key/ value pair on a new line with a specified indent
jsonObjEnd¶
public WebRes jsonObjEnd(int indent)
Write closing JSON markup. on a new line
jsonObjStart¶
public WebRes jsonObjStart(int indent)
Write opening JSON markup.
jsonStrN¶
public WebRes jsonStrN(Str str)
Print the specified string in JSON format on a new line without indent
jsonStrNI¶
public WebRes jsonStrNI(int indent, Str str)
Print the specified string in JSON format on a new line with a specified indent
printDuration¶
public WebRes printDuration(long ticks)
Print duration in human readable form.
printElapsed¶
public WebRes printElapsed(long ticks)
Print elapsed duration from specified ticks to now.
printProp¶
public WebRes printProp(Component c, Slot prop)
Print the component's current value of the specified property.
spaces¶
public WebRes spaces(int num)
Print the specified number of spaces.
td¶
public WebRes td()
Write td start tag with no-wrap and left align.
th¶
Write th element with no-wrap and left align.
trTitle¶
public WebRes trTitle(Str title, int colspan)
Write a tr element with the specified colspan that can be used as a title header to separate rows.
w¶
Print the specified string and return this.
wi¶
public WebRes wi(int i)
Print the specified integer and return this.
write¶
public override bool write(int b)
writeBytes¶
public override bool writeBytes(byte[] b, int off, int len)
writeContentType¶
public WebRes writeContentType(Str val)
Convenience for writeHeader("Content-Type", val)
writeHeader¶
public WebRes writeHeader(Str name, Str val)
Write a header name/value pair. This call must be made between writeStatus() and finishHeaders().
writeStatus¶
public WebRes writeStatus(int status)
Write response status line with specified HTTP status code. This call must be the very first thing written.
writeStatusOk¶
public WebRes writeStatusOk()
Convenience for writeStatus(200)
Doc Home > API Index > web > WebRes