- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在通过 Guzzle 3.8.1 发出超过 2MB 的 Jasper 报告请求(通过 Jasper Server API),我收到的响应带有正确的 Content-Length header ,但没有响应正文。
Guzzle 请求:
GET /jasperserver/rest_v2/reports/projects/i3app_suite/Resource/BulkShiftExport.csv?ACCOUNT_ID=2&START_DATETIME=2015-01-01&END_DATETIME=2015-01-31 HTTP/1.1
Host: jasper.i3app:8080
User-Agent: Guzzle/3.8.1 curl/7.19.7 PHP/5.5.8
Authorization: Basic ***=
响应:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Cache-Control: private
Expires: Wed, 31 Dec 1969 17:00:00 MST
P3P: CP="ALL"
Set-Cookie: JSESSIONID=F0B0F72B65A8145B45DA9DB2BACE53D8; Path=/jasperserver/; HttpOnly, userLocale=en_US;Expires=Fri, 13-Feb-2015 18:56:44 GMT;HttpOnly
Content-Disposition: attachment; filename="BulkShiftExport.csv"
output-final: true
Content-Type: application/vnd.ms-excel
Content-Length: 2173897
Date: Thu, 12 Feb 2015 18:57:02 GMT
如果我通过命令行上的 curl 发出此请求(或在浏览器中请求),我会按预期收到报告
GET /jasperserver/rest_v2/reports/projects/i3app_suite/Resource/BulkShiftExport.csv?ACCOUNT_ID=2&START_DATETIME=2015-01-01&END_DATETIME=2015-01-30 HTTP/1.1
Authorization: Basic ***=
User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.15.3 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
Host: jasper.i3app:8080
Accept: */*
< HTTP/1.1 200 OK
< Server: Apache-Coyote/1.1
< Cache-Control: private
< Expires: Wed, 31 Dec 1969 17:00:00 MST
< P3P: CP="ALL"
< Set-Cookie: JSESSIONID=AF1BF885354AF3E352DD9E18FA044A4B; Path=/jasperserver/; HttpOnly
< Set-Cookie: userLocale=en_US;Expires=Fri, 13-Feb-2015 19:03:42 GMT;HttpOnly
< Content-Disposition: attachment; filename="BulkShiftExport.csv"
< output-final: true
< Content-Type: application/vnd.ms-excel
< Content-Length: 2113902
< Date: Thu, 12 Feb 2015 19:03:49 GMT
<
{ [data not shown]
我能看到的唯一区别是 curl 请求中的 Accept: */*
。我尝试将该 header 添加到 guzzle 请求并得到相同的结果。
当通过 Guzzle 客户端发出请求时,似乎需要相同的时间(5-6 秒)来接收响应,并且它设置了 Content-Length header ,但响应正文为空。为什么我通过使用 curl 的 Guzzle 得到一个空的响应主体,但在命令行上使用 curl 时却没有?是否需要设置一个选项才能使其正常工作?
$request = $this->getGuzzleClient()->createRequest('GET');
$config = $this->getConfig();
$url = new Url(
$config['scheme'],
$config['host'],
$config['user'],
$config['pass'],
$config['port'],
$config['path'] . $reportPath . '.' . $format,
new QueryString($parameters)
);
$request->setUrl($url);
$response = $request->send();
...
public function getGuzzleClient()
{
if (!$this->restClient) {
$client = new GuzzleClient();
$this->setRestClient($client);
}
return $this->restClient;
}
最佳答案
在我的例子中,我错误地使用了 MockHandler
。
关于php - Guzzle curl 请求得到空响应正文,但状态为 200 且 Content-Length header 正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28485842/
当我运行以下代码(使用最新的 Guzzle v6)时,请求的 URL 是 http://example.com/foobar?foo=bar删除 boo=far从请求。 $guzzle_http_cl
我正在使用 Guzzle 并发请求工具: http://docs.guzzlephp.org/en/latest/quickstart.html#concurrent-requests 我的代码类似于
我需要将 header 类型添加到下面的 guzzle 请求中,但无法弄清楚如何在不出错的情况下添加它这是我要添加的内容: $command->set('command.headers', array
我正在使用 lumen 尝试通过 guzzle 设置简单的 api 请求。 问题是 base_uri 参数似乎没有在初始 new Client() 上正确传递. 简化示例: use GuzzleHtt
我正在使用 Guzzle 6。 我正在尝试模拟客户端并像这样使用它: 'application/json'], 'foo'), ]); $history = []; $history_middlew
我正在尝试使用 Guzzle 而不是直接使用 cURL 来实现和 HTTP 请求。我如何使用 Guzzle 发出相同类型的请求?或者我应该坚持使用cURL? $ch = curl_init(); //
Guzzle 的 API 文档在哪里? 有这两个链接(看起来是同一件事): http://guzzle.readthedocs.org/en/latest/quickstart.html http:/
我有一个页面使用 Guzzle 6 执行一些 REST 查询。它工作正常,但有时速度太慢,因为它总是进行查询。我发现有 guzzle-cache-middleware应该缓存来自远程 API 的响应。
在 Symfony 4 项目中,我使用 eightpoints/guzzle 包来调用远程 API。安装 bundle (并在单独的 yaml 文件中配置客户端)后,我关注了 this quide让我
您可以使用 Guzzle 的 Pool:batch() 方法并行执行 http 请求。它允许您使用第三个参数中的 options 键为请求设置默认选项。 但是如果我需要为池中的不同请求提供不同的选项怎
我正在尝试使用 Guzzle 5 连接到 WooCommerce API(Guzzle 6 似乎没有 oAuth 选项 o.O)。 Woocommerce requires the oAuth aut
我在 laravel 项目中遇到问题。 它显示了这个错误 Fatal Error : Class 'Guzzle\Http\Client' not found 我已安装 Guzzle 并将其添加到配置
Guzzle/Http的新手。 我有一个API rest url登录名,如果未授权,则用401代码回答;如果缺少值,则用400回答。 我将获取http状态代码以检查是否存在某些问题,但不能仅包含代码(
A. 总结 顾名思义,Guzzle 允许一次发送多个请求以节省时间,如 documentation . $responses = $client->send(array( $requestOb
我正在使用 PayPal API 模拟负面响应,以便在客户通过 onApprove 方法批准付款时获得响应并正确处理付款的关键部分。 我正在使用 GuzzleHttp + Laravel 来捕获 客户
我一直在尝试从工作中获取 GET 请求,但不断收到 500 错误。 我不知道发生了什么。 如果我执行以下操作,它可以正常工作: 'http://www.google.com', ]); $respo
我如何通过 guzzle 服务客户端获取发布数据 getCommand功能? 我的 json 如下所示: "createMessage": { "httpMethod": "P
之间有什么区别? GuzzleHttp ReactPHP Amphp 它们之间有何不同?与典型的用例一起使用是什么? 最佳答案 它们之间的主要区别是Guzzle是HTTP客户端,而Amp和ReactP
我不确定为什么会收到此错误: php composer.phar require guzzle/guzzle:~3.7 错误 : ./composer.json has been update
我想使用Guzzle和Silex将请求发送到https页面。 使用http url我有一个回应: app->get('/',function() use ($app, $client){ $r
我是一名优秀的程序员,十分优秀!