The extension module for web services works.
WebServiceUtils
01 Syntax
02 Methods
| Name | Overloads | Summary |
|---|---|---|
| isURL | 1 | Determine that is this uri string is a network location? (判断这个uri字符串是否是一个网络位置) |
| isFilePath | 1 | is the file path in the url data or a unix file path? |
| IsURLPattern | 1 | is a web location? |
| BuildReqparm | 2 | Build the request parameters for the HTTP POST |
| IsSocketPortOccupied | 1 | Only one usage of each socket address (protocol/network address/port) Is normally permitted |
| ParseUrlQueryParameters | 1 | Create a parameter dictionary from the request parameter tokens. |
| QueryStringParameters | 1 | 不像WebServiceUtils.PostUrlDataParser())函数,这个函数不会替换掉转义字符,并且所有的Key都已经被默认转换为小写形式的了 |
| BuildUrlData | 1 | 生成URL请求的参数 |
| BuildArgs | 1 | Build the url query arguments string |
| UrlDecode | 2 | |
| UrlEncode | 1 | 进行url编码,将特殊字符进行转码 |
| UrlPathEncode | 1 | 编码整个URL,这个函数会自动截取出query string parameter部分,然后对截取出来的query string parameter进行编码 |
| PostUrlDataParser | 1 | 假若你的数据之中包含有SHA256的加密数据,则非常不推荐使用这个函数进行解析。因为请注意,这个函数会替换掉一些转义字符的,所以会造成一些非常隐蔽的BUG |
| GetRequest | 2 | GET http request |
| GetRequestRaw | 1 | GET http request |
| PostRequest | 2 | POST http request |
| PostMultipartForm | 1 | A wrapper web client for set a longer operation timeout |
| POST | 2 | POST http request for get html |
| POSTFile | 1 | 通过post上传文件 |
| DownloadFile | 1 | download the file from strUrl to local file. |
| GetDownload | 1 | Download file from http request and save to a specific location. |
| GetMyIPAddress | 1 | 获取我的公网IP地址,假若没有连接互联网的话则会返回局域网IP地址 |
| getIPAddressInternal | 1 | Request an external server and then returns the ip address from the server side. |
03 Properties
| Name | Overloads | Summary |
|---|---|---|
| Protocols | 1 | Web protocols enumeration |
| Proxy | 1 | Example for xx-net tool: http://127.0.0.1:10809/ |
| DefaultUA | 1 | 设置默认的http请求的user-agent,默认为Google Chrome的UA字符串 |
| LocalIPAddress | 1 | Gets the IP address of this local machine. |
04 Fields
| Name | Overloads | Summary |
|---|---|---|
| URLPattern | 2 | regex pattern for http url |
| UrlLinkPattern | 2 | regex pattern for any kind of url protocol |
| MicrosoftDNS | 1 | Microsoft DNS Server |
| UnixPathPattern | 1 |
05 Members
String)Determine that is this uri string is a network location? (判断这个uri字符串是否是一个网络位置)
| Name | Type | Description |
|---|---|---|
url | String | - |
String, Boolean)is the file path in the url data or a unix file path?
| Name | Type | Description |
|---|---|---|
url | String | - |
includeWindowsFs | Boolean | and also test for the windows file path pattern? |
String)is a web location?
| Name | Type | Description |
|---|---|---|
str | String | - |
Dictionary(Of String, String))Build the request parameters for the HTTP POST
| Name | Type | Description |
|---|---|---|
dict | Dictionary(Of String, String) | - |
IEnumerable(Of KeyValuePair(Of String, String)))Build the request parameters for the HTTP POST
| Name | Type | Description |
|---|---|---|
data | IEnumerable(Of KeyValuePair(Of String, String)) | - |
Exception)Only one usage of each socket address (protocol/network address/port) Is normally permitted
| Name | Type | Description |
|---|---|---|
ex | Exception | - |
String(), Boolean)Create a parameter dictionary from the request parameter tokens. (请注意,字典的key默认为转换为小写的形式)
| Name | Type | Description |
|---|---|---|
tokens | String() | 元素的个数必须要大于1,因为从url里面解析出来的元素之中第一个元素是url本身,则不再对url做字典解析 |
2016-11-21
因为post可能会传递数组数据进来,则这个时候就会出现重复的键名,则已经不再适合字典类型了,这里改为返回NameValueCollection
String, Boolean)不像WebServiceUtils.PostUrlDataParser()函数,这个函数不会替换掉转义字符,并且所有的Key都已经被默认转换为小写形式的了
| Name | Type | Description |
|---|---|---|
url | String | URL parameters |
IEnumerable(Of KeyValuePair(Of String, String)), Boolean, Boolean)生成URL请求的参数
| Name | Type | Description |
|---|---|---|
data | IEnumerable(Of KeyValuePair(Of String, String)) | - |
escaping | Boolean | 是否进行对value部分的字符串数据进行转义 |
String()())Build the url query arguments string
| Name | Type | Description |
|---|---|---|
params | String()() | - |
String)在服务器端对URL进行解码还原
| Name | Type | Description |
|---|---|---|
s | String | - |
String, Boolean)进行url编码,将特殊字符进行转码
A extension method wrapper for WebUtility.UrlEncode()
| Name | Type | Description |
|---|---|---|
s | String | - |
jswhitespace | Boolean | 空格符号默认被转义为 |
String)编码整个URL,这个函数会自动截取出query string parameter部分,然后对截取出来的query string parameter进行编码
| Name | Type | Description |
|---|---|---|
s | String | - |
String, Boolean)假若你的数据之中包含有SHA256的加密数据,则非常不推荐使用这个函数进行解析。因为请注意,这个函数会替换掉一些转义字符的,所以会造成一些非常隐蔽的BUG
| Name | Type | Description |
|---|---|---|
data | String | 转义的时候大小写无关 |
String, String()())GET http request
| Name | Type | Description |
|---|---|---|
strUrl$ | String | - |
args | String()() | - |
String, Boolean, String)GET http request
| Name | Type | Description |
|---|---|---|
url | String | - |
String, Boolean, String, Dictionary(Of String, String))GET http request
| Name | Type | Description |
|---|---|---|
url | String | - |
https | Boolean | - |
userAgent | String | fix a bug for github API: Protocol violation using Github api You need to set UserAgent like this: webRequest.UserAgent = "YourAppName" Otherwise it will give The server committed a protocol violation. Section=ResponseStatusLine Error. |
this function returns a stream object that produced by the HttpResponseMessage content stream
String, IEnumerable(Of KeyValuePair(Of String, String)), Boolean)POST http request
| Name | Type | Description |
|---|---|---|
url | String | - |
params | IEnumerable(Of KeyValuePair(Of String, String)) | - |
String, String()())POST http request
| Name | Type | Description |
|---|---|---|
url | String | - |
params | String()() | - |
String, Dictionary(Of String, String))A wrapper web client for set a longer operation timeout
String, NameValueCollection, Dictionary(Of String, String), String, String, Encodings, Int32, Int32, Boolean)POST http request for get html. (请注意,假若params之中含有字符串数组的话,则会出错,这个时候需要使用 WebServiceUtils.POST()方法)
| Name | Type | Description |
|---|---|---|
url$ | String | - |
params | NameValueCollection | - |
Referer | Dictionary(Of String, String) | - |
this function will returns nothing if the http error happends.
String, Dictionary(Of String, String()), String, String, String, Boolean, String)POST http request for get html
| Name | Type | Description |
|---|---|---|
url$ | String | - |
data | Dictionary(Of String, String()) | - |
Referer$ | String | - |
通过post上传文件
| Name | Type | Description |
|---|---|---|
url$ | String | - |
name$ | Byte() | - |
referer$ | String | - |
String, String, String, String, Int32, String, Int32, Boolean, String)download the file from strUrl to local file.
| Name | Type | Description |
|---|---|---|
strUrl | String | - |
save | String | The file path of the file saved |
String, String)Download file from http request and save to a specific location. (使用GET方法下载文件)
| Name | Type | Description |
|---|---|---|
url | String | - |
savePath | String | - |
获取我的公网IP地址,假若没有连接互联网的话则会返回局域网IP地址
Request an external server and then returns the ip address from the server side.
Web protocols enumeration
Example for xx-net tool:
http://127.0.0.1:10809/设置默认的http请求的user-agent,默认为Google Chrome的UA字符串
Gets the IP address of this local machine. (获取本机对象的IP地址,请注意这个属性获取得到的仅仅是本机在局域网内的ip地址, 假若需要获取得到公网IP地址,还需要外部服务器的帮助才行)
becareful, this property may produce IPV6 address if avaiable
regex pattern for http url
regex pattern for any kind of url protocol
Microsoft DNS Server
String, TextWriter)