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.
显示文件 Open project: argentini/Halide

Public Methods

Method 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

Method 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 method

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.
return void

AddCrossBrowserClientRedirect() public static method

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.
return void

AddUrlParamPrefix() public static method

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 "?".
return String

DeleteUrlParameter() public static method

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.
return String

DeleteUrlParameter() public static method

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 "?".
return String

DomainRedirect() public static method

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).
return String

GetBrowser() public static method

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

GetBrowser() public static method

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
return String

GetBrowserMajorVersion() public static method

Return the browser major version number.
public static GetBrowserMajorVersion ( ) : String
return String

GetBrowserMinorVersion() public static method

Return the browser minor version number.
public static GetBrowserMinorVersion ( ) : String
return String

GetBrowserName() public static method

Return the browser name.
public static GetBrowserName ( ) : String
return String

GetBrowserVersion() public static method

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
return Double

GetCurrentPageName() public static method

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

GetFirefoxVersion() public static method

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

GetHost() public static method

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

GetHostRoot() public static method

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
return String

GetIPAddress() public static method

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

GetInternetExplorerVersion() public static method

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

GetOSType() public static method

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

GetOSType() public static method

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
return String

GetOSType() public static method

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
return String

GetRedirectCodeText() public static method

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)
return String

GetSafariVersion() public static method

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

GetUrlParams() public static method

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

GetUrlParams() public static method

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.
return String

GetWebPage() public static method

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

GetWebPage() public static method

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.
return String

GetWebPage() public static method

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.
return String

GetWebPage() public static method

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.
return String

GetWebPage() public static method

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.
return String

GetWebPage() public static method

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.
return String

GetWebPage() public static method

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.
return String

Redirect() public static method

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.
return void

Redirect303() public static method

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
return void

Redirect307() public static method

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
return void

SetUrlParameterValue() public static method

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.
return String

SetUrlParameterValue() public static method

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 "?".
return String

WriteBinaryFile() public static method

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.
return System.Int64