|
Wt
4.12.2
|
A resource which removes itself after being served. More...
#include <Wt/WSelfDeletingResource.h>
Public Member Functions | |
| WSelfDeletingResource (const std::string &mimeType) | |
| Creates a new resource with given mime-type. | |
| WSelfDeletingResource (const std::string &mimeType, const std::vector< unsigned char > &data) | |
| Creates a new resource with given mime-type and data. | |
| ~WSelfDeletingResource () | |
| Destructor. | |
| void | handleRequest (const Http::Request &request, Http::Response &response) override |
| Handles a request. | |
Public Member Functions inherited from Wt::WMemoryResource | |
| WMemoryResource () | |
| Creates a new resource. | |
| WMemoryResource (const std::string &mimeType) | |
| Creates a new resource with given mime-type. | |
| WMemoryResource (const std::string &mimeType, const std::vector< unsigned char > &data) | |
| Creates a new resource with given mime-type and data. | |
| void | setData (const std::vector< unsigned char > &data) |
| Sets new data for the resource to serve. | |
| void | setData (const unsigned char *data, int count) |
| Sets new data for the resource to serve. | |
| const std::vector< unsigned char > | data () const |
| Returns the data this resource will serve. | |
| const std::string | mimeType () const |
| Returns the mime-type. | |
| void | setMimeType (const std::string &mimeType) |
| Sets the mime-type. | |
Public Member Functions inherited from Wt::WResource | |
| WResource () | |
| Creates a new resource. | |
| ~WResource () | |
| Destroys the resource. | |
| void | suggestFileName (const Wt::WString &name, ContentDisposition disposition=ContentDisposition::Attachment) |
| Suggests a filename to the user for the data streamed by this resource. | |
| const Wt::WString & | suggestedFileName () const |
| Returns the suggested file name. | |
| void | setDispositionType (ContentDisposition cd) |
| Configures the Content-Disposition header. | |
| ContentDisposition | dispositionType () const |
| Returns the currently configured content disposition. | |
| void | setChanged () |
| Generates a new URL for this resource and emits the changed signal. | |
| void | setInvalidAfterChanged (bool enabled) |
| Return "page not found" for prior resource URLs after change. | |
| bool | invalidAfterChanged () const |
| Should "page not found" be returned for outdated resource URLs. | |
| void | setInternalPath (const std::string &path) |
| Sets an internal path for this resource. | |
| std::string | internalPath () const |
| Returns the internal path. | |
| const std::string & | generateUrl () |
| Generates an URL for this resource. | |
| const std::string & | url () const |
| Returns the current URL for this resource. | |
| void | setAlternativeBotUrl (const std::string &url) |
| Sets an alternative URL, given to bots, for this resource. | |
| const std::string & | alternativeBotUrl () const |
| Returns the alternative URL, given to bots, for this resource. | |
| Signal & | dataChanged () |
| Signal emitted when the data presented in this resource has changed. | |
| void | setUploadProgress (bool enabled) |
| Indicate interest in upload progress. | |
| Signal< ::uint64_t, ::uint64_t > & | dataReceived () |
| Signal emitted when data has been received for this resource. | |
| void | write (std::ostream &out, const Http::ParameterMap ¶meters=Http::ParameterMap(), const Http::UploadedFileMap &files=Http::UploadedFileMap()) |
| Stream the resource to a stream. | |
| std::vector< unsigned char > | writeToMemory () |
| Writes the resource into a unsigned char vector. | |
| virtual void | handleAbort (const Http::Request &request) |
| Handles a continued request being aborted. | |
| void | haveMoreData () |
| Indicate that more data is available. | |
| void | setTakesUpdateLock (bool enabled) |
| Set whether this resource takes the WApplication's update lock. | |
| bool | takesUpdateLock () const |
| Returns whether this resources takes the WApplication's update lock. | |
| void | setAllowAutoRemoval (bool allow) |
| Sets whether this resource can be automatically removed. | |
| bool | allowAutoRemoval () const |
| Returns whether this resource can be automatically removed. | |
| void | setBotResourceId (const std::string &id) |
| Sets the bot resource ID. | |
| std::string | botResourceId () const |
| Returns the bot resource ID. | |
| virtual std::shared_ptr< WResource > | botResource () |
| Resource made public for bot sessions. | |
Public Member Functions inherited from Wt::WObject | |
| void | addChild (std::unique_ptr< WObject > child) |
| Add a child WObject whose lifetime is determined by this WObject. | |
| template<typename Child > | |
| Child * | addChild (std::unique_ptr< Child > child) |
| Add a child WObject, returning a raw pointer. | |
| std::unique_ptr< WObject > | removeChild (WObject *child) |
| Remove a child WObject, so its lifetime is no longer determined by this WObject. | |
| template<typename Child > | |
| std::unique_ptr< Child > | removeChild (Child *child) |
| Remove a child WObject, so its lifetime is no longer determined by this WObject. | |
| virtual const std::string | id () const |
| Returns the (unique) identifier for this object. | |
| virtual void | setObjectName (const std::string &name) |
| Sets an object name. | |
| virtual std::string | objectName () const |
| Returns the object name. | |
| void | resetLearnedSlots () |
| Resets learned stateless slot implementations. | |
| template<class T > | |
| void | resetLearnedSlot (void(T::*method)()) |
| Resets a learned stateless slot implementation. | |
| template<class T > | |
| WStatelessSlot * | implementStateless (void(T::*method)()) |
| Declares a slot to be stateless and learn client-side behaviour on first invocation. | |
| template<class T > | |
| WStatelessSlot * | implementStateless (void(T::*method)(), void(T::*undoMethod)()) |
| Declares a slot to be stateless and learn client-side behaviour in advance. | |
| void | isNotStateless () |
| Marks the current function as not stateless. | |
| template<class T > | |
| WStatelessSlot * | implementJavaScript (void(T::*method)(), const std::string &jsCode) |
| Provides a JavaScript implementation for a method. | |
Public Member Functions inherited from Wt::Core::observable | |
| observable () noexcept | |
| Default constructor. | |
| virtual | ~observable () |
| Destructor. | |
| template<typename... Args, typename C > | |
| auto | bindSafe (void(C::*method)(Args...)) noexcept |
| Protects a method call against object destruction. | |
| template<typename... Args, typename C > | |
| auto | bindSafe (void(C::*method)(Args...) const) const noexcept |
| Protects a const method call against object destruction. | |
| template<typename Function > | |
| auto | bindSafe (const Function &function) noexcept |
| Protects a function against object destruction. | |
Additional Inherited Members | |
Public Types inherited from Wt::WObject | |
| typedef void(WObject::* | Method) () |
| Typedef for a WObject method without arguments. | |
Protected Member Functions inherited from Wt::WResource | |
| void | beingDeleted () |
| Prepares the resource for deletion. | |
| bool | customBotResourceId () const |
| Returns whether this resource has a custom bot resource ID. | |
Protected Member Functions inherited from Wt::WObject | |
| virtual WStatelessSlot * | getStateless (Method method) |
| On-demand stateless slot implementation. | |
A resource which removes itself after being served.
This resource will automatically unexpose itself after being served.
This resource is mainly intended to be used as output for the WResource::botResource() in order to free memory once the bot has fetched the resource.
This resource has auto removal allowed by default.
| Wt::WSelfDeletingResource::WSelfDeletingResource | ( | const std::string & | mimeType | ) |
Creates a new resource with given mime-type.
You must call setData() before using the resource.
|
overridevirtual |
Handles a request.
Reimplement this method so that a proper response is generated for the given request. From the request object you can access request parameters and whether the request is a continuation request. In the response object, you should set the mime type and stream the output data.
A request may also concern a continuation, indicated in Http::Request::continuation(), in which case the next part for a previously created continuation should be served.
While handling a request, which may happen at any time together with event handling, the library makes sure that the resource is not being concurrently deleted, but multiple requests may happend simultaneously for a single resource.
Reimplemented from Wt::WMemoryResource.