C# Class Argentini.Halide.H3Http

The H3Http class contains methods and properties for performing or evaluating HTTP operations. This includes cookies, domain redirection, and more.
Afficher le fichier Open project: argentini/Halide

Méthodes publiques

Méthode Description
AddCrossBrowserClientRedirect ( Page pageToAddScriptTo, String url ) : void

Add a cross browser compliant client side redirect (which ensures that the Referrer value will be not null on the subsequent page) with a zero second delay.

AddCrossBrowserClientRedirect ( Page pageToAddScriptTo, String url, Int32 seconds ) : void

Add a cross browser compliant client side redirect (which ensures that the Referrer value will be not null on the subsequent page).

AddUrlParamPrefix ( String urlParams ) : String

When passed a URL parameter list, it is returned with the leading "?", or as a blank string if there are no parameters. This method is used to ensure that a URL parameter list starts with a "?".

DeleteUrlParameter ( String urlParam ) : String

Remove a URL parameter from the current URL parameter list and return the new request string.

DeleteUrlParameter ( String urlParam, String urlParameterString ) : String

Remove a URL parameter and return the new request string.

DomainRedirect ( String defaultPageName, String domainName ) : String

Determine if the user needs to be redirected to a new URL, for sites that have multiple domain names, but one primary (e.g. like catching misspellings in domain names). The transport (e.g. http://) is not used or returned with the result of the method.

GetBrowser ( String userAgent ) : String

Return the browser name and version.

GetBrowser ( String userAgent, System.Int64 &majorVersion, System.Int64 &minorVersion, System.Int64 &buildVersion, String &browserName ) : String

Return the browser name and version.

GetBrowserMajorVersion ( ) : String

Return the browser major version number.

GetBrowserMinorVersion ( ) : String

Return the browser minor version number.

GetBrowserName ( ) : String

Return the browser name.

GetBrowserVersion ( String browserName ) : Double

Return the version of specific browser based on HTTP headers or -1 if the request came from another browser.

GetCurrentPageName ( ) : String

Retrieve the current page file name on disk.

GetFirefoxVersion ( ) : Double

Return the version of Mozilla Firefox being used or -1 if the request came from another browser.

GetHost ( ) : String

Get the fully qualified domain name of the current URL.

GetHostRoot ( ) : String

Get the root domain from the fully qualified domain name of the current URL. (e.g. if visiting "www.mydomain.com", "mydomain.com" is returned.)

GetIPAddress ( ) : String

Return the IP address of a web visitor.

GetInternetExplorerVersion ( ) : Double

Return the version of Internet Explorer being used or -1 if the request came from another browser.

GetOSType ( ) : String

Return the operating system type for the current user agent

GetOSType ( String userAgent ) : String

Return the operating system type and version for the current user agent

GetOSType ( String userAgent, System.Int64 &majorVersion, System.Int64 &minorVersion, System.Int64 &buildVersion, String &osName ) : String

Return the operating system type for the current user agent

GetRedirectCodeText ( Int32 redirectCode ) : String

Contains the following Indexes: 301,302,303,304,305,307

GetSafariVersion ( ) : Double

Return the version of Apple Safari being used or -1 if the request came from another browser.

GetUrlParams ( ) : String

Get the current URL parameters as a single string, without the leading "?".

GetUrlParams ( System.Boolean includePrefix ) : String

Get the current URL parameters as a single string, without the leading "?".

GetWebPage ( String url ) : String

Perform an Http GET operation, and return the result.

GetWebPage ( String url, CookieContainer cookies ) : String

Perform an Http GET operation, passing cookies, and return the result.

GetWebPage ( String url, GetWebPageMethod method, CookieContainer cookies, String postData, String userName, String password ) : String

Perform an Http GET or POST operation, passing cookies, post data, user name and password, and return the result.

GetWebPage ( String url, GetWebPageMethod method, CookieContainer cookies, String postData, String userName, String password, Int32 timeoutMilliseconds ) : String

Perform an Http GET or POST operation, passing cookies, post data, user name and password, and return the result.

GetWebPage ( String url, GetWebPageMethod method, String postData ) : String

Perform an Http GET or POST operation, and return the result.

GetWebPage ( String url, Int32 timeoutMilliseconds ) : String

Perform an Http GET operation, and return the result. Timeout in milliseconds is passed as well.

GetWebPage ( String url, String userName, String password ) : String

Perform an Http GET operation, passing credentials, and return the result.

Redirect ( Page pageToRedirect, String redirectLocation, Int32 code ) : void

Core redirect function. Redirects the provided page using the provided redirect code and location. Usage: H3Http.Redirect(this, "http://fynydd.com", 301);

Redirect303 ( Page pageToRedirect, String redirectLocation ) : void

Commonly used 303 redirect ("See Other"). Redirects the user, but the browser is instructed not to cache this response. Similar to 307, but more SEO friendly. Usage: H3Http.Redirect303(this, "http://fynydd.com");

Redirect307 ( Page pageToRedirect, String redirectLocation ) : void

Commonly used 307 redirect ("Temporary Redirect"). Redirects the user, but the browser is instructed that it *should* not cache this response (not guaranteed). Usage: H3Http.Redirect307(this, "http://fynydd.com");

SetUrlParameterValue ( String urlParam, String value ) : String

Add or Edit a URL parameter value in the current URL. If the parameter exists, it is modified. Otherwise, its value is changed.

SetUrlParameterValue ( String urlParam, String value, String urlParameterString ) : String

Add or Edit a URL parameter value. If the parameter exists on the supplied URL parameter string, it is modified. Otherwise, its value is changed.

WriteBinaryFile ( String url, String filePath ) : System.Int64

Read a binary file from a URL and write it to disk.

Private Methods

Méthode Description
BuildMatch ( String pattern, String userAgent, String browser, Int32 versionIndex, String browserNameVersionFallback, String &browserName, System.Int64 &majorVersion, System.Int64 &minorVersion, System.Int64 &buildVersion ) : String
H3Http ( ) : System

Method Details

AddCrossBrowserClientRedirect() public static méthode

Add a cross browser compliant client side redirect (which ensures that the Referrer value will be not null on the subsequent page) with a zero second delay.
public static AddCrossBrowserClientRedirect ( Page pageToAddScriptTo, String url ) : void
pageToAddScriptTo System.Web.UI.Page The page to which the ClientScript will be Registered as a StartupScript.
url String String representation of a URL to which the page will redirect.
Résultat void

AddCrossBrowserClientRedirect() public static méthode

Add a cross browser compliant client side redirect (which ensures that the Referrer value will be not null on the subsequent page).
public static AddCrossBrowserClientRedirect ( Page pageToAddScriptTo, String url, Int32 seconds ) : void
pageToAddScriptTo System.Web.UI.Page The page to which the ClientScript will be Registered as a StartupScript.
url String String representation of a URL to which the page will redirect.
seconds System.Int32 Int32 value of seconds to delay before redirecting.
Résultat void

AddUrlParamPrefix() public static méthode

When passed a URL parameter list, it is returned with the leading "?", or as a blank string if there are no parameters. This method is used to ensure that a URL parameter list starts with a "?".
public static AddUrlParamPrefix ( String urlParams ) : String
urlParams String URL parameters list with or without the leading "?".
Résultat String

DeleteUrlParameter() public static méthode

Remove a URL parameter from the current URL parameter list and return the new request string.
public static DeleteUrlParameter ( String urlParam ) : String
urlParam String Name of the URL parameter to remove.
Résultat String

DeleteUrlParameter() public static méthode

Remove a URL parameter and return the new request string.
public static DeleteUrlParameter ( String urlParam, String urlParameterString ) : String
urlParam String Name of the URL parameter to remove.
urlParameterString String The URL parameter string to modify, without the leading "?".
Résultat String

DomainRedirect() public static méthode

Determine if the user needs to be redirected to a new URL, for sites that have multiple domain names, but one primary (e.g. like catching misspellings in domain names). The transport (e.g. http://) is not used or returned with the result of the method.
public static DomainRedirect ( String defaultPageName, String domainName ) : String
defaultPageName String default page file name used on the site (e.g. default.aspx).
domainName String Primary domain name that should be used (e.g. nonsequiturs.com).
Résultat String

GetBrowser() public static méthode

Return the browser name and version.
public static GetBrowser ( String userAgent ) : String
userAgent String Browser user agent string
Résultat String

GetBrowser() public static méthode

Return the browser name and version.
public static GetBrowser ( String userAgent, System.Int64 &majorVersion, System.Int64 &minorVersion, System.Int64 &buildVersion, String &browserName ) : String
userAgent String Browser user agent string
majorVersion System.Int64 Output of major version
minorVersion System.Int64 Output of minor version
buildVersion System.Int64 Output of build version
browserName String Output of browser name
Résultat String

GetBrowserMajorVersion() public static méthode

Return the browser major version number.
public static GetBrowserMajorVersion ( ) : String
Résultat String

GetBrowserMinorVersion() public static méthode

Return the browser minor version number.
public static GetBrowserMinorVersion ( ) : String
Résultat String

GetBrowserName() public static méthode

Return the browser name.
public static GetBrowserName ( ) : String
Résultat String

GetBrowserVersion() public static méthode

Return the version of specific browser based on HTTP headers or -1 if the request came from another browser.
public static GetBrowserVersion ( String browserName ) : Double
browserName String
Résultat Double

GetCurrentPageName() public static méthode

Retrieve the current page file name on disk.
public static GetCurrentPageName ( ) : String
Résultat String

GetFirefoxVersion() public static méthode

Return the version of Mozilla Firefox being used or -1 if the request came from another browser.
public static GetFirefoxVersion ( ) : Double
Résultat Double

GetHost() public static méthode

Get the fully qualified domain name of the current URL.
public static GetHost ( ) : String
Résultat String

GetHostRoot() public static méthode

Get the root domain from the fully qualified domain name of the current URL. (e.g. if visiting "www.mydomain.com", "mydomain.com" is returned.)
public static GetHostRoot ( ) : String
Résultat String

GetIPAddress() public static méthode

Return the IP address of a web visitor.
public static GetIPAddress ( ) : String
Résultat String

GetInternetExplorerVersion() public static méthode

Return the version of Internet Explorer being used or -1 if the request came from another browser.
public static GetInternetExplorerVersion ( ) : Double
Résultat Double

GetOSType() public static méthode

Return the operating system type for the current user agent
public static GetOSType ( ) : String
Résultat String

GetOSType() public static méthode

Return the operating system type and version for the current user agent
public static GetOSType ( String userAgent ) : String
userAgent String Web browser User Agent string
Résultat String

GetOSType() public static méthode

Return the operating system type for the current user agent
public static GetOSType ( String userAgent, System.Int64 &majorVersion, System.Int64 &minorVersion, System.Int64 &buildVersion, String &osName ) : String
userAgent String Web browser User Agent string
majorVersion System.Int64 Output of major version
minorVersion System.Int64 Output of minor version
buildVersion System.Int64 Output of build version
osName String Output of OS name
Résultat String

GetRedirectCodeText() public static méthode

Contains the following Indexes: 301,302,303,304,305,307
public static GetRedirectCodeText ( Int32 redirectCode ) : String
redirectCode System.Int32 Redirect Code number (e.g. 301)
Résultat String

GetSafariVersion() public static méthode

Return the version of Apple Safari being used or -1 if the request came from another browser.
public static GetSafariVersion ( ) : Double
Résultat Double

GetUrlParams() public static méthode

Get the current URL parameters as a single string, without the leading "?".
public static GetUrlParams ( ) : String
Résultat String

GetUrlParams() public static méthode

Get the current URL parameters as a single string, without the leading "?".
public static GetUrlParams ( System.Boolean includePrefix ) : String
includePrefix System.Boolean Include the leading "?" if there are parameters.
Résultat String

GetWebPage() public static méthode

Perform an Http GET operation, and return the result.
public static GetWebPage ( String url ) : String
url String Fully qualified URL to the remote page.
Résultat String

GetWebPage() public static méthode

Perform an Http GET operation, passing cookies, and return the result.
public static GetWebPage ( String url, CookieContainer cookies ) : String
url String Fully qualified URL to the remote page.
cookies System.Net.CookieContainer CookieContainer variable for sending cookies.
Résultat String

GetWebPage() public static méthode

Perform an Http GET or POST operation, passing cookies, post data, user name and password, and return the result.
public static GetWebPage ( String url, GetWebPageMethod method, CookieContainer cookies, String postData, String userName, String password ) : String
url String Fully qualified URL to the remote page.
method GetWebPageMethod GetWebPageMethod enum value.
cookies System.Net.CookieContainer CookieContainer variable for sending cookies.
postData String String post data for sending a post.
userName String User name string for Windows Authentication.
password String password string for Windows Authentication.
Résultat String

GetWebPage() public static méthode

Perform an Http GET or POST operation, passing cookies, post data, user name and password, and return the result.
public static GetWebPage ( String url, GetWebPageMethod method, CookieContainer cookies, String postData, String userName, String password, Int32 timeoutMilliseconds ) : String
url String Fully qualified URL to the remote page.
method GetWebPageMethod GetWebPageMethod enum value.
cookies System.Net.CookieContainer CookieContainer variable for sending cookies.
postData String String post data for sending a post.
userName String User name string for Windows Authentication.
password String password string for Windows Authentication.
timeoutMilliseconds System.Int32 Timeout in milliseconds for the request.
Résultat String

GetWebPage() public static méthode

Perform an Http GET or POST operation, and return the result.
public static GetWebPage ( String url, GetWebPageMethod method, String postData ) : String
url String Fully qualified URL to the remote page.
method GetWebPageMethod GetWebPageMethod enum value.
postData String String post data for sending a post.
Résultat String

GetWebPage() public static méthode

Perform an Http GET operation, and return the result. Timeout in milliseconds is passed as well.
public static GetWebPage ( String url, Int32 timeoutMilliseconds ) : String
url String Fully qualified URL to the remote page.
timeoutMilliseconds System.Int32 Timeout in milliseconds for the request.
Résultat String

GetWebPage() public static méthode

Perform an Http GET operation, passing credentials, and return the result.
public static GetWebPage ( String url, String userName, String password ) : String
url String Fully qualified URL to the remote page.
userName String User name string for Windows Authentication.
password String password string for Windows Authentication.
Résultat String

Redirect() public static méthode

Core redirect function. Redirects the provided page using the provided redirect code and location. Usage: H3Http.Redirect(this, "http://fynydd.com", 301);
public static Redirect ( Page pageToRedirect, String redirectLocation, Int32 code ) : void
pageToRedirect System.Web.UI.Page The Page object which is to be redirected
redirectLocation String The url to which the page will be redirected
code System.Int32 The 3 digit (301,302,303,304,305, or 307) redirect code to use.
Résultat void

Redirect303() public static méthode

Commonly used 303 redirect ("See Other"). Redirects the user, but the browser is instructed not to cache this response. Similar to 307, but more SEO friendly. Usage: H3Http.Redirect303(this, "http://fynydd.com");
public static Redirect303 ( Page pageToRedirect, String redirectLocation ) : void
pageToRedirect System.Web.UI.Page The Page object which is to be redirected
redirectLocation String The url to which the page will be redirected
Résultat void

Redirect307() public static méthode

Commonly used 307 redirect ("Temporary Redirect"). Redirects the user, but the browser is instructed that it *should* not cache this response (not guaranteed). Usage: H3Http.Redirect307(this, "http://fynydd.com");
public static Redirect307 ( Page pageToRedirect, String redirectLocation ) : void
pageToRedirect System.Web.UI.Page The Page object which is to be redirected
redirectLocation String The url to which the page will be redirected
Résultat void

SetUrlParameterValue() public static méthode

Add or Edit a URL parameter value in the current URL. If the parameter exists, it is modified. Otherwise, its value is changed.
public static SetUrlParameterValue ( String urlParam, String value ) : String
urlParam String Name of the URL parameter.
value String Value of the URL parameter to add or edit.
Résultat String

SetUrlParameterValue() public static méthode

Add or Edit a URL parameter value. If the parameter exists on the supplied URL parameter string, it is modified. Otherwise, its value is changed.
public static SetUrlParameterValue ( String urlParam, String value, String urlParameterString ) : String
urlParam String Name of the URL parameter.
value String Value of the URL parameter to add or edit.
urlParameterString String The URL parameter string to modify, without the leading "?".
Résultat String

WriteBinaryFile() public static méthode

Read a binary file from a URL and write it to disk.
public static WriteBinaryFile ( String url, String filePath ) : System.Int64
url String URL to the web resource.
filePath String Web-style path for the destination file on disk, including new file name.
Résultat System.Int64