Example #1
0
static HRESULT WINAPI BindStatusCallback_OnProgress(IBindStatusCallback *iface,
        ULONG ulProgress, ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
{
    BindStatusCallback *This = impl_from_IBindStatusCallback(iface);
    DWORD status_code;

    TRACE("(%p)->(%d %d %d %s)\n", This, ulProgress, ulProgressMax, ulStatusCode,
          debugstr_w(szStatusText));

    switch(ulStatusCode) {
    case BINDSTATUS_REDIRECTING:
        return set_dochost_url(This->doc_host, szStatusText);
    case BINDSTATUS_BEGINDOWNLOADDATA:
        set_status_text(This, szStatusText); /* FIXME: "Start downloading from site: %s" */
        status_code = get_http_status_code(This->binding);
        if(status_code != HTTP_STATUS_OK)
            handle_navigation_error(This->doc_host, status_code, This->url, NULL);
        return S_OK;
    case BINDSTATUS_ENDDOWNLOADDATA:
        set_status_text(This, szStatusText); /* FIXME: "Downloading from site: %s" */
        return S_OK;
    case BINDSTATUS_CLASSIDAVAILABLE:
    case BINDSTATUS_MIMETYPEAVAILABLE:
    case BINDSTATUS_BEGINSYNCOPERATION:
    case BINDSTATUS_ENDSYNCOPERATION:
        return S_OK;
    default:
        FIXME("status code %u\n", ulStatusCode);
    }

    return S_OK;
}
Example #2
0
DWORD https_raw_request(int dopost, char *http_host, short http_port, char *http_headers, char *http_url, const char *accept_types[], unsigned char *http_data, unsigned int http_data_len, unsigned char **response_data){
	HINTERNET internetopenhandle = NULL;
	HINTERNET internetconnecthandle = NULL;
	HINTERNET httpopenrequesthandle = NULL;
	BOOL ishttpsendrequest = FALSE;
	DWORD http_response_code = -1;
	DWORD http_response_content_length = 0;
	char *ua;

	ua = get_default_ua();
	if (ua == NULL){
		ua = malloc(32);
		if (ua = NULL){
			return http_response_code;
		}
		RtlZeroMemory(ua, 32);
		strcpy_s(ua, 32, SH_DEFAULT_UA);
	}
	internetopenhandle = InternetOpen(ua, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
	if (internetopenhandle == NULL){
		return http_response_code;
	}

	internetconnecthandle = InternetConnect(internetopenhandle, http_host, http_port, NULL, NULL, INTERNET_SERVICE_HTTP, INTERNET_FLAG_RELOAD, 0);
	if (internetconnecthandle == NULL){
		return http_response_code;
	}

	/* adjust http verb according to flag */
	if (dopost){
		httpopenrequesthandle = HttpOpenRequest(internetconnecthandle, "POST", http_url, NULL, NULL, accept_types, INTERNET_FLAG_SECURE, 0);
	}
	else{
		httpopenrequesthandle = HttpOpenRequest(internetconnecthandle, "GET", http_url, NULL, NULL, accept_types, INTERNET_FLAG_SECURE, 0);
	}

	if (httpopenrequesthandle == NULL){
		return http_response_code;
	}

	/* send the actual request */
	ishttpsendrequest = HttpSendRequest(httpopenrequesthandle, http_headers, -1, http_data, http_data_len);
	if (!ishttpsendrequest){
		return http_response_code;
	}

	/* retrieve http response status code */
	http_response_code = get_http_status_code(httpopenrequesthandle);
	if (http_response_code == -1){
		return http_response_code;
	}

	/* assume that we can retrieve length */
	http_response_content_length = get_http_content_length(httpopenrequesthandle, 1);

	if (http_response_content_length == -1){
		return http_response_code;
	}

	/* get the actual response content */
	*response_data = get_http_content(httpopenrequesthandle, http_response_content_length);
	if (*response_data == NULL){
		return http_response_code;
	}

	/* cleanup after ourselfs */
	zfree(ua);
	InternetCloseHandle(httpopenrequesthandle);
	InternetCloseHandle(internetconnecthandle);
	InternetCloseHandle(internetopenhandle);
	return http_response_code;
}