【问题标题】:Get HTTP content获取 HTTP 内容
【发布时间】:2014-10-20 00:13:00
【问题描述】:

这是我访问 pwd.html 时的 Http 标头跟踪

host:port/pwd.html?type=Msg=8

POST /pwd.html?type=Msg=8 HTTP/1.1
Host: host:port
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: anotherhost:port/referrer
Cookie: SomeCookie=loggedoutcontinue; targetURL=Someurl
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 4936
  APP_REQ=324823823


HTTP/1.1 200 OK
Date: Tue, 26 Aug 2014 15:05:29 GMT
Server: Application-Server
Last-Modified: Mon, 25 Aug 2014 18:55:15 GMT
Accept-Ranges: bytes
Content-Length: 1336
Keep-Alive: timeout=5, max=99
Connection: Keep-Alive
Content-Type: text/html
Content-Language: en

如何使用 Javascript 从我的 pwd.html 中读取 APP_REQ 的值?它不是查询字符串或 URL 的一部分,但它是请求的一部分。

【问题讨论】:

  • @FrankvanPuffelen 您链接到的问题不相关。
  • @Brad:你确定吗? “在 JavaScript 中访问网页的 HTTP 标头”。我必须承认,我立即点击了stackoverflow.com/questions/12258705/…,它的答案与您给出的相同:“不可能,除非”。
  • @FrankvanPuffelen 这个问题似乎是在询问 AJAX 请求,而这个问题是在询问 JavaScript 请求本身的 POST 数据。虽然另一个答案提到了这一点,但问题是不同的,因此不是重复的。有许多类似的问题具有相同的答案,但要作为重复关闭,问题的实质必须相同。
  • 啊...等一下,我明白你的意思了。我错过了这是在寻找 request “标头”。那确实是不同的(尽管答案是一样的)。

标签: javascript http http-headers


【解决方案1】:

这是不可能的,除非服务器将这个值包含在pwd.html 本身的内容中。这需要一些服务器端的东西,比如 PHP 或 Node.js。

【讨论】:

  • 当我看到生成器 URL 时,它是这样的:"host:port/pwd.html?type=Msg=8 APP_REQ=324823823" 你知道为什么会出现这样的内容吗?电话或任何其他信息?
  • @ManishAcharya 在上面的示例中,APP_REQ-324823823 只是 POST 正文。
猜你喜欢
  • 1970-01-01
  • 2019-02-15
  • 2021-12-09
  • 2019-10-17
  • 2012-05-04
  • 2011-04-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多