C# Class Steamworks.SteamGameServerHTTP

Show file Open project: rlabrecque/Steamworks.NET

Public Methods

Method Description
CreateCookieContainer ( bool bAllowResponsesToModify ) : HTTPCookieContainerHandle

Creates a cookie container handle which you must later free with ReleaseCookieContainer(). If bAllowResponsesToModify=true

than any response to your requests using this cookie container may add new cookies which may be transmitted with

future requests. If bAllowResponsesToModify=false than only cookies you explicitly set will be sent. This API is just for

during process lifetime, after steam restarts no cookies are persisted and you have no way to access the cookie container across

repeat executions of your process.

CreateHTTPRequest ( EHTTPMethod eHTTPRequestMethod, string pchAbsoluteURL ) : HTTPRequestHandle

Initializes a new HTTP request, returning a handle to use in further operations on it. Requires

the method (GET or POST) and the absolute URL for the request. Both http and https are supported,

so this string must start with http:// or https:// and should look like http://store.steampowered.com/app/250/

or such.

DeferHTTPRequest ( HTTPRequestHandle hRequest ) : bool

Defers a request you have sent, the actual HTTP client code may have many requests queued, and this will move

the specified request to the tail of the queue. Returns false on invalid handle, or if the request is not yet sent.

GetHTTPDownloadProgressPct ( HTTPRequestHandle hRequest, float &pflPercentOut ) : bool

Gets progress on downloading the body for the request. This will be zero unless a response header has already been

received which included a content-length field. For responses that contain no content-length it will report

zero for the duration of the request as the size is unknown until the connection closes.

GetHTTPRequestWasTimedOut ( HTTPRequestHandle hRequest, bool &pbWasTimedOut ) : bool

Check if the reason the request failed was because we timed it out (rather than some harder failure)

GetHTTPResponseBodyData ( HTTPRequestHandle hRequest, byte pBodyDataBuffer, uint unBufferSize ) : bool

Gets the body data from a HTTP response given a handle from HTTPRequestCompleted_t, will return false if the

handle is invalid or is to a streaming response, or if the provided buffer is not the correct size. Use BGetHTTPResponseBodySize first to find out

the correct buffer size to use.

GetHTTPResponseBodySize ( HTTPRequestHandle hRequest, uint &unBodySize ) : bool

Gets the size of the body data from a HTTP response given a handle from HTTPRequestCompleted_t, will return false if the

handle is invalid.

GetHTTPResponseHeaderSize ( HTTPRequestHandle hRequest, string pchHeaderName, uint &unResponseHeaderSize ) : bool

Checks if a response header is present in a HTTP response given a handle from HTTPRequestCompleted_t, also

returns the size of the header value if present so the caller and allocate a correctly sized buffer for

GetHTTPResponseHeaderValue.

GetHTTPResponseHeaderValue ( HTTPRequestHandle hRequest, string pchHeaderName, byte pHeaderValueBuffer, uint unBufferSize ) : bool

Gets header values from a HTTP response given a handle from HTTPRequestCompleted_t, will return false if the

header is not present or if your buffer is too small to contain it's value. You should first call

BGetHTTPResponseHeaderSize to check for the presence of the header and to find out the size buffer needed.

GetHTTPStreamingResponseBodyData ( HTTPRequestHandle hRequest, uint cOffset, byte pBodyDataBuffer, uint unBufferSize ) : bool

Gets the body data from a streaming HTTP response given a handle from HTTPRequestDataReceived_t. Will return false if the

handle is invalid or is to a non-streaming response (meaning it wasn't sent with SendHTTPRequestAndStreamResponse), or if the buffer size and offset

do not match the size and offset sent in HTTPRequestDataReceived_t.

PrioritizeHTTPRequest ( HTTPRequestHandle hRequest ) : bool

Prioritizes a request you have sent, the actual HTTP client code may have many requests queued, and this will move

the specified request to the head of the queue. Returns false on invalid handle, or if the request is not yet sent.

ReleaseCookieContainer ( HTTPCookieContainerHandle hCookieContainer ) : bool

Release a cookie container you are finished using, freeing it's memory

ReleaseHTTPRequest ( HTTPRequestHandle hRequest ) : bool

Releases an HTTP response handle, should always be called to free resources after receiving a HTTPRequestCompleted_t

callback and finishing using the response.

SendHTTPRequest ( HTTPRequestHandle hRequest, SteamAPICall_t &pCallHandle ) : bool

Sends the HTTP request, will return false on a bad handle, otherwise use SteamCallHandle to wait on

asynchronous response via callback.

Note: If the user is in offline mode in Steam, then this will add a only-if-cached cache-control

header and only do a local cache lookup rather than sending any actual remote request.

SendHTTPRequestAndStreamResponse ( HTTPRequestHandle hRequest, SteamAPICall_t &pCallHandle ) : bool

Sends the HTTP request, will return false on a bad handle, otherwise use SteamCallHandle to wait on

asynchronous response via callback for completion, and listen for HTTPRequestHeadersReceived_t and

HTTPRequestDataReceived_t callbacks while streaming.

SetCookie ( HTTPCookieContainerHandle hCookieContainer, string pchHost, string pchUrl, string pchCookie ) : bool

Adds a cookie to the specified cookie container that will be used with future requests.

SetHTTPRequestAbsoluteTimeoutMS ( HTTPRequestHandle hRequest, uint unMilliseconds ) : bool

Set an absolute timeout on the HTTP request, this is just a total time timeout different than the network activity timeout

which can bump everytime we get more data

SetHTTPRequestContextValue ( HTTPRequestHandle hRequest, ulong ulContextValue ) : bool

Set a context value for the request, which will be returned in the HTTPRequestCompleted_t callback after

sending the request. This is just so the caller can easily keep track of which callbacks go with which request data.

SetHTTPRequestCookieContainer ( HTTPRequestHandle hRequest, HTTPCookieContainerHandle hCookieContainer ) : bool

Set the cookie container to use for a HTTP request

SetHTTPRequestGetOrPostParameter ( HTTPRequestHandle hRequest, string pchParamName, string pchParamValue ) : bool

Set a GET or POST parameter value on the request, which is set will depend on the EHTTPMethod specified

when creating the request. Must be called prior to sending the request. Will return false if the

handle is invalid or the request is already sent.

SetHTTPRequestHeaderValue ( HTTPRequestHandle hRequest, string pchHeaderName, string pchHeaderValue ) : bool

Set a request header value for the request, must be called prior to sending the request. Will

return false if the handle is invalid or the request is already sent.

SetHTTPRequestNetworkActivityTimeout ( HTTPRequestHandle hRequest, uint unTimeoutSeconds ) : bool

Set a timeout in seconds for the HTTP request, must be called prior to sending the request. Default

timeout is 60 seconds if you don't call this. Returns false if the handle is invalid, or the request

has already been sent.

SetHTTPRequestRawPostBody ( HTTPRequestHandle hRequest, string pchContentType, byte pubBody, uint unBodyLen ) : bool

Sets the body for an HTTP Post request. Will fail and return false on a GET request, and will fail if POST params

have already been set for the request. Setting this raw body makes it the only contents for the post, the pchContentType

parameter will set the content-type header for the request so the server may know how to interpret the body.

SetHTTPRequestRequiresVerifiedCertificate ( HTTPRequestHandle hRequest, bool bRequireVerifiedCertificate ) : bool

Set that https request should require verified SSL certificate via machines certificate trust store

SetHTTPRequestUserAgentInfo ( HTTPRequestHandle hRequest, string pchUserAgentInfo ) : bool

Set the extra user agent info for a request, this doesn't clobber the normal user agent, it just adds the extra info on the end

Method Details

CreateCookieContainer() public static method

Creates a cookie container handle which you must later free with ReleaseCookieContainer(). If bAllowResponsesToModify=true

than any response to your requests using this cookie container may add new cookies which may be transmitted with

future requests. If bAllowResponsesToModify=false than only cookies you explicitly set will be sent. This API is just for

during process lifetime, after steam restarts no cookies are persisted and you have no way to access the cookie container across

repeat executions of your process.

public static CreateCookieContainer ( bool bAllowResponsesToModify ) : HTTPCookieContainerHandle
bAllowResponsesToModify bool
return HTTPCookieContainerHandle

CreateHTTPRequest() public static method

Initializes a new HTTP request, returning a handle to use in further operations on it. Requires

the method (GET or POST) and the absolute URL for the request. Both http and https are supported,

so this string must start with http:// or https:// and should look like http://store.steampowered.com/app/250/

or such.

public static CreateHTTPRequest ( EHTTPMethod eHTTPRequestMethod, string pchAbsoluteURL ) : HTTPRequestHandle
eHTTPRequestMethod EHTTPMethod
pchAbsoluteURL string
return HTTPRequestHandle

DeferHTTPRequest() public static method

Defers a request you have sent, the actual HTTP client code may have many requests queued, and this will move

the specified request to the tail of the queue. Returns false on invalid handle, or if the request is not yet sent.

public static DeferHTTPRequest ( HTTPRequestHandle hRequest ) : bool
hRequest HTTPRequestHandle
return bool

GetHTTPDownloadProgressPct() public static method

Gets progress on downloading the body for the request. This will be zero unless a response header has already been

received which included a content-length field. For responses that contain no content-length it will report

zero for the duration of the request as the size is unknown until the connection closes.

public static GetHTTPDownloadProgressPct ( HTTPRequestHandle hRequest, float &pflPercentOut ) : bool
hRequest HTTPRequestHandle
pflPercentOut float
return bool

GetHTTPRequestWasTimedOut() public static method

Check if the reason the request failed was because we timed it out (rather than some harder failure)

public static GetHTTPRequestWasTimedOut ( HTTPRequestHandle hRequest, bool &pbWasTimedOut ) : bool
hRequest HTTPRequestHandle
pbWasTimedOut bool
return bool

GetHTTPResponseBodyData() public static method

Gets the body data from a HTTP response given a handle from HTTPRequestCompleted_t, will return false if the

handle is invalid or is to a streaming response, or if the provided buffer is not the correct size. Use BGetHTTPResponseBodySize first to find out

the correct buffer size to use.

public static GetHTTPResponseBodyData ( HTTPRequestHandle hRequest, byte pBodyDataBuffer, uint unBufferSize ) : bool
hRequest HTTPRequestHandle
pBodyDataBuffer byte
unBufferSize uint
return bool

GetHTTPResponseBodySize() public static method

Gets the size of the body data from a HTTP response given a handle from HTTPRequestCompleted_t, will return false if the

handle is invalid.

public static GetHTTPResponseBodySize ( HTTPRequestHandle hRequest, uint &unBodySize ) : bool
hRequest HTTPRequestHandle
unBodySize uint
return bool

GetHTTPResponseHeaderSize() public static method

Checks if a response header is present in a HTTP response given a handle from HTTPRequestCompleted_t, also

returns the size of the header value if present so the caller and allocate a correctly sized buffer for

GetHTTPResponseHeaderValue.

public static GetHTTPResponseHeaderSize ( HTTPRequestHandle hRequest, string pchHeaderName, uint &unResponseHeaderSize ) : bool
hRequest HTTPRequestHandle
pchHeaderName string
unResponseHeaderSize uint
return bool

GetHTTPResponseHeaderValue() public static method

Gets header values from a HTTP response given a handle from HTTPRequestCompleted_t, will return false if the

header is not present or if your buffer is too small to contain it's value. You should first call

BGetHTTPResponseHeaderSize to check for the presence of the header and to find out the size buffer needed.

public static GetHTTPResponseHeaderValue ( HTTPRequestHandle hRequest, string pchHeaderName, byte pHeaderValueBuffer, uint unBufferSize ) : bool
hRequest HTTPRequestHandle
pchHeaderName string
pHeaderValueBuffer byte
unBufferSize uint
return bool

GetHTTPStreamingResponseBodyData() public static method

Gets the body data from a streaming HTTP response given a handle from HTTPRequestDataReceived_t. Will return false if the

handle is invalid or is to a non-streaming response (meaning it wasn't sent with SendHTTPRequestAndStreamResponse), or if the buffer size and offset

do not match the size and offset sent in HTTPRequestDataReceived_t.

public static GetHTTPStreamingResponseBodyData ( HTTPRequestHandle hRequest, uint cOffset, byte pBodyDataBuffer, uint unBufferSize ) : bool
hRequest HTTPRequestHandle
cOffset uint
pBodyDataBuffer byte
unBufferSize uint
return bool

PrioritizeHTTPRequest() public static method

Prioritizes a request you have sent, the actual HTTP client code may have many requests queued, and this will move

the specified request to the head of the queue. Returns false on invalid handle, or if the request is not yet sent.

public static PrioritizeHTTPRequest ( HTTPRequestHandle hRequest ) : bool
hRequest HTTPRequestHandle
return bool

ReleaseCookieContainer() public static method

Release a cookie container you are finished using, freeing it's memory

public static ReleaseCookieContainer ( HTTPCookieContainerHandle hCookieContainer ) : bool
hCookieContainer HTTPCookieContainerHandle
return bool

ReleaseHTTPRequest() public static method

Releases an HTTP response handle, should always be called to free resources after receiving a HTTPRequestCompleted_t

callback and finishing using the response.

public static ReleaseHTTPRequest ( HTTPRequestHandle hRequest ) : bool
hRequest HTTPRequestHandle
return bool

SendHTTPRequest() public static method

Sends the HTTP request, will return false on a bad handle, otherwise use SteamCallHandle to wait on

asynchronous response via callback.

Note: If the user is in offline mode in Steam, then this will add a only-if-cached cache-control

header and only do a local cache lookup rather than sending any actual remote request.

public static SendHTTPRequest ( HTTPRequestHandle hRequest, SteamAPICall_t &pCallHandle ) : bool
hRequest HTTPRequestHandle
pCallHandle SteamAPICall_t
return bool

SendHTTPRequestAndStreamResponse() public static method

Sends the HTTP request, will return false on a bad handle, otherwise use SteamCallHandle to wait on

asynchronous response via callback for completion, and listen for HTTPRequestHeadersReceived_t and

HTTPRequestDataReceived_t callbacks while streaming.

public static SendHTTPRequestAndStreamResponse ( HTTPRequestHandle hRequest, SteamAPICall_t &pCallHandle ) : bool
hRequest HTTPRequestHandle
pCallHandle SteamAPICall_t
return bool

SetCookie() public static method

Adds a cookie to the specified cookie container that will be used with future requests.

public static SetCookie ( HTTPCookieContainerHandle hCookieContainer, string pchHost, string pchUrl, string pchCookie ) : bool
hCookieContainer HTTPCookieContainerHandle
pchHost string
pchUrl string
pchCookie string
return bool

SetHTTPRequestAbsoluteTimeoutMS() public static method

Set an absolute timeout on the HTTP request, this is just a total time timeout different than the network activity timeout

which can bump everytime we get more data

public static SetHTTPRequestAbsoluteTimeoutMS ( HTTPRequestHandle hRequest, uint unMilliseconds ) : bool
hRequest HTTPRequestHandle
unMilliseconds uint
return bool

SetHTTPRequestContextValue() public static method

Set a context value for the request, which will be returned in the HTTPRequestCompleted_t callback after

sending the request. This is just so the caller can easily keep track of which callbacks go with which request data.

public static SetHTTPRequestContextValue ( HTTPRequestHandle hRequest, ulong ulContextValue ) : bool
hRequest HTTPRequestHandle
ulContextValue ulong
return bool

SetHTTPRequestCookieContainer() public static method

Set the cookie container to use for a HTTP request

public static SetHTTPRequestCookieContainer ( HTTPRequestHandle hRequest, HTTPCookieContainerHandle hCookieContainer ) : bool
hRequest HTTPRequestHandle
hCookieContainer HTTPCookieContainerHandle
return bool

SetHTTPRequestGetOrPostParameter() public static method

Set a GET or POST parameter value on the request, which is set will depend on the EHTTPMethod specified

when creating the request. Must be called prior to sending the request. Will return false if the

handle is invalid or the request is already sent.

public static SetHTTPRequestGetOrPostParameter ( HTTPRequestHandle hRequest, string pchParamName, string pchParamValue ) : bool
hRequest HTTPRequestHandle
pchParamName string
pchParamValue string
return bool

SetHTTPRequestHeaderValue() public static method

Set a request header value for the request, must be called prior to sending the request. Will

return false if the handle is invalid or the request is already sent.

public static SetHTTPRequestHeaderValue ( HTTPRequestHandle hRequest, string pchHeaderName, string pchHeaderValue ) : bool
hRequest HTTPRequestHandle
pchHeaderName string
pchHeaderValue string
return bool

SetHTTPRequestNetworkActivityTimeout() public static method

Set a timeout in seconds for the HTTP request, must be called prior to sending the request. Default

timeout is 60 seconds if you don't call this. Returns false if the handle is invalid, or the request

has already been sent.

public static SetHTTPRequestNetworkActivityTimeout ( HTTPRequestHandle hRequest, uint unTimeoutSeconds ) : bool
hRequest HTTPRequestHandle
unTimeoutSeconds uint
return bool

SetHTTPRequestRawPostBody() public static method

Sets the body for an HTTP Post request. Will fail and return false on a GET request, and will fail if POST params

have already been set for the request. Setting this raw body makes it the only contents for the post, the pchContentType

parameter will set the content-type header for the request so the server may know how to interpret the body.

public static SetHTTPRequestRawPostBody ( HTTPRequestHandle hRequest, string pchContentType, byte pubBody, uint unBodyLen ) : bool
hRequest HTTPRequestHandle
pchContentType string
pubBody byte
unBodyLen uint
return bool

SetHTTPRequestRequiresVerifiedCertificate() public static method

Set that https request should require verified SSL certificate via machines certificate trust store

public static SetHTTPRequestRequiresVerifiedCertificate ( HTTPRequestHandle hRequest, bool bRequireVerifiedCertificate ) : bool
hRequest HTTPRequestHandle
bRequireVerifiedCertificate bool
return bool

SetHTTPRequestUserAgentInfo() public static method

Set the extra user agent info for a request, this doesn't clobber the normal user agent, it just adds the extra info on the end

public static SetHTTPRequestUserAgentInfo ( HTTPRequestHandle hRequest, string pchUserAgentInfo ) : bool
hRequest HTTPRequestHandle
pchUserAgentInfo string
return bool