void FrameLoaderClientImpl::dispatchWillRequestResource(FetchRequest* request)
{
    if (m_webFrame->client()) {
        WebCachedURLRequest urlRequest(request);
        m_webFrame->client()->willRequestResource(m_webFrame, urlRequest);
    }
}
Esempio n. 2
0
	cJSON* do_login(const char* _interface, const char* _content)
	{
		const wchar_t* headers[] = {L"Content-Type:application/json\r\n"};

		char buf[128];
		wchar url[128];

		cl::StringUtil::format(buf, 128, "http://%s/v2/logon", g_host);
		cl::StringUtil::char_to_wchar(url, 128, buf);

		char* response;
		int len;
		unsigned long code;
		int ret = urlRequest(url, L"POST", headers, 1, _content, 0, &code, &response, &len);

		if(ret)
		{
			if(code == 200)
			{
				cJSON* root = cJSON_Parse(response);
				free(response);
				return root;
			}
			else
			{
				free(response);
				return NULL;
			}
		}
		return NULL;
	}
Esempio n. 3
0
	st action(const char* _id, st type)
	{
		wchar_t header1[128];
		wchar_t header2[128];
		const wchar_t* arr[2];
		arr[0] = header1;
		arr[1] = header2;

		wchar url[128];
		char buf[128];

		cl::StringUtil::format(buf, 128, "Authorization: %s\r\n", g_token);
		cl::StringUtil::char_to_wchar(header1, 128, buf);

		cl::StringUtil::copy(buf, 128, "Content-Type: application/json\r\n");
		cl::StringUtil::char_to_wchar(header2, 128, buf);

		cl::StringUtil::format(buf, 128, "http://%s/v2/instances/%s/action", g_host, _id);
		cl::StringUtil::char_to_wchar(url, 128, buf);


		cJSON* root = cJSON_CreateObject();
		const char* action_str;
		switch(type)
		{
			case -1:
				action_str = "poweroff";
				break;
			case 0:
				action_str = "shutdown";
				break;
			case 1:
				action_str = "start";
				break;
		}
		cJSON_AddItemToObject(root, "action", cJSON_CreateString(action_str));
		char* str = cJSON_PrintUnformatted(root);
		cJSON_Delete(root);

		char* response;
		int len;
		unsigned long code;
		int ret = urlRequest(url, L"POST", arr, 2, str, 0, &code, &response, &len);
		free(str);

		if(cl::StringUtil::compare(response, "null"))
			ret = TRUE;
		else
			ret = FALSE;
		free(response);
		return ret;
	}
Esempio n. 4
0
	cJSON* do_get_list()
	{
		wchar header[128];
		const wchar_t* arr[1];
		arr[0] = header;

		wchar url[128];
		char buf[128];

		cl::StringUtil::format(buf, 128, "Authorization: %s\r\n", g_token);
		cl::StringUtil::char_to_wchar(header, 128, buf);

		cl::StringUtil::format(buf, 128, "http://%s/v2/instances", g_host);
		cl::StringUtil::char_to_wchar(url, 128, buf);

		char* response;
		int len;
		unsigned long code;
		int ret = urlRequest(url, L"GET", arr, 1, NULL, 0, &code, &response, &len);

		if(ret)
		{
			if(code == 200)
			{
				cJSON* root = cJSON_Parse(response);
				cl_free(response);
				return root;
			}
			else
			{
				cl_free(response);
				return NULL;
			}
		}
		return NULL;
	}
Esempio n. 5
0
void loadFrame(WebFrame* frame, const std::string& url) {
  WebURLRequest urlRequest(URLTestHelpers::toKURL(url));
  frame->loadRequest(urlRequest);
  pumpPendingRequestsForFrameToLoad(frame);
}