【问题标题】:android picasso okhttp verify http headersandroid picasso okhttp 验证 http 标头
【发布时间】:2016-01-28 16:44:41
【问题描述】:

在我的 gradle 依赖项中,我添加了:

compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.5.0'

然后我正常使用毕加索,例如:

Picasso.with(context)
.load(url)
.placeholder(R.drawable.ic_contact_picture)
.error(R.drawable.ic_contact_picture)
.into(imageView);

现在,url 是一个 php 脚本,我正在使用它 echo file_get_contents("$imagepath"); picasso 正在获取并显示图像。

但在做 echo 之前,我还设置了一些标题,例如:

header("Last-Modified: ".gmdate("D, d M Y H:i:s", $lastModified)." GMT");
header("Etag: $etagFile");
header('Cache-Control: max-age=60');

现在,当毕加索咨询 okhttp 时,okhttp 会在 http 请求中发送这些标头吗?如何验证是否发送?

【问题讨论】:

    标签: php android picasso okhttp


    【解决方案1】:

    尝试使用 Chrome 访问该 URL,并查看 this SO answer 了解如何在 Chrome 中检查 HTTP 标头。

    This website 将显示 HTTP 客户端发送的标头。如果您使用的是 Linux,那么 this SO answer 提供了一种使用 TCPDump 的方法

    【讨论】:

    • 就像我说的,我想测试 http 客户端 (okhttp) 是否真的发回了这些标头。浏览器在这里没有帮助
    猜你喜欢
    • 2014-08-08
    • 2015-09-09
    • 2014-07-12
    • 2021-11-01
    • 1970-01-01
    • 2021-06-04
    • 2019-04-27
    • 2017-02-25
    • 1970-01-01
    相关资源
    最近更新 更多