In generally, I can use the following codes to get something on one URL
- Code: Select all
// Create a CefRequest for the specified URL.
CefRefPtr<CefRequest> request = CefRequest::Create();
request->SetURL(url);
request->SetMethod("GET");
// Callback to be executed on request completion.
// It's safe to use base::Unretained() here because there is only one
// RequestClient pending at any given time and we explicitly detach the
// callback in the Handler destructor.
const RequestClient::Callback& callback =
base::Bind(&HappSyncHandler::OnRequestComplete, base::Unretained(this));
// Create and start the new CefURLRequest.
urlrequest_ = CefURLRequest::Create(request,
new RequestClient(callback),
NULL);
if the URL I want to visit need Authorization, I can do it on Windows:
- Code: Select all
lpszAgent = "WinInetGet/0.1";
hInternet = InternetOpen(lpszAgent,INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
lpszVerb = "GET";
serverDomain="api.website.com";
port=443;
InternetConnect(hInternet, serverDomain, port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
DWORD dwOpenRequestFlags = INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP |
INTERNET_FLAG_KEEP_CONNECTION |
INTERNET_FLAG_NO_AUTH |
INTERNET_FLAG_NO_COOKIES |
INTERNET_FLAG_NO_UI |
//use HTTPS
INTERNET_FLAG_SECURE |
INTERNET_FLAG_RELOAD;
//init Request
string Authheader= "Authorization: Bearer "+token;
HINTERNET hRequest = HttpOpenRequest(hConnect, lpszVerb, lpszObjectName, NULL,
NULL, NULL,
dwOpenRequestFlags, 0);
HttpAddRequestHeaders(hRequest, Authheader.c_str(), -1, HTTP_ADDREQ_FLAG_ADD|HTTP_ADDREQ_FLAG_REPLACE);
//send Request
BOOL bResult = HttpSendRequest(hRequest, NULL, 0, NULL, 0);
but how can I do the same thing with CEF3 api?