/usr/include/Wt/Http/Response is in libwt-dev 3.3.3+dfsg-4.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | // This may look like C code, but it's really -*- C++ -*-
/*
* Copyright (C) 2009 Emweb bvba, Kessel-Lo, Belgium.
*
* See the LICENSE file for terms of use.
*/
#ifndef HTTP_RESPONSE_H_
#define HTTP_RESPONSE_H_
#include <string>
#include <Wt/WGlobal>
#include <Wt/Http/ResponseContinuation>
#include <ostream>
namespace Wt {
class WResource;
class WebSession;
namespace Http {
/*! \class Response Wt/Http/Response Wt/Http/Response
* \brief A resource response.
*
* This class defines the HTTP response for a WResource request.
*
* More specifically you can:
* - set the content mime type using setMimeType()
* - add HTTP headers using addHeader()
* - stream content into out()
*
* You may chose to provide only a partial response. In that case, use
* createContinuation() to create a continuation object to which you
* can annotate information for the next request to process the
* response further.
*
* \sa WResource::handleRequest(), Request
*
* \ingroup http
*/
class WT_API Response
{
public:
/*! \brief Sets the response status.
*
* Unless a overriden, 200 OK will be assumed.
*/
void setStatus(int status);
/*! \brief Sets the content length
*
* If content length is known, use this method to set it. File downloads
* will see progress bars. If not set, Wt will use chunked transfers.
*
* Always use this method instead of setting the Content-Length header
* with addHeader().
*
* Headers may be added only before setting the content mime-type
* (setMimeType()), and before streaming any data to the out()
* stream.
*/
void setContentLength(::uint64_t length);
/*! \brief Set the content mime type.
*
* The content mimetype is used by the browser to correctly interpret
* the resource.
*/
void setMimeType(const std::string& mimeType);
/*! \brief Add an HTTP header.
*
* Headers may be added only before setting the content mime-type
* (setMimeType()), and before streaming any data to the out()
* stream.
*/
void addHeader(const std::string& name, const std::string& value);
/*! \brief Create a continuation object for this response.
*
* A continuation is used to resume sending more data later for this
* response. There are two possible reasons for this:
* - the entire response is quite big and you may want to read and send
* it in smaller chunks to avoid memory consumption problems since the
* I/O layer buffers the response first in memory to send it then out
* to a possibly slow client using async I/O.
* - you may not have any more data available, currently, but expect more
* data later. In that case you can call
* ResponseContinuation::waitForMoreData() and later call
* WResource::haveMoreData() when more data is available.
*
* A new call to handleRequest() will be made to retrieve more
* data.
*
* \sa continuation()
*/
ResponseContinuation *createContinuation();
/*! \brief Return the continuation, if one was created for this response.
*
* Returns the continuation that was previously created using
* createContinuation(), or 0 if no continuation was created yet.
*
* \sa createContinuation()
*/
ResponseContinuation *continuation() const;
/*! \brief Returns the stream for getting the response output.
*/
std::ostream& out();
WT_BOSTREAM& bout() { return out(); }
private:
WResource *resource_;
WebResponse *response_;
ResponseContinuation *continuation_;
WT_BOSTREAM *out_;
bool headersCommitted_;
Response(WResource *resource, WebResponse *response,
ResponseContinuation *continuation);
Response(WResource *resource, WT_BOSTREAM& out);
friend class Wt::WResource;
friend class Wt::WebSession;
};
}
}
#endif // HTTP_RESPONSE_H_
|