winhttp

package
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2024 License: GPL-3.0, BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Rendered for windows/amd64

Overview

Copyright (C) 2018, Rapid7 LLC, Boston, MA, USA. All rights reserved. This material contains unpublished, copyrighted work including confidential and proprietary information of Rapid7.

Index

Constants

View Source
const (
	// WINHTTP_AUTOPROXY_AUTO_DETECT - Attempt to automatically discover the URL of the PAC file using both DHCP and DNS queries to the local network.
	WINHTTP_AUTOPROXY_AUTO_DETECT = 0x00000001
	// WINHTTP_AUTOPROXY_CONFIG_URL - Download the PAC file from the URL specified by lpszAutoConfigUrl in the WINHTTP_AUTOPROXY_OPTIONS structure.
	WINHTTP_AUTOPROXY_CONFIG_URL = 0x00000002
	// WINHTTP_AUTO_DETECT_TYPE_DHCP - Use DHCP to locate the proxy auto-configuration file.
	WINHTTP_AUTO_DETECT_TYPE_DHCP = 0x00000001
	// WINHTTP_AUTO_DETECT_TYPE_DNS_A - Use DNS to attempt to locate the proxy auto-configuration file at a well-known location on the domain of the local computer.
	WINHTTP_AUTO_DETECT_TYPE_DNS_A = 0x00000002
	// WINHTTP_ACCESS_TYPE_NO_PROXY - Resolves all host names directly without a proxy.
	WINHTTP_ACCESS_TYPE_NO_PROXY = 0x00000001
)

noinspection SpellCheckingInspection,GoNameStartsWithPackageName,GoSnakeCaseUsage

Variables

This section is empty.

Functions

func CloseHandle

func CloseHandle(hInternet HInternet) error

MSDN: ``` The WinHttpCloseHandle function closes a single HINTERNET handle.

BOOLAPI WinHttpCloseHandle(
  IN HINTERNET hInternet
);

hInternet

Valid HINTERNET handle to be closed.

Returns TRUE if the handle is successfully closed, or FALSE otherwise. ```

func LpwstrToString

func LpwstrToString(d Lpwstr) string

noinspection SpellCheckingInspection

func SetTimeouts

func SetTimeouts(hInternet HInternet, nResolveTimeout int, nConnectTimeout int, nSendTimeout int, nReceiveTimeout int) error

The WinHttpSetTimeouts function sets time-outs involved with HTTP transactions.

BOOLAPI WinHttpSetTimeouts(
  IN HINTERNET hInternet,
  IN int       nResolveTimeout,
  IN int       nConnectTimeout,
  IN int       nSendTimeout,
  IN int       nReceiveTimeout
);

hInternet

The HINTERNET handle returned by WinHttpOpen or WinHttpOpenRequest.

nResolveTimeout

A value of type integer that specifies the time-out value, in milliseconds, to use for name resolution. If resolution takes longer than this time-out value, the action is canceled. The initial value is zero, meaning no time-out (infinite).

nConnectTimeout

A value of type integer that specifies the time-out value, in milliseconds, to use for server connection requests. If a connection request takes longer than this time-out value, the request is canceled. The initial value is 60,000 (60 seconds).
TCP/IP can time out while setting up the socket during the three leg SYN/ACK exchange, regardless of the value of this parameter.

nSendTimeout

A value of type integer that specifies the time-out value, in milliseconds, to use for sending requests. If sending a request takes longer than this time-out value, the send is canceled. The initial value is 30,000 (30 seconds).

nReceiveTimeout

A value of type integer that specifies the time-out value, in milliseconds, to receive a response to a request. If a response takes longer than this time-out value, the request is canceled. The initial value is 30,000 (30 seconds).

Returns TRUE if successful, or FALSE otherwise.

func StringToLpwstr

func StringToLpwstr(s string) *uint16

noinspection SpellCheckingInspection

Types

type Allocated

type Allocated interface {
	Free() error
}

noinspection SpellCheckingInspection

type AutoProxyOptions

type AutoProxyOptions struct {
	DwFlags           Dword
	DwAutoDetectFlags Dword
	LpszAutoConfigUrl Lpwstr

	FAutoLogonIfChallenged bool
	// contains filtered or unexported fields
}
typedef struct __unnamed_struct_4 {
  DWORD   dwFlags;
  DWORD   dwAutoDetectFlags;
  LPCWSTR lpszAutoConfigUrl;
  LPVOID  lpvReserved;
  DWORD   dwReserved;
  BOOL    fAutoLogonIfChallenged;
} WINHTTP_AUTOPROXY_OPTIONS;

type CurrentUserIEProxyConfig

type CurrentUserIEProxyConfig struct {
	FAutoDetect       bool
	LpszAutoConfigUrl Lpwstr
	LpszProxy         Lpwstr
	LpszProxyBypass   Lpwstr
}
typedef struct WINHTTP_CURRENT_USER_IE_PROXY_CONFIG {
  BOOL   fAutoDetect;
  LPWSTR lpszAutoConfigUrl;
  LPWSTR lpszProxy;
  LPWSTR lpszProxyBypass;
};

func GetIEProxyConfigForCurrentUser

func GetIEProxyConfigForCurrentUser() (*CurrentUserIEProxyConfig, error)

The WinHttpGetIEProxyConfigForCurrentUser function retrieves the Internet Explorer proxy configuration for the current user.

BOOLAPI WinHttpGetIEProxyConfigForCurrentUser(
  IN OUT WINHTTP_CURRENT_USER_IE_PROXY_CONFIG *pProxyConfig
);

pProxyConfig

A pointer, on input, to a WINHTTP_CURRENT_USER_IE_PROXY_CONFIG structure. On output, the structure contains the Internet Explorer proxy settings for the current active network connection (for example, LAN, dial-up, or VPN connection).

Returns TRUE if successful, or FALSE otherwise.

noinspection SpellCheckingInspection

func (*CurrentUserIEProxyConfig) Free

func (p *CurrentUserIEProxyConfig) Free() error

noinspection SpellCheckingInspection

type Dword

type Dword uint32

noinspection SpellCheckingInspection

type HInternet

type HInternet uintptr

noinspection SpellCheckingInspection

func Open

func Open(pszAgentW Lpwstr, dwAccessType Dword, pszProxyW Lpwstr, pszProxyBypassW Lpwstr, dwFlags Dword) (HInternet, error)

MSDN: ``` The WinHttpOpen function initializes, for an application, the use of WinHTTP functions and returns a WinHTTP-session handle.

WINHTTPAPI HINTERNET WinHttpOpen(
  LPCWSTR pszAgentW,
  DWORD   dwAccessType,
  LPCWSTR pszProxyW,
  LPCWSTR pszProxyBypassW,
  DWORD   dwFlags
);

pszAgentW

A pointer to a string variable that contains the name of the application or entity calling the WinHTTP functions. This name is used as the user agent in the HTTP protocol.

dwAccessType

Type of access required.

pszProxyW

A pointer to a string variable that contains the name of the proxy server to use when proxy access is specified by setting dwAccessType to WINHTTP_ACCESS_TYPE_NAMED_PROXY. The WinHTTP functions recognize only CERN type proxies for HTTP. If dwAccessType is not set to WINHTTP_ACCESS_TYPE_NAMED_PROXY, this parameter must be set to WINHTTP_NO_PROXY_NAME.

pszProxyBypassW

A pointer to a string variable that contains an optional semicolon delimited list of host names or IP addresses, or both, that should not be routed through the proxy when dwAccessType is set to WINHTTP_ACCESS_TYPE_NAMED_PROXY. The list can contain wildcard characters. Do not use an empty string, because the WinHttpOpen function uses it as the proxy bypass list. If this parameter specifies the "<local>" macro in the list as the only entry, this function bypasses any host name that does not contain a period. If dwAccessType is not set to WINHTTP_ACCESS_TYPE_NAMED_PROXY, this parameter must be set to WINHTTP_NO_PROXY_BYPASS.

dwFlags

Unsigned long integer value that contains the flags that indicate various options affecting the behavior of this function.

Returns a valid session handle if successful, or NULL otherwise. To retrieve extended error information, call GetLastError. ```

noinspection SpellCheckingInspection

type Lpwstr

type Lpwstr *uint16

noinspection SpellCheckingInspection

type ProxyInfo

type ProxyInfo struct {
	DwAccessType    Dword
	LpszProxy       Lpwstr
	LpszProxyBypass Lpwstr
}
typedef struct WINHTTP_PROXY_INFO {
  DWORD  dwAccessType;
  LPWSTR lpszProxy;
  LPWSTR lpszProxyBypass;
}  *LPWINHTTP_PROXY_INFO;

func GetDefaultProxyConfiguration

func GetDefaultProxyConfiguration() (*ProxyInfo, error)

The WinHttpGetDefaultProxyConfiguration function retrieves the default WinHTTP proxy configuration from the registry.

WINHTTPAPI BOOL WinHttpGetDefaultProxyConfiguration(
  IN OUT WINHTTP_PROXY_INFO *pProxyInfo
);

pProxyInfo

A pointer to a variable of type WINHTTP_PROXY_INFO that receives the default proxy configuration.

Returns TRUE if successful or FALSE otherwise.

func GetProxyForUrl

func GetProxyForUrl(hInternet HInternet, lpcwszUrl Lpwstr, pAutoProxyOptions *AutoProxyOptions) (*ProxyInfo, error)

MSDN: ``` The WinHttpGetProxyForUrl function retrieves the proxy data for the specified URL.

BOOLAPI WinHttpGetProxyForUrl(
  IN HINTERNET                 hSession,
  IN LPCWSTR                   lpcwszUrl,
  IN WINHTTP_AUTOPROXY_OPTIONS *pAutoProxyOptions,
  OUT WINHTTP_PROXY_INFO       *pProxyInfo
);

hSession

The WinHTTP session handle returned by the WinHttpOpen function.

lpcwszUrl

A pointer to a null-terminated Unicode string that contains the URL of the HTTP request that the application is preparing to send.

pAutoProxyOptions

A pointer to a WINHTTP_AUTOPROXY_OPTIONS structure that specifies the auto-proxy options to use.

pProxyInfo

A pointer to a WINHTTP_PROXY_INFO structure that receives the proxy setting. This structure is then applied to the request handle using the WINHTTP_OPTION_PROXY option. Free the lpszProxy and lpszProxyBypass strings contained in this structure (if they are non-NULL) using the GlobalFree function.

If the function succeeds, the function returns TRUE. If the function fails, it returns FALSE. For extended error data, call GetLastError. ```

noinspection SpellCheckingInspection

func (*ProxyInfo) Free

func (p *ProxyInfo) Free() error

noinspection SpellCheckingInspection

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL