Comments (6)
Please upgrade again.
from http-client.
Please upgrade to v0.1.6.
from http-client.
Please show your codes or give an example to reproduce the issue.
For response messages, whether or not a message-body is included with
a message is dependent on both the request method and the response
status code (section 6.1.1). All responses to the HEAD request method
MUST NOT include a message-body, even though the presence of entity-
header fields might lead one to believe they do. All 1xx
(informational), 204 (no content), and 304 (not modified) responses
MUST NOT include a message-body. All other responses do include a
message-body, although it MAY be of zero length.
https://tools.ietf.org/html/rfc2616#section-4.3
According to the RFC specification, 201 and 401 do include a
message-body although it MAY be of zero length. So if the status codes is 201 or 401 the head must include a Message Length
field which can be Transfer-Encoding
or Content-Length
or multipart/byteranges
or By the server closing the connection
to tell the length of message-body.
from http-client.
Example:
<?php
require __DIR__ . '/vendor/autoload.php';
use Workerman\Http\Client;
use Workerman\Worker;
$worker = new Worker();
$worker->count = 1;
$worker->onWorkerStart = function () {
$http_async_client = new Client( [
'connect_timeout' => 10,
'timeout' => 10,
] );
$start_time = microtime( true );
$http_async_client->get(
"https://apip.orangedata.ru:2443/api/v2/devices/status/12345678910/Main",
function () use ( $start_time ) {
echo 'Elapsed time ' . round( microtime( true ) - $start_time, 2 ). ' sec';
}
);
};
Worker::runAll();
Output:
Elapsed time 10.12 sec
from http-client.
Great, it works!
Elapsed time 0.24 sec
There is another issue. In the current implementation, it is not possible to set SSL certificates.
Now I've extended ConnectionPool and Client class and work as follows:
protected function create($address, $ssl = false)
{
$context = [];
if ( !empty( $this->_option['context'] ) ) {
$context = $this->_option['context'];
}
$connection = new AsyncTcpConnection($address, $context);
...
}
$custom_http_client = new Client( [
'connect_timeout' => 10,
'timeout' => 10,
'context' => [
'ssl' => [
'local_cert' => $this->client_crt_path,
'local_pk' => $this->client_key_path,
],
],
] );
What about native support?
from http-client.
Awesome! Thank you!
from http-client.
Related Issues (12)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from http-client.