vibe.d beta banner
get vibe.d

Asynchronous I/O that doesn’t get in your way, written in D

Class HTTPServerResponse

Represents a HTTP response as sent from the server side.

class HTTPServerResponse
  : HTTPResponse ;


this (conn, raw_connection, settings, req_alloc)
this (conn, raw_connection, settings, req_alloc)


headers DictionaryList!(string,false,12L,false)The response header fields
httpVersion HTTPVersionThe protocol version of the response - should not be changed
statusCode intThe status code of the response, 200 by default
statusPhrase stringThe status phrase of the response
m_cookies DictionaryList!(vibe.http.common.Cookie,true,32L,false)


bodyWriter[get] vibe.internal.interfaceproxy.InterfaceProxy!( stream for writing the body of the HTTP response.
bytesWritten[get] ulong
connected[get] boolDetermines if the underlying connection is still alive.
headerWritten[get] boolDetermines if the HTTP header has already been written.
timeFinalized[get] std.datetime.systime.SysTimeReturns the time at which the request was finalized.
contentType[get, set] stringShortcut to the "Content-Type" header
cookies[get] DictionaryList!(vibe.http.common.Cookie,true,32L,false)All cookies that shall be set on the client for this request


connectProxy () Special method for handling CONNECT proxy tunnel
finalize () Finalizes the response. This is usually called automatically by the server.
isHeadResponse () Determines if the response does not need a body.
redirect (url, status) Sends a redirect request to the client.
setCookie (name, value, path, encoding) Sets the specified cookie value.
startSession (path) Initiates a new session.
switchProtocol (protocol) Special method sending a SWITCHING_PROTOCOLS response to the client.
terminateSession () Terminates the current session (if any).
tls () Determines if the response is sent over an encrypted connection.
waitForConnectionClose (timeout) Waits until either the connection closes, data arrives, or until the given timeout is reached.
writeBody (data, content_type) Writes the entire response body at once.
writeBody (data, content_type) Writes the entire response body as a single string.
writeJsonBody (data, status, allow_chunked) Writes a JSON message with the specified status
writePrettyJsonBody (data, allow_chunked) Writes a JSON message with the specified status
writeRawBody (stream) Writes the whole response body at once, without doing any further encoding.
writeVoidBody () Writes the response with no body.
toString ()



Sönke Ludwig, Jan Krüger, Ilya Shipunov


© 2012-2017 Sönke Ludwig


Subject to the terms of the MIT license, as written in the included LICENSE.txt file.