Comments (3)
By default client is using StreamTransport instead of CurlTransport as described here so your options don't apply. Is it the case?
Thank you for your reminder. I originally used StreamTransport
with CURL Options, but it had no effect.
If you use TimeOut of StreamTransport
you cannot get the information that the connection was interrupted due to TimeOut, but when I change to CurlTransport
I will be able to get the information I want.
from yii2-httpclient.
In addition, it works for me to use the following method, but I still can't get the connection timeout message. If I use $response->getStatusCode()
, you will only get Unable to get status code: referred header information is missing.
, you know there is a problem, but you donβt know where the problem is. It may be a client setting error, it may be a network problem...
header('content-Type: text/plain; charset=utf-8');
try
{
$client = new \yii\httpclient\Client();
$request = $client->createRequest()
->setMethod('GET')
->setUrl(Url::to(['time-out'], 'https'))
->setOptions([
'timeout' => 5,
]);
\yii\helpers\VarDumper::dump($request->toString(), $depth=10, $highlight=false); echo "\n";
$response = $request->send();
\yii\helpers\VarDumper::dump('ok', $depth=10, $highlight=false); echo "\n";
// time out, Unless you call isOk or statusCode, you will not be told time out.
\yii\helpers\VarDumper::dump($response, $depth=10, $highlight=false); echo "\n";
} catch (\yii\httpclient\Exception $e) {
\yii\helpers\VarDumper::dump('error', $depth=10, $highlight=false); echo "\n";
\yii\helpers\VarDumper::dump($e, $depth=10, $highlight=false); echo "\n";
}
exit();
from yii2-httpclient.
By default client is using StreamTransport instead of CurlTransport as described here so your options don't apply. Is it the case?
from yii2-httpclient.
Related Issues (20)
- Memory leak issue when response headers are empty HOT 1
- CurlTransport sends no error code while throwing Exception
- How to get responseTime() after sending request? HOT 4
- Client duplicates the response from the server making it invalid HOT 3
- Undefined variable: http_response_header HOT 1
- Uncaught TypeError when `fopen` returns false on PHP8 HOT 5
- StreamTransport does not verify SSL certificates HOT 3
- Instance with header Bearer HOT 1
- response body with string "0" turn out into null
- Debug panel renders error on PHP 8.1 HOT 1
- Shorcut Get methd with params generates a malformed request (Your client has issued a malformed or illegal request) HOT 2
- debug panel throw ErrorException HOT 2
- update github folder link
- update docs folder link
- update src folder link
- update root folder link
- Unrecognized format HOT 2
- Missing info in documentation HOT 1
- Unable to get status code: referred header information is missing. HOT 2
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 yii2-httpclient.