我使用以下命令将 zip 文件从 Nodejs 服务器发送到浏览器
res.set("Content-Type", "application/octet-stream");
res.set("Content-disposition", `attachment; filename="`+zip_name+`.zip"`);
res.set("Content-Length", zipBuff.length);
res.send(zipBuff);
Run Code Online (Sandbox Code Playgroud)
然后我使用以下方法获取它:
fetch("/my/url", {
method: "POST",
body: formData,
})
.then(response => {
return response.blob();
})
.then(response => {
const blob = new Blob([response], {type: 'application/zip'});
const downloadUrl = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = downloadUrl;
a.download = "blah.zip";
document.body.appendChild(a);
a.click();
});
Run Code Online (Sandbox Code Playgroud)
我希望能够使用zip_name而不是blah文件名,但我无法弄清楚如何Content-disposition使用fetch.
有人可以解释一下它是如何完成的吗?
有很多工具可以更改数据包中的 sni。ssh 是否使用 sni 或者 HTTP 注入器之类的软件如何更改 SNI 并浏览互联网。
Cross-Origin-Embedder-Policy和Cross-Origin-Opener-Policyheaders 可以用标签设置吗<meta>?还是只能用实际的 headers 设置?如果没有,是否有可以使用元标记设置的标头列表?
以下示例记录crossOriginIsolated: false到控制台。
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Cross-Origin-Embedder-Policy" content="require-corp">
<meta http-equiv="Cross-Origin-Opener-Policy" content="same-origin">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>COOP/COEP header test</title>
</head>
<body>
<script>console.log("crossOriginIsolated:", self.crossOriginIsolated)</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
如果我删除这些http-equiv元标记并使用实际的 HTTP 标头提供文件,那么它会记录crossOriginIsolated: true(在 Chrome 和 Firefox 中)。所以看来我无法使用元标记设置这些标头?
html http-headers cross-origin-embedder-policy cross-origin-opener-policy
我一直在更改用户代理:
chrome_options.add_argument("user-agent=" + USER_AGENT)
Run Code Online (Sandbox Code Playgroud)
我注意到 Chrome 有额外的用户代理客户端提示标头,例如Sec-CH-UA-Platform,以及此处Sec-CH-UA看到和测试的更多标头。
我想Sec-CH-UA-Platform在不使用 Selenium 扩展的情况下更改这些客户端提示(特别是)。这是否可能类似于更改用户代理的方式?
我想拦截所有正在发送的 XHR 请求,并在发送请求之前更改它们的 URL 和标头。
发现了这个类似的问题,但那里没有答案。
我尝试了 hooking XMLHttpRequest.prototype.open,但它只能让我访问响应:
(function () {
var origOpen = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function () {
console.log(arguments); // prints method ("GET"), URL
console.log(this); // prints response, responseText, responseURL, status, statusText, and onXXX handlers
origOpen.apply(this, arguments);
};
})();
Run Code Online (Sandbox Code Playgroud)
还尝试了 hooking XMLHttpRequest.prototype.setRequestHeader,但它只能让我一一访问正在设置的每个标头值,而且我无法将其与请求的 URL 关联起来:
(function () {
var origSetRequestHeader = XMLHttpRequest.prototype.setRequestHeader;
XMLHttpRequest.prototype.setRequestHeader = function (header, value) {
console.log("header", header);
console.log("value", value);
origSetRequestHeader.apply(this, arguments);
};
})();
Run Code Online (Sandbox Code Playgroud)
我设法挂钩XMLHttpRequest.prototype.send设置自定义标头,但由于我想更改现有标头键,因此它会附加我的新值而不是替换现有值。其他人也遇到了同样的问题:1 , 2 :
(function …Run Code Online (Sandbox Code Playgroud) javascript xmlhttprequest httprequest request-headers http-headers
您可以请求http标头检查网页是否已通过查看其日期进行编辑,但动态页面如-php,aspx-如何从数据库中获取数据?
我用PHP编写了一个Web应用程序,它使用了Ajax请求(使用YUI.util.Connect.asyncRequest进行).
大多数时候,这很好.该请求与一个发送的X-请求-随着的值的XMLHttpRequest.我的PHP控制器代码使用apache_request_headers()来检查传入的请求是否是Ajax,并且一切正常.
但不总是.间歇性地,我遇到了发送Ajax请求的情况(并且Firebug确认请求中的标头包含XML-HttpRequest的X-Requested-With)但是apache_request_headers()没有在其列表中返回该标头.
var_dump apache_request_headers()时的输出如下(注意缺少X-
'Host' => string 'peterh.labs.example.com' (length=26)
'User-Agent' => string 'Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.9.0.3) Gecko/2008101315 Ubuntu/8.10 (intrepid) Firefox/3.0.3' (length=105)
'Accept' => string 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' (length=63)
'Accept-Language' => string 'en-gb,en;q=0.5' (length=14)
'Accept-Encoding' => string 'gzip,deflate' (length=12)
'Accept-Charset' => string 'ISO-8859-1,utf-8;q=0.7,*;q=0.7' (length=30)
'Keep-Alive' => string '300' (length=3)
'Connection' => string 'keep-alive' (length=10)
'Referer' => string 'http://peterh.labs.example.com/qmail/' (length=40)
'Cookie' => string 'WORKFLOW_SESSION=55f9aff2051746851de453c1f776ad10745354f6' (length=57)
'Pragma' => string 'no-cache' (length=8)
'Cache-Control' => string 'no-cache' (length=8)
Run Code Online (Sandbox Code Playgroud)
但是Firebug告诉我: …
我需要在没有实际下载内容的情况下检查页面是否被重定向.我只需要最终的URL.这样做的最好方法是Python?谢谢!
这是否有效且正确?
RewriteRule ^myOldPage.html$ /index.php#info [R]
Run Code Online (Sandbox Code Playgroud)
我对这个#info部分特别感兴趣.
我正在使用ASP.NET MVC实现RESTful API的原型,除了奇怪的bug之外,我已经实现了我在开始时设置的所有要求,除了调用者能够使用X-HTTP-Method-Override自定义标头覆盖HTTP方法.
我想要的是以下要求......
GET /someresource/123 HTTP/1.1
X-HTTP-Method-Override: DELETE
Run Code Online (Sandbox Code Playgroud)
...将被调度到我的控制器方法,该方法实现DELETE功能而不是该GET操作的功能(假设有多个方法实现该操作,并且它们标记有不同的[AcceptVerbs]属性).因此,鉴于以下两种方法,我希望将上述请求分发给第二个:
[ActionName("someresource")]
[AcceptVerbs(HttpVerbs.Get)]
public ActionResult GetSomeResource(int id) { /* ... */ }
[ActionName("someresource")]
[AcceptVerbs(HttpVerbs.Delete)]
public ActionResult DeleteSomeResource(int id) { /* ... */ }
Run Code Online (Sandbox Code Playgroud)
有人知道这是否可行?这样做会有多少工作......?
http-headers ×10
javascript ×2
python ×2
ajax ×1
apache ×1
asp.net-mvc ×1
cross-origin-embedder-policy ×1
fetch-api ×1
firebug ×1
html ×1
http ×1
http-method ×1
httprequest ×1
mod-rewrite ×1
php ×1
rest ×1
selenium ×1
sni ×1
ssh ×1
ssh-tunnel ×1
user-agent ×1