gpt4 book ai didi

powershell - 如何使用Invoke-WebRequest查看发送的 header ?

转载 作者:行者123 更新时间:2023-12-02 23:21:47 26 4
gpt4 key购买 nike

当我使用以下命令时:

Invoke-WebRequest -UseBasicParsing -Uri http://example.com -SessionVariable Foo -UserAgent Bar

我得到以下输出:
StatusCode        : 200
StatusDescription : OK
Content : <!doctype html>
<html>
<head>
<title>Example Domain</title>

<meta charset="utf-8" />
<meta http-equiv="Content-type" content="text/html;
charset=utf-8" />
<meta name="viewport" conten...
RawContent : HTTP/1.1 200 OK
Vary: Accept-Encoding
X-Cache: HIT
Content-Length: 1270
Cache-Control: max-age=604800
Content-Type: text/html
Date: Mon, 19 Feb 2018 16:38:28 GMT
Expires: Mon, 26 Feb 2018 16:38...
Forms :
Headers : {[Vary, Accept-Encoding], [X-Cache, HIT], [Content-Length,
1270], [Cache-Control, max-age=604800]...}
Images : {}
InputFields : {}
Links : {@{outerHTML=<a
href="http://www.iana.org/domains/example">More
information...</a>; tagName=A;
href=http://www.iana.org/domains/example}}
ParsedHtml :
RawContentLength : 1270

但是问题是,我看不到已发送的 header ( session 变量或用户代理)。也许它被 ...截断了?

如何显示已发送的标题?

最佳答案

Invoke-WebRequest不存储请求 header AFAIK。如果要在 header 中使用特定值,则它希望您使用-Headers-UserAgent参数指定它们。

如果愿意,HttpWebRequestWebRequest可提供更多控制。

$req = [System.Net.HttpWebRequest]::Create("http://www.stackoverflow.com")
$res = $req.GetResponse()

$req.Headers.Keys | % { "$_ = $($req.Headers[$_])" }
Host = stackoverflow.com

$req | fl Method, UserAgent, ProtocolVersion
Method : GET
UserAgent :
ProtocolVersion : 1.1

关于powershell - 如何使用Invoke-WebRequest查看发送的 header ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48870540/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com