Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
system
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
_site-res
system
Commits
3ed4cb42
Commit
3ed4cb42
authored
Aug 27, 2018
by
tufengqi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
并发http修复
parent
009f70fa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
7 deletions
+19
-7
SwooleHttpClient.php
classes/fpf/http/SwooleHttpClient.php
+12
-6
SwooleHttpClient.php
classes/fpf/thrift/SwooleHttpClient.php
+7
-1
No files found.
classes/fpf/http/SwooleHttpClient.php
View file @
3ed4cb42
...
...
@@ -2,7 +2,7 @@
namespace
fpf\http
;
use
fpf\http\exception\Swo
ft
HttpException
;
use
fpf\http\exception\Swo
ole
HttpException
;
use
Swoole\Coroutine\Http\Client
;
class
SwooleHttpClient
...
...
@@ -24,9 +24,9 @@ class SwooleHttpClient
/**
* Buffer for the HTTP request data
*
* @var
string
* @var
array
*/
protected
$post_
fields
;
protected
$post_
arr
;
/**
* http headers
...
...
@@ -125,7 +125,13 @@ class SwooleHttpClient
register_shutdown_function
([
$this
,
'closeCurlHandle'
]);
$full_url
=
$this
->
full_url
;
$parts
=
parse_url
(
$full_url
);
$this
->
curl_handle
=
new
Client
(
$parts
[
'host'
],
(
$parts
[
'port'
]
??
80
),
'http'
===
$parts
[
'scheme'
]
?
false
:
true
);
$scheme
=
'http'
===
$parts
[
'scheme'
]
?
false
:
true
;
$parts
[
'port'
]
=
$parts
[
'port'
]
??
''
;
if
(
true
===
$scheme
&&
!
$parts
[
'port'
])
{
$parts
[
'port'
]
=
443
;
}
$parts
[
'port'
]
=
intval
(
$parts
[
'port'
]
??
80
);
$this
->
curl_handle
=
new
Client
(
$parts
[
'host'
],
$parts
[
'port'
],
$scheme
);
$full_url
=
$this
->
full_url
;
$headers
=
[];
foreach
(
$this
->
headers
as
$key
=>
$value
)
{
...
...
@@ -135,10 +141,10 @@ class SwooleHttpClient
$options
[
'headers'
][
VERSION_KEY
]
=
VERSION_VALUE_NO_PTEFIX
;
}
if
(
self
::
METHOD_POST
===
$this
->
method
)
{
$options
[
'body'
]
=
$this
->
request_
;
$options
[
'body'
]
=
$this
->
post_arr
;
}
$options
[
'timeout'
]
=
$this
->
timeout_ms
/
1000
;
$
this
->
post_fields
=
''
;
$
options
[
'headers'
]
=
$options
[
'headers'
]
??
[]
;
$this
->
curl_handle
->
setHeaders
(
$options
[
'headers'
]);
$this
->
curl_handle
->
set
([
'timeout'
=>
$options
[
'timeout'
]]);
if
(
self
::
METHOD_POST
===
$this
->
method
)
{
...
...
classes/fpf/thrift/SwooleHttpClient.php
View file @
3ed4cb42
...
...
@@ -219,7 +219,13 @@ class SwooleHttpClient extends \Thrift\Transport\TTransport
$this
->
request_
=
''
;
$full_url
=
$this
->
scheme_
.
"://"
.
$host
.
$this
->
uri_
;
$parts
=
parse_url
(
$full_url
);
$this
->
handle
=
new
Client
(
$parts
[
'host'
],
(
$parts
[
'port'
]
??
80
),
'http'
===
$parts
[
'scheme'
]
?
false
:
true
);
$parts
[
'port'
]
=
$parts
[
'port'
]
??
''
;
$scheme
=
'http'
===
$parts
[
'scheme'
]
?
false
:
true
;
if
(
true
===
$scheme
&&
!
$parts
[
'port'
])
{
$parts
[
'port'
]
=
443
;
}
$parts
[
'port'
]
=
intval
(
$parts
[
'port'
]
??
80
);
$this
->
handle
=
new
Client
(
$parts
[
'host'
],
$parts
[
'port'
],
$scheme
);
$this
->
handle
->
setHeaders
(
$options
[
'headers'
]);
$this
->
handle
->
set
([
'timeout'
=>
$options
[
'timeout'
]]);
$this
->
handle
->
post
(
$this
->
uri_
,
$options
[
'body'
]);
...
...
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