看看这个页面:
它加载良好(至少在这里)。现在我想用 wget 来抓取它。
$ wget http://www.ptmytrade.com/product.asp?id=61363 --debug
DEBUG output created by Wget 1.12 on linux-gnu.
--2011-05-21 18:24:51-- http://www.ptmytrade.com/product.asp?id=61363
Resolving www.ptmytrade.com... 205.209.150.134
Caching www.ptmytrade.com => 205.209.150.134
Connecting to www.ptmytrade.com|205.209.150.134|:80... connected.
Created socket 3.
Releasing 0x0890e260 (new refcount 1).
---request begin---
GET /product.asp?id=61363 HTTP/1.0
User-Agent: Wget/1.12 (linux-gnu)
Accept: */*
Host: www.ptmytrade.com
Connection: Keep-Alive
---request end---
HTTP request sent, awaiting response...
---response begin---
HTTP/1.1 500 Internal Server Error
Connection: keep-alive
Date: Sat, 21 May 2011 16:24:56 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET …Run Code Online (Sandbox Code Playgroud) 我希望将 301 重定向到应用程序以获取查询字符串参数的特定值。
例如:
http://www.example.com/page?id=1? 重定向到新页面http://www.example.com/page?id=2? 呈现正常反应浏览器如何缓存重定向?
具体来说,在访问第一个 URL 后,某些浏览器会开始对 执行 301 重定向id=2,还是基于完整 URL 进行重定向?
url redirect http-redirect http-headers http-status-code-301
我试图在Swift中使用Alamofire发出带有标题的帖子请求.但是,我一直在方法调用错误中获取额外参数.我正在使用Alamofire的4.5版本.我无法弄清楚错误.
请找到附带的代码
let headers = ["Authorization": token, "Content-Type": "application/json"]
Alamofire.request("http://localhost:8000/create", method: .post, parameters: parameters, encoding: JSONEncoding.default, headers: headers).responseJSON { response in
}
Run Code Online (Sandbox Code Playgroud) 我正在对我的计算机(192.168.1.132)上的API发出请求,并通过电话(在同一网络中)进行本地响应:
fetch('http://192.168.1.132:8000/test', {
method: 'GET',
headers: { 'Authorization': 'Bearer 4uFPmkP5326DXcRuHDKjRRrmhdeIBJ'},
credentials: 'same-origin'
})
.then((response) => response.json())
.then((responseJson) => {
console.log('RESPONSE: ' + JSON.stringify(responseJson))
})
Run Code Online (Sandbox Code Playgroud)
但是我正在嗅探该请求,并且它没有Authorization标头(我输入的其他任何标头都会出现,但没有Authorization)。在Xcode中,我启用了“ AllowArbitraryLoads”。因此,我的API返回401(未授权),因为显然没有授权标头。为什么它不包含在我的请求中?
我想仅通过首次访问者通过CloudFlare工作者动态添加http-header 。例如,这些标头:
Link: </path/to/file.css>; rel=preload; as=style; nopush
Link: </path/to/script.js>; rel=preload; as=script; nopush
Run Code Online (Sandbox Code Playgroud)
因此,我需要通过CloudFlare Workers中的JavaScript进行以下操作:
您可以在此处使用代码。
这是CF博客中的一个一般示例(涉及cookie和标头):
// A Service Worker which skips cache if the request contains
// a cookie.
addEventListener('fetch', event => {
let request = event.request
if (request.headers.has('Cookie')) {
// Cookie present. Add Cache-Control: no-cache.
let newHeaders = new Headers(request.headers)
newHeaders.set('Cache-Control', 'no-cache')
event.respondWith(fetch(request, {headers: newHeaders}))
}
// Use default behavior.
return
})
Run Code Online (Sandbox Code Playgroud) javascript cookies http-headers cloudflare cloudflare-workers
当使用Axios/http请求设置标头时,我在向服务器发出请求时遇到问题.我添加的任何标头(content-type标头除外)都会导致相同的错误:"预检的响应具有无效的HTTP状态代码405".这在Chrome,Firefox,Edge等中都是如此.
具体来说,我需要为我需要连接的服务添加Authorization标头以进行帐户验证.
使用API URI在Postman上运行GET请求工作正常,我得到了所需的响应.在浏览器中的React应用程序中运行它会给出HTTP 405错误.我在本地节点服务器上运行此Allow-Control-Origin功能,并安装了Google的扩展程序并启用了http://localhost:3000.
当我运行没有任何标头参数的请求时:
axios.get("https://myrequest.com/req/reqservice.svc/Login",).then(data => console.log(data)).catch(err => console.log(err))
请求工作正常.当我用标题(任何标题,但在我的情况下,授权标题)运行它时,我得到错误:
axios.get("https://myrequest.com/req/reqservice.svc/Login", { headers: { "Authorization": "randomExample" } }).then(data => console.log(data)).catch(err => console.log(err))
那么,可能导致这个问题的原因是什么?如果是CORS或连接问题,我一般不会在提出请求时遇到问题吗?我一直在仔细阅读Stack Overflow,没有回答给我解决方案.我完全迷失了该做什么,而且我已经在没有一个解决方案的情况下工作了好几天.任何输入都将非常感激.
我的API要求是
网址:/ user / upload-profile-image
方法=开机自检
标头-
Accesstoken:“ access_token”
内容类型=多部分/表单数据
这是我的代码:
Future getUploadImg(File _image) async {
String apiUrl = '$_apiUrl/user/upload-profile-image';
final length = await _image.length();
final request = new http.MultipartRequest('POST', Uri.parse(apiUrl))
..files.add(new http.MultipartFile('avatar', _image.openRead(), length));
http.Response response = await http.Response.fromStream(await request.send());
print("Result: ${response.body}");
return JSON.decode(response.body);
}
Run Code Online (Sandbox Code Playgroud) 是否可以仅对图像,字体,css和js等静态资产进行缓存控制?
这是我的解决方法
[[headers]]
for = "/*" # This defines which paths this specific [[headers]] block will cover.
[headers.values]
Cache-Control = "public, max-age=604800"
Run Code Online (Sandbox Code Playgroud)
它很可爱,但是效果不如我预期。即使更新内容,该网站似乎仍使用旧版本。
frame-src和frame-ancestors到底做什么?定义表明目的是为两个指令定义框架的有效内容。什么时候使用哪个。我能够使用-在iframe中加载外部域内容
两者都可以,但是无法获得正确的用例。
对于我的项目,我需要知道git repo是否公开。我首先想到要使用HTTP请求,所以我使用的是邮递员,并且尝试使用HEAD方法处理多个URL。
当我发送请求时,看不到标题中的内容可以指示我是否失败。
当我向github发送一个私有项目的请求时,我收到状态404,因此对我来说是完美的,因为我知道这是一个私有项目。
但是,当我为gitlab执行此操作时,我收到状态200,然后被重定向。
我想知道是否有解决方案。
http-headers ×10
javascript ×2
.net ×1
alamofire ×1
axios ×1
cloudflare ×1
cookies ×1
dart ×1
flutter ×1
git ×1
http ×1
httprequest ×1
image ×1
ios ×1
netlify ×1
node.js ×1
post ×1
react-native ×1
redirect ×1
swift ×1
upload ×1
url ×1
wget ×1
xcode ×1