interface IDriverContext
package hx.well.http.driver
Defines the contract for a driver-specific context for a single HTTP request.
This interface abstracts away the underlying server implementation (e.g., Socket, Undertow) from the main HttpHandler. It is responsible for all I/O operations and for translating native request/response objects into the framework's common objects.
It provides two mutually exclusive ways to send a response:
1. writeResponse(response): For simple, buffered responses that are sent in one go.
2. beginWrite() followed by write* methods: For manual/streaming responses.
Variables
Methods
beginWrite():Void
Begins a manual/streaming response. This sends the HTTP status line and headers,
preparing the stream for the body content. This must be called before any write* methods
are used for streaming.
close():Void
Closes the connection and releases all resources associated with this request context. This should be the final action for any request.
writeByte(c:Int):Void
Writes a single byte to the response body.
Requires beginWrite() to have been called first.
Parameters:
c | The byte to write. |
|---|
writeFullBytes(bytes:Bytes, pos:Int = 0, len:Int = -1):Void
Writes a chunk of bytes to the response body.
Requires beginWrite() to have been called first.
Parameters:
bytes | The |
|---|---|
pos | The starting position in the buffer. |
len | The number of bytes to write. |
writeInput(i:Input, ?bufsize:Int):Void
Writes the content of an Input stream to the response body.
Requires beginWrite() to have been called first.
Parameters:
i | The |
|---|---|
bufsize | The size of the buffer to use for copying. |
writeResponse(response:Response):Void
writeString(s:String, ?encoding:Encoding):Void
Writes a string to the response body.
Requires beginWrite() to have been called first.
Parameters:
s | The |
|---|---|
encoding | The character encoding to use. |