Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mall.oytour.com
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄奎
mall.oytour.com
Commits
771e5b59
Commit
771e5b59
authored
Apr 01, 2022
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
页面修改
parent
72b93555
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
16 deletions
+14
-16
HttpHelper.cs
Mall.Common/Plugin/HttpHelper.cs
+14
-16
No files found.
Mall.Common/Plugin/HttpHelper.cs
View file @
771e5b59
...
...
@@ -18,8 +18,6 @@ namespace Mall.Common.Plugin
/// </summary>
public
class
HttpHelper
{
/// <summary>
/// Post提交数据
/// </summary>
...
...
@@ -29,7 +27,6 @@ namespace Mall.Common.Plugin
/// <returns></returns>
public
static
string
HttpPost
(
string
url
,
string
body
,
string
contenttype
=
""
)
{
LogHelper
.
Write
(
"测试超时S:"
+
DateTime
.
Now
);
try
{
Encoding
encoding
=
Encoding
.
UTF8
;
...
...
@@ -45,10 +42,9 @@ namespace Mall.Common.Plugin
byte
[]
buffer
=
encoding
.
GetBytes
(
body
);
request
.
ContentLength
=
buffer
.
Length
;
request
.
GetRequestStream
().
Write
(
buffer
,
0
,
buffer
.
Length
);
HttpWebResponse
response
=
(
HttpWebResponse
)
request
.
GetResponse
();
HttpWebResponse
response
=
(
HttpWebResponse
)
request
.
GetResponse
();
using
(
StreamReader
reader
=
new
StreamReader
(
response
.
GetResponseStream
(),
encoding
))
{
LogHelper
.
Write
(
"测试超时E:"
+
DateTime
.
Now
);
return
reader
.
ReadToEnd
();
}
}
...
...
@@ -70,7 +66,7 @@ namespace Mall.Common.Plugin
/// <param name="encode">编码方式</param>
/// <param name="Source">来源</param>
/// <returns></returns>
public
static
string
HttpGet
(
string
url
,
Encoding
encode
,
string
Source
,
string
cookie
=
""
)
public
static
string
HttpGet
(
string
url
,
Encoding
encode
,
string
Source
,
string
cookie
=
""
)
{
HttpWebRequest
myRequest
=
(
HttpWebRequest
)
WebRequest
.
Create
(
url
);
if
(!
string
.
IsNullOrEmpty
(
Source
))
...
...
@@ -138,7 +134,7 @@ namespace Mall.Common.Plugin
HttpWebRequest
req
=
(
HttpWebRequest
)
WebRequest
.
Create
(
url
);
req
.
Method
=
"POST"
;
req
.
ContentType
=
"application/x-www-form-urlencoded"
;
//req.Headers.Add("Accept", "application/json");
//req.Headers.Add("Content-Type", "application/json");
byte
[]
data
=
Encoding
.
UTF8
.
GetBytes
(
postDataStr
);
...
...
@@ -151,7 +147,7 @@ namespace Mall.Common.Plugin
reqStream
.
Close
();
}
HttpWebResponse
rsp
=
(
HttpWebResponse
)
req
.
GetResponse
();
if
(
string
.
IsNullOrWhiteSpace
(
rsp
.
CharacterSet
))
...
...
@@ -255,8 +251,9 @@ namespace Mall.Common.Plugin
/// </summary>
/// <param name="latlng"></param>
/// <returns></returns>
public
static
string
GetGeocoderAddress
(
string
latlng
)
{
string
apiKey
=
"7d9fbeb43e975cd1e9477a7e5d5e192a"
;
public
static
string
GetGeocoderAddress
(
string
latlng
)
{
string
apiKey
=
"7d9fbeb43e975cd1e9477a7e5d5e192a"
;
HttpClient
client
=
new
HttpClient
();
string
url
=
"http://api.map.baidu.com/geocoder?location="
+
latlng
+
"&output=json&key="
+
apiKey
;
try
...
...
@@ -311,7 +308,7 @@ namespace Mall.Common.Plugin
/// <param name="url">请求地址</param>
/// <param name="postDataStr">请求地址</param>
/// <returns>HTTP响应</returns>
public
static
string
HttpPostForGetWXQRCodePath
(
string
url
,
string
postDataStr
,
string
path
)
public
static
string
HttpPostForGetWXQRCodePath
(
string
url
,
string
postDataStr
,
string
path
)
{
HttpWebRequest
req
=
(
HttpWebRequest
)
WebRequest
.
Create
(
url
);
req
.
Method
=
"POST"
;
...
...
@@ -341,7 +338,7 @@ namespace Mall.Common.Plugin
/// <param name="postDataStr"></param>
/// <param name="path"></param>
/// <returns></returns>
public
static
string
HttpPostForGetWXQRCodePathSmallShops
(
string
url
,
string
postDataStr
,
string
path
,
string
ssPhoto
)
public
static
string
HttpPostForGetWXQRCodePathSmallShops
(
string
url
,
string
postDataStr
,
string
path
,
string
ssPhoto
)
{
HttpWebRequest
req
=
(
HttpWebRequest
)
WebRequest
.
Create
(
url
);
req
.
Method
=
"POST"
;
...
...
@@ -407,7 +404,7 @@ namespace Mall.Common.Plugin
stream
=
rsp
.
GetResponseStream
();
return
ReadImageForStream_V2
(
stream
,
path
);
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
LogHelper
.
Write
(
ex
,
"GetResponseAsStringBase64_V2"
);
return
""
;
...
...
@@ -426,7 +423,7 @@ namespace Mall.Common.Plugin
/// <param name="rsp"></param>
/// <param name="encoding"></param>
/// <returns></returns>
private
static
string
GetResponseAsStringBase64_V3
(
HttpWebResponse
rsp
,
Encoding
encoding
,
string
path
,
string
ssPhoto
)
private
static
string
GetResponseAsStringBase64_V3
(
HttpWebResponse
rsp
,
Encoding
encoding
,
string
path
,
string
ssPhoto
)
{
System
.
IO
.
Stream
stream
=
null
;
try
...
...
@@ -453,7 +450,7 @@ namespace Mall.Common.Plugin
/// </summary>
/// <param name="imgstream"></param>
/// <returns></returns>
public
static
string
ReadImageForStream_V2
(
Stream
imgstream
,
string
path
)
public
static
string
ReadImageForStream_V2
(
Stream
imgstream
,
string
path
)
{
System
.
Drawing
.
Image
result
=
System
.
Drawing
.
Image
.
FromStream
(
imgstream
);
System
.
Drawing
.
Bitmap
bit
=
new
System
.
Drawing
.
Bitmap
(
result
);
...
...
@@ -507,7 +504,8 @@ namespace Mall.Common.Plugin
public
static
string
ReadImageForStream_V3
(
Stream
imgstream
,
string
path
,
string
ssPhoto
)
{
System
.
Drawing
.
Image
result
=
System
.
Drawing
.
Image
.
FromStream
(
imgstream
);
if
(!
string
.
IsNullOrEmpty
(
ssPhoto
))
{
if
(!
string
.
IsNullOrEmpty
(
ssPhoto
))
{
WebRequest
wreq
=
WebRequest
.
Create
(
ssPhoto
);
HttpWebResponse
wresp
=
(
HttpWebResponse
)
wreq
.
GetResponse
();
Stream
s
=
wresp
.
GetResponseStream
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment