Giter Club home page Giter Club logo

Comments (6)

walkor avatar walkor commented on June 16, 2024 2

Please upgrade again.

from http-client.

walkor avatar walkor commented on June 16, 2024 1

Please upgrade to v0.1.6.

from http-client.

walkor avatar walkor commented on June 16, 2024

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.

M0nik avatar M0nik commented on June 16, 2024

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.

M0nik avatar M0nik commented on June 16, 2024

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.

M0nik avatar M0nik commented on June 16, 2024

Awesome! Thank you!

from http-client.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.