Google APIs Client Library for C++
WebServerResponse Class Reference

Abstract class for responses to WebServerRequests into the AbstractWebServerThis is different from the HttpResponse class in the transport layer which are client-side responses. More...

#include "client/util/abstract_webserver.h"

List of all members.

Public Member Functions

 WebServerResponse ()
virtual ~WebServerResponse ()
util::Status SendHtml (int http_code, const StringPiece &body)
 Respond with a text/html content type and body.
util::Status SendText (int http_code, const StringPiece &body)
 Respond with a text/plain content type and body.
virtual util::Status SendRedirect (int http_code, const StringPiece &url)
 Respond with a redirect to another url.
virtual util::Status SendReply (const StringPiece &content_type, int http_code, const StringPiece &body)=0
 Respond with an specified content type and body.
virtual util::Status AddHeader (const StringPiece &name, const StringPiece &value)=0
 Adds a custom header to the repsonse.
virtual util::Status AddCookie (const StringPiece &name, const StringPiece &value)=0
 Adds a custom cookie to the repsonse.

Detailed Description

Abstract class for responses to WebServerRequests into the AbstractWebServer

This is different from the HttpResponse class in the transport layer which are client-side responses.

These are server side responses.

Responses are owned and created by WebServerRequest.


Constructor & Destructor Documentation

WebServerResponse ( ) [inline]
virtual ~WebServerResponse ( ) [inline, virtual]

Member Function Documentation

virtual util::Status AddCookie ( const StringPiece &  name,
const StringPiece &  value 
) [pure virtual]

Adds a custom cookie to the repsonse.

This will not check the cookie names or values.

Parameters:
[in]nameThe name of header to add.
[in]valueThe value of the header.
virtual util::Status AddHeader ( const StringPiece &  name,
const StringPiece &  value 
) [pure virtual]

Adds a custom header to the repsonse.

Content-Type, Content-Length and Location headers are automatically added. This will not check the header names or values.

Parameters:
[in]nameThe name of header to add.
[in]valueThe value of the header.
util::Status SendHtml ( int  http_code,
const StringPiece &  body 
) [inline]

Respond with a text/html content type and body.

Parameters:
[in]http_codeThe HTTP status code to send.
[in]bodyThe payload can be empty.
Returns:
ok or reason for failure.
virtual util::Status SendRedirect ( int  http_code,
const StringPiece &  url 
) [virtual]

Respond with a redirect to another url.

Parameters:
[in]http_codeThe HTTP status code to send (e.g. 307).
[in]urlThe url to redirect to.
Returns:
ok or reason for failure.
virtual util::Status SendReply ( const StringPiece &  content_type,
int  http_code,
const StringPiece &  body 
) [pure virtual]

Respond with an specified content type and body.

Parameters:
[in]content_typeThe MIME content type of the body.
[in]http_codeThe HTTP status code to send.
[in]bodyThe payload can be empty.
Returns:
ok or reason for failure.
util::Status SendText ( int  http_code,
const StringPiece &  body 
) [inline]

Respond with a text/plain content type and body.

Parameters:
[in]http_codeThe HTTP status code to send.
[in]bodyThe payload can be empty.
Returns:
ok or reason for failure.

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines