Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
php_utils
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
bp
php_utils
Commits
fed331ea
Commit
fed331ea
authored
Jul 14, 2021
by
mengweifu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update: HttpUtil
parent
e4b3d69f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
19 deletions
+19
-19
HttpUtil.php
src/Http/HttpUtil.php
+19
-19
No files found.
src/Http/HttpUtil.php
View file @
fed331ea
...
...
@@ -28,36 +28,36 @@ class HttpUtil
private
const
CODE_SUCCESS
=
0
;
private
const
CODE_FAIL
=
999999
;
static
function
HEAD
(
$url
,
$timeout
=
10000
,
$retries
=
1
,
$headers
=
false
,
$proxy
=
false
)
static
function
head
(
$url
,
$timeout
=
10000
,
$retries
=
1
,
$headers
=
false
,
$proxy
=
false
)
{
return
self
::
CURL
(
$url
,
$timeout
,
$retries
,
$headers
,
false
,
$proxy
,
'HEAD'
);
return
self
::
curl
(
$url
,
$timeout
,
$retries
,
$headers
,
false
,
$proxy
,
'HEAD'
);
}
static
function
GET
(
$url
,
$params
,
$timeout
=
10000
,
$retries
=
1
,
$headers
=
false
,
$proxy
=
false
,
$curl_opts
=
array
())
static
function
get
(
$url
,
$params
,
$timeout
=
10000
,
$retries
=
1
,
$headers
=
false
,
$proxy
=
false
,
$curl_opts
=
array
())
{
$url
=
$url
.
"?"
.
http_build_query
(
$params
);
return
self
::
CURL
(
$url
,
$timeout
,
$retries
,
$headers
,
[],
$proxy
,
'GET'
,
$curl_opts
);
return
self
::
curl
(
$url
,
$timeout
,
$retries
,
$headers
,
[],
$proxy
,
'GET'
,
$curl_opts
);
}
static
function
PUT
(
$url
,
$post
,
$timeout
=
10000
,
$retries
=
1
,
$headers
=
false
,
$proxy
=
false
)
static
function
put
(
$url
,
$post
,
$timeout
=
10000
,
$retries
=
1
,
$headers
=
false
,
$proxy
=
false
)
{
return
self
::
CURL
(
$url
,
$timeout
,
$retries
,
$headers
,
$post
,
$proxy
,
'PUT'
);
return
self
::
curl
(
$url
,
$timeout
,
$retries
,
$headers
,
$post
,
$proxy
,
'PUT'
);
}
static
function
POST
(
$url
,
$post
,
$timeout
=
10000
,
$retries
=
1
,
$headers
=
false
,
$proxy
=
false
,
$curl_opts
=
array
())
static
function
post
(
$url
,
$post
,
$timeout
=
10000
,
$retries
=
1
,
$headers
=
false
,
$proxy
=
false
,
$curl_opts
=
array
())
{
return
self
::
CURL
(
$url
,
$timeout
,
$retries
,
$headers
,
$post
,
$proxy
,
'POST'
,
$curl_opts
);
return
self
::
curl
(
$url
,
$timeout
,
$retries
,
$headers
,
$post
,
$proxy
,
'POST'
,
$curl_opts
);
}
static
function
DELETE
(
$url
,
$timeout
=
10000
,
$retries
=
1
,
$headers
=
false
,
$proxy
=
false
)
static
function
delete
(
$url
,
$timeout
=
10000
,
$retries
=
1
,
$headers
=
false
,
$proxy
=
false
)
{
return
self
::
CURL
(
$url
,
$timeout
,
$retries
,
$headers
,
false
,
$proxy
,
'DELETE'
);
return
self
::
curl
(
$url
,
$timeout
,
$retries
,
$headers
,
false
,
$proxy
,
'DELETE'
);
}
static
function
CURL
(
$url
,
$timeout
,
$retries
,
$headers
,
$post
=
false
,
$proxy
=
false
,
$method
=
'GET'
,
$curl_opts
=
array
())
static
function
curl
(
$url
,
$timeout
,
$retries
,
$headers
,
$post
=
false
,
$proxy
=
false
,
$method
=
'GET'
,
$curl_opts
=
array
())
{
$ch
=
self
::
CH
(
$url
,
$timeout
,
$headers
,
$post
,
$proxy
,
$method
,
$curl_opts
);
$ch
=
self
::
ch
(
$url
,
$timeout
,
$headers
,
$post
,
$proxy
,
$method
,
$curl_opts
);
$response
=
defaultResponse
();
$response
=
self
::
defaultResponse
();
if
(
is_resource
(
$ch
)
===
true
)
{
...
...
@@ -125,7 +125,7 @@ class HttpUtil
* @param array $curl_opts
* @return false|mixed|resource
*/
static
function
CH
(
$url
,
$timeout
,
$headers
=
false
,
$post
=
false
,
$proxy
=
false
,
$method
=
'GET'
,
$curl_opts
=
array
())
static
function
ch
(
$url
,
$timeout
,
$headers
=
false
,
$post
=
false
,
$proxy
=
false
,
$method
=
'GET'
,
$curl_opts
=
array
())
{
$ch
=
curl_init
(
$url
);
...
...
@@ -182,16 +182,16 @@ class HttpUtil
}
return
$ch
;
}
static
function
MULTI_POST
(
$urls
,
$posts
,
$timeouts
,
$headers
,
$proxies
,
$curl_opts
)
static
function
concurrencyPost
(
$urls
,
$posts
,
$timeouts
,
$headers
,
$proxies
,
$curl_opts
)
:
array
{
$methods
=
[];
foreach
(
$urls
as
$k
=>
$url
)
{
$methods
[
$k
]
=
'POST'
;
}
return
self
::
MULTI_CURL
(
$urls
,
$methods
,
$posts
,
$timeouts
,
$headers
,
$proxies
,
$curl_opts
);
return
self
::
concurrencyCurl
(
$urls
,
$methods
,
$posts
,
$timeouts
,
$headers
,
$proxies
,
$curl_opts
);
}
static
function
MULTI_GET
(
$urls
=
[],
$params
=
[],
$timeouts
=
[],
$headers
=
[],
$proxies
=
[],
$curl_opts
=
[])
static
function
concurrencyGet
(
array
$urls
=
[],
$params
=
[],
$timeouts
=
[],
$headers
=
[],
$proxies
=
[],
$curl_opts
=
[])
:
array
{
$methods
=
$posts
=
[];
foreach
(
$urls
as
$k
=>
$url
)
{
...
...
@@ -200,7 +200,7 @@ class HttpUtil
$posts
[
$k
]
=
false
;
}
return
self
::
MULTI_CURL
(
$urls
,
$methods
,
$posts
,
$timeouts
,
$headers
,
$proxies
,
$curl_opts
);
return
self
::
concurrencyCurl
(
$urls
,
$methods
,
$posts
,
$timeouts
,
$headers
,
$proxies
,
$curl_opts
);
}
/**
...
...
@@ -215,7 +215,7 @@ class HttpUtil
* @param array $curl_opts
* @return array
*/
static
function
MULTI_CURL
(
$urls
=
[],
$methods
=
[],
$posts
=
[],
$timeouts
=
[],
$headers
=
[],
$proxies
=
[],
$curl_opts
=
[])
static
function
concurrencyCurl
(
$urls
=
[],
$methods
=
[],
$posts
=
[],
$timeouts
=
[],
$headers
=
[],
$proxies
=
[],
$curl_opts
=
[])
:
array
{
//step one 初始化一个批处理handle
$mh
=
curl_multi_init
();
...
...
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