从浏览器的角度来看,
如果在没有Last-ModifiedHTTP头字段的情况下提供组件(图像,脚本,样式表...)会发生什么...
然而If-Modified-Since,由于缺少日期/时间信息,它是否会被浏览器缓存,即使它将来无法执行有效性检查()?
例如:
GET /foo.png HTTP/1.1
Host: example.org
--
200 OK
Content-Type: image/png
...
Run Code Online (Sandbox Code Playgroud)
被foo.png然而缓存?
-
您是否知道我可以自己编写的原始HTTP响应服务的任何在线服务,以便测试我的要求?
谢谢.
我正在尝试检查自上次检查后文件(在Web上)是否被修改.是否可以通过在上次修改(或上传)文件时读取http标头来实现此目的?
我需要添加非标准请求标头,其格式如下:(X-MMP-Params:fs = 640x0).我在这里使用HTTPClient是代码:
HttpClient client = new DefaultHttpClient();
String getURL = "http://example.com";
HttpGet get = new HttpGet(getURL);
get.setHeader("X-MMP-Params","fs=640x0"); // I set my request header right here
HttpResponse responseGet = client.execute(get);
Run Code Online (Sandbox Code Playgroud)
这是正确的方法吗?
我完全迷失了这个问题.
我有一个获取json响应的ajax查询.查询在大多数情况下都能正常工作,但是当json响应非常大时,它似乎会绊倒.
问题是响应最终形式如下:
...est":"test length"}]]}
HTTP/1.1 200 OK
Date: Wed, 21 Sep 2011 17:10:32 GMT
Server: Apache/2.2.11 (Win32) mod_ssl/2.2.11 OpenSSL/0.9.8k PHP/5.3.0
X-Powered-By: PHP/5.3.0
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Keep-Alive: timeout=5, max=90
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html
5b03d
{"ResultsInfo":{"RequestID":"131661886010","FeedCompletion":{"0":"100"}},"ResultsData":[[{"test":"test length"},{"test":"test length"},
...0
Run Code Online (Sandbox Code Playgroud)
...表示更多相同的"{"test":"test length"},"string
所以响应似乎是以下形式:
没有确切的响应长度,但是它在360791个字符处是正常的但不是在372797个字符处.
我正在使用Yii PHP框架,但搜索范围广泛,并没有在论坛中看到任何东西.
在我看来,网络服务器正在将响应分成几个部分,或者超时并重新开始.
或者可能有最大的回报?
编辑 ___ _ __ _ _ _ _ _ _ _ _ _ …
我在Symfony2中找到了一些关于cookie的问题和页面,但似乎没有就这究竟是如何工作的问题达成任何明确的共识.当然,我可以回到使用PHP的本机setcookie函数,但我觉得使用Symfony2也应该是一件容易的事情.
我在我的控制器中有一个动作,我只想返回一个带有cookie的视图.到目前为止,我看起来基本上是这样的例子:
use Symfony\Compentnt\HttpFoundation\Response;
public function indexAction() {
$response = new Response();
$response->headers->setCookie(new Cookie('name', 'value', 0, '/');
$response->send();
}
Run Code Online (Sandbox Code Playgroud)
这个问题是它发送响应......并且不呈现视图.如果我在不发送标题的情况下设置cookie,则会呈现视图,但不会发送标题(cookie).
在我周围找到了sendHeaders()响应对象中的方法,所以我现在在返回之前手动调用它,这似乎有效:
public function indexAction() {
...
$response->sendHeaders();
return array('variables' => 'values');
}
Run Code Online (Sandbox Code Playgroud)
但这真的是预期使用的模式吗?在symfony的早期版本中,我可以在控制器中设置标头,并期望视图控制器处理发送的任何内容.现在看来我必须从动作中手动发送它们才能使它工作,这意味着我必须从我设置标题的任何动作中调用它.这是否是这种情况或者是否有一些我错过的东西是如此明显以至于在任何文档中都没有人提到它甚至没有提到它?
我已经通过 Angular 中的 HttpInterceptor 添加了授权标头,但输出似乎不正确。根据添加标头后的 JSON 输出,这感觉太笨拙而无法正确。我是否错误地添加了标头,或者我访问它们是否错误?:
headers["lazyUpdate"].forEach(x=>{x.name=='Authorization'}).value
Run Code Online (Sandbox Code Playgroud)
目标是回归Bearer mystring
拦截器调用:
{"url":" https://myurl ","body:{}, "reportProgress":false, "withCredentials":false, "responseType":"json", "method":"POST", "headers" :{"normalizedNames":{},"lazyUpdate":null,"headers":{}},"params":{"updates":null,"cloneFrom":null,"encoder":{},"map" :null},"urlWithParams":"myurl"}
token.interceptor.ts:13拦截器添加token:
{"url":"myurl", "body":{}, "reportProgress":false, "withCredentials":false, "responseType":"json", "method":"POST", "headers":{" NormalizedNames":{},"lazyUpdate":[ {"name":"Authorization","value":"Bearer mystring","op":"s"} ], "headers":{},"lazyInit": {"normalizedNames":{},"lazyUpdate":null,"headers":{}}},"params":{"updates":null,"cloneFrom":null,"encoder":{},"map" :{}},"urlWithParams":"myurl"}
我的 TokenInterceptor 类:
@Injectable()
export class TokenInterceptor implements HttpInterceptor {
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
console.log('interceptor called: '+JSON.stringify(request))
let r = request.clone({
headers: request.headers.set('Authorization', `Bearer ${localStorage.getItem("id_token")}`)
});
console.log('interceptor added token: '+JSON.stringify(r))
return next.handle(r);
}
}
Run Code Online (Sandbox Code Playgroud) 抱歉编辑历史记录,但这个问题对我来说真的不清楚,很难找到确切的问题。
我有一个在Nginx后面运行的.Net-Core Web 应用程序,并且X-Forwarded-Proto总是通过而不是.httphttps
启动.cs
public void ConfigureServices(IServiceCollection services)
{
services.Configure<ForwardedHeadersOptions>(options =>
{
options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
});
services.AddMvc();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
//first middlewear
app.UseForwardedHeaders();
//and the rest
}
Run Code Online (Sandbox Code Playgroud)
Nginx 配置
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://localhost:5001/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Run Code Online (Sandbox Code Playgroud)
Nginx.conf
http {
include …Run Code Online (Sandbox Code Playgroud) 我一直在更改用户代理:
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-headers ×10
http ×3
.net-core ×1
ajax ×1
android ×1
angular ×1
asp.net-core ×1
caching ×1
cookies ×1
httprequest ×1
https ×1
javascript ×1
json ×1
nginx ×1
php ×1
python ×1
ruby ×1
selenium ×1
symfony ×1
user-agent ×1