我正在测试一个API,我想用safari命中它,看看返回的原始json。 API要求在每个请求时发送某个HTTP标头。在访问网址时,Safari或Chrome是否有办法设置我的http标头?
答案 0 :(得分:12)
有几个谷歌Chrome应用程序可以执行此操作。一个叫Rest Console。 我实际上在Mac AppStore中找到了一个名为GraphicalHttpClient的应用程序,它使用起来更轻松,更有趣。
答案 1 :(得分:5)
另一个受欢迎的Chrome应用是Postman
答案 2 :(得分:4)
Header Hacker将在Chrome浏览器上执行此操作 FireFox浏览器上的Modify Headers。它们都允许设置自定义HTTP标头
答案 3 :(得分:3)
(目前为实验性的)WebRequest API允许您查看和修改标题:http://code.google.com/chrome/extensions/trunk/webRequest.html
使用onSendHeaders
查看标题非常简单。
要编辑标题,您需要阻止该请求。此示例(来自上面链接的文档)从所有请求中删除了User-Agent标头:
chrome.experimental.webRequest.onBeforeSendHeaders.addListener(
function(details) {
delete details.requestHeaders['User-Agent'];
return {requestHeaders: details.requestHeaders};
},
{},
["blocking"]);
答案 4 :(得分:3)
我会使用Fiddler作为我的调试代理并在那里设置标头。请参阅FiddlerScript CookBook的“添加请求标头”。这个解决方案适用于任何浏览器。
Fiddler是一个Web调试代理,它记录所有HTTP(S)流量 在您的计算机和Internet之间。 Fiddler允许你检查 所有HTTP(S)流量,设置断点,以及传入或者“小提琴” 传出数据。 Fiddler包含强大的基于事件的脚本 子系统,可以使用任何.NET语言进行扩展。
答案 5 :(得分:1)
您可以在Chrome中使用<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/linear_layout_two"
android:layout_below="@+id/linear_layout_one"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="60dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="25dp"
android:textColor="#3193b9"
android:text="99.3%"
android:layout_weight="1"
android:id="@+id/goals_accuracy"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="10dp"
android:gravity="center"
android:text="Goals accuracy"
android:layout_weight="1"
android:id="@+id/goals_accuracy_2"/>
</LinearLayout>
<ImageView
android:layout_width="0dp"
android:layout_height="60dp"
android:src="@drawable/the_vertical"
android:id="@+id/imageView8" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="60dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="25dp"
android:textColor="#3193b9"
android:text="10:30hr"
android:gravity="center"
android:layout_weight="1"
android:id="@+id/total_time_on_ice"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="10dp"
android:text="Total time on ice"
android:gravity="center"
android:layout_weight="1"
android:id="@+id/total_time_on_ice_2"/>
</LinearLayout>
</LinearLayout>
扩展名。
答案 6 :(得分:1)
如果您使用的是 Chrome,则可以使用 Requestly
中的 Modify Headers 规则这是一个修改Headers的例子(添加一个请求头)
Requestly 还具有一项功能,可以让用户相互共享规则。这是我创建的标题规则示例 - https://app.requestly.io/rules/#sharedList/1624596871428-Stackoverflow-answer
要使用它,请点击链接并点击导入列表以根据您的用例进行修改。
其他参考资料
答案 7 :(得分:0)
我知道答案已被选中,但我想我也会分享:
Mac App Store中的EasyHTTP。 https://itunes.apple.com/gb/app/easyhttp/id657224426?mt=12
它是免费的,易于使用且非常好。