Could be related to my other issue, but this is much easier to replicate with the simple handler below. Unless created with hack=true, this will hang. Will make a note on the issue tracker.
- Code: Select all
struct SchemeHandlerTest
:
CefSchemeHandler
{
SchemeHandlerTest(bool hack) : hack(hack), pos(0) { }
bool hack;
std::size_t pos;
static const char *data() { return "testing, testing, testing...."; }
static int len() { return strlen(data()); }
virtual void Cancel() override { }
virtual bool ProcessRequest( CefRefPtr< CefRequest > request, CefRefPtr< CefSchemeHandlerCallback > callback ) override
{
callback->HeadersAvailable();
return true;
}
virtual void GetResponseHeaders( CefRefPtr< CefResponse > response, int64& response_length, CefString& redirectUrl ) override
{
response->SetMimeType("text/plain");
response->SetStatus(200);
response_length = len();
}
virtual bool ReadResponse( void* data_out, int bytes_to_read, int& bytes_read, CefRefPtr< CefSchemeHandlerCallback > callback ) override
{
bytes_read = std::min(bytes_to_read, len());
if (this->hack)
{
if (bytes_read > 1) --bytes_read;
}
memcpy(data_out, &this->data()[this->pos], bytes_read);
this->pos += bytes_read;
return this->pos != len();
}
IMPLEMENT_REFCOUNTING(SchemeHandlerTest);
};