Merge pull request #2711 from dumganhar/xmlhttprequest-fix-develop

fixed #2243: XMLHttpRequest don't support non-ascii characters.
This commit is contained in:
James Chen 2013-06-02 20:43:45 -07:00
commit fc816fde84
1 changed files with 9 additions and 5 deletions

View File

@ -628,7 +628,7 @@ JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, send)
{
JSString *str = NULL;
char *data = NULL;
std::string data;
// Clean up header map. New request, new headers!
http_header.clear();
@ -636,12 +636,13 @@ JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, send)
if (!JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "S", &str)) {
return JS_FALSE;
};
data = JS_EncodeString(cx, str);
JSStringWrapper strWrap(str);
data = strWrap.get();
}
if (data != NULL && meth.compare("post") == 0 || meth.compare("POST") == 0) {
cc_request->setRequestData(data, strlen(data));
if (data.length() > 0 && (meth.compare("post") == 0 || meth.compare("POST") == 0)) {
cc_request->setRequestData(data.c_str(), data.length());
}
_setHttpRequestHeader();
@ -700,7 +701,10 @@ JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, getResponseHeader)
return JS_FALSE;
};
char *data = JS_EncodeString(cx, header_value);
std::string data;
JSStringWrapper strWrap(header_value);
data = strWrap.get();
stringstream streamdata;
streamdata << data;