Response to custom protocol requests.

Header#include "nativeui/protocol_job.h"
Namespacenamespace nu
Typeclass (RefCounted)

This class can not be used to create instances, you must use its sub-classes instead.

Note that the interface of this class will be modified in future for extensions.


std::function<void(int)> notify_content_length

Called by sub-classes when it is ready to read data.


bool Start()

Called when the loading of request should start.

Returning false would cancel the request.

This method is asynchronous, when the request is ready to be read, the notify_content_length function property of this class should be called with notify_content_length(size). The size is the expected length of the data to be read, pass -1 if uncertain.



void Kill()

Called when the loading should be stopped.

bool GetMimeType(std::string* mimetype)

Called when browser wants to get mime type of the request.

Returning false would leave the browser to guess the mime type.

Depending on the platform, this method may be called before and after the request is started, and it may be called in a different thread from the one it was created.




size_t Read(void* buffer, size_t bytes)

Called when browser wants to read data.

The data should be written to the buffer, which has the size of bytes. It should return size of data written, returning 0 means there is no more data.