Another CefSchemeHandler problem

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Another CefSchemeHandler problem

Postby paperjam » Fri Mar 02, 2012 5:49 am

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);
};
paperjam
Techie
 
Posts: 21
Joined: Thu Feb 02, 2012 6:57 am

Return to Support Forum

Who is online

Users browsing this forum: No registered users and 97 guests