(Using Cef1 binary distribution version 1.963.439 on Windows XP and Windows Vista)
I'm issuing a XmlHttpRequest POST request with Content-Type: text/plain; charset=UTF-8 and a text as request data. Implementing my own scheme, I noticed that the ProcessRequest() does not hold any postdata in this case.
- Code: Select all
ProcessRequest() request->GetPostData() returns a NULL pointer.
I found issue 404 http://code.google.com/p/chromiumembedd ... ail?id=404 with status WontFix. But I'm not sure issue 404 hits the same problem as I'm doing.
I modified the scheme_test.cpp file. When running the "Scheme handler" test, a new hyperlink "Test XmlHttpRequest POST" is at the bottom of the page. Clicking this link shows an Alert-Box. In the Alert-Box the string "This is the postdata payload." should be shown, but it isn't.
- Code: Select all
virtual bool ProcessRequest(CefRefPtr<CefRequest> request,
CefRefPtr<CefSchemeHandlerCallback> callback)
OVERRIDE
{
REQUIRE_IO_THREAD();
bool handled = false;
AutoLock lock_scope(this);
std::string url = request->GetURL();
if(strstr(url.c_str(), "handler.html") != NULL) {
// Build the response html
data_ = "<html><head><title>Client Scheme Handler</title></head><body>"
"This contents of this page page are served by the "
"ClientSchemeHandler class handling the client:// protocol."
"<br/>You should see an image:"
"<br/><img src=\"client://tests/client.png\"><pre>";
// Output a string representation of the request
std::string dump;
DumpRequestContents(request, dump);
data_.append(dump);
data_.append("</pre><br/>Try the test form:"
"<form method=\"POST\" action=\"handler.html\">"
"<input type=\"text\" name=\"field1\">"
"<input type=\"text\" name=\"field2\">"
"<input type=\"submit\">"
"</form>");
//
//MODIFIED START
//
data_.append("\r\n<script language=\"javascript\">\r\n"
"function XHR_Post()\r\n"
"{\r\n"
" var xhr = new XMLHttpRequest();\r\n"
" xhr.open(\"POST\", \"dump.html?action=XHR_Post\", true);\r\n"
" xhr.setRequestHeader(\"Content-Type\", \"text/plain; charset=UTF-8\");\r\n"
" xhr.onreadystatechange = function() \r\n"
" {\r\n"
" if (xhr.readyState == 4)\r\n"
" {\r\n"
" alert(xhr.responseText);\r\n"
" }\r\n"
" }\r\n"
" xhr.send(\"This is the postdata payload.\");\r\n"
"}\r\n"
"</script>\r\n"
"<p><a href=\"javascript:XHR_Post();\">Test XmlHttpRequest POST</a></p>\r\n");
data_.append("</body></html>");
//
//MODIFIED END
//
handled = true;
// Set the resulting mime type
mime_type_ = "text/html";
}
//
//MODIFIED START
//
else if(strstr(url.c_str(), "dump.html") != NULL) {
// Output a string representation of the request
data_.clear();
std::string dump;
DumpRequestContents(request, dump);
data_.append(dump);
mime_type_ = "text/plain";
handled = true;
}
//
//MODIFIED END
//
else if(strstr(url.c_str(), "client.png") != NULL) {
// Load the response image
#if defined(OS_WIN)
DWORD dwSize;
LPBYTE pBytes;
if(LoadBinaryResource(IDS_LOGO, dwSize, pBytes)) {
data_ = std::string(reinterpret_cast<const char*>(pBytes), dwSize);
handled = true;
// Set the resulting mime type
mime_type_ = "image/jpg";
}
#elif (defined(OS_MACOSX) || defined(OS_LINUX))
if(LoadBinaryResource("logo.png", data_)) {
handled = true;
// Set the resulting mime type
mime_type_ = "image/png";
}
#else
#error "Unsupported platform"
#endif
}
if (handled) {
// Indicate the headers are available.
callback->HeadersAvailable();
return true;
}
return false;
}
This problem is really a showstopper for me: not being able to call XmlHttpRequest on my custom scheme.
I hope somebody is willing to look into this problem and hopefully prove that I'm wrong or fix CEF1
Kind Regards,
Mirco Babin