MCPcopy Create free account
hub / github.com/9miao/CrossApp / JS_BINDED_FUNC_IMPL

Function JS_BINDED_FUNC_IMPL

scripting/javascript/bindings/XMLHTTPRequest.cpp:574–621  ·  view source on GitHub ↗

* @brief initialize new xhr. * */

Source from the content-addressed store, hash-verified

572 *
573 */
574JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, open)
575{
576
577 if (argc >= 2) {
578 jsval* argv = JS_ARGV(cx, vp);
579 const char* method;
580 const char* urlstr;
581 JSBool async = true;
582 JSString* jsMethod = JS_ValueToString(cx, argv[0]);
583 JSString* jsURL = JS_ValueToString(cx, argv[1]);
584
585 if (argc > 2) {
586 JS_ValueToBoolean(cx, argv[2], &async);
587 }
588
589 JSStringWrapper w1(jsMethod);
590 JSStringWrapper w2(jsURL);
591 method = w1;
592 urlstr = w2;
593
594 url = urlstr;
595 meth = method;
596 readyState = 1;
597 isAsync = async;
598
599 if (url.length() > 5 && url.compare(url.length() - 5, 5, ".json") == 0) {
600 responseType = kRequestResponseTypeJSON;
601 }
602
603 if (meth.compare("post") == 0 || meth.compare("POST") == 0) {
604 cc_request->setRequestType(extension::CCHttpRequest::kHttpPost);
605 }
606 else {
607 cc_request->setRequestType(extension::CCHttpRequest::kHttpGet);
608 }
609
610 cc_request->setUrl(url.c_str());
611
612 isNetwork = true;
613 readyState = OPENED;
614
615 return JS_TRUE;
616 }
617
618 JS_ReportError(cx, "invalid call: %s", __FUNCTION__);
619 return JS_FALSE;
620
621}
622
623/**
624 * @brief send xhr

Callers

nothing calls this directly

Calls 11

STRING_TO_JSVALFunction · 0.50
lengthMethod · 0.45
compareMethod · 0.45
setUrlMethod · 0.45
c_strMethod · 0.45
clearMethod · 0.45
getMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
strMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected