这是请求和响应标头
http://www.example.com/get/pdf
GET /~get/pdf HTTP/1.1
Host: www.example.com
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3
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
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Referer: http://www.example.com
Cookie: etc
HTTP/1.1 200 OK
Date: Thu, 29 Apr 2010 02:20:43 GMT
Server: Apache/2.2.14 (Unix) mod_ssl/2.2.14 OpenSSL/0.9.8i DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
X-Powered-By: Me
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Pragma: no-cache
Cache-Control: private
Content-Disposition: attachment; filename="File #1.pdf"
Content-Length: 18776
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: …Run Code Online (Sandbox Code Playgroud) 我有RESTEasy(JAX-RS)服务器,有大约60个服务(到目前为止).我想通过服务器构建时间自动为提供者调用者注入一个自定义响应头:X-BuildTime: 20100335.1130.
有没有一种简单的方法可以在不修改我的每项服务的情况下完成
我试图使用实现一类org.jboss.resteasy.spi.interception.PostProcessInterceptor带注解@Provider和@ServerInterceptor,但我无法弄清楚如何修改传递到我的ServerResponse postProcess()方法.
只是想知道是否有任何方法可以从代理的远程服务器覆盖/删除响应Cache-Control:private.设置架构看起来像这样(是的,它是一个反向代理设置):
[我的服务器] - > [远程服务器]
我的服务器站点可用/默认设置:
server {
listen 80; ## listen for ipv4
listen [::]:80 default ipv6only=on; ## listen for ipv6
server_name localhost;
location / {
if ($arg_AWSACCESSKEY) {
proxy_pass http://localhost:8088;
}
try_files $uri $uri/ /index.php /index.html /index.htm;
}
# other setting goes here
}
Run Code Online (Sandbox Code Playgroud)
我的服务器站点可用/远程的设置:
server {
listen 8088; ## listen for ipv4; this line is default and implied
# Make site accessible from http://localhost/
# server_name localhost;
location / {
proxy_pass http://remoteserver;
proxy_set_header Host remoteserverhostname.com;
proxy_ignore_headers Cache-Control …Run Code Online (Sandbox Code Playgroud) 该w3.org(RFC2616),似乎没有定义块的最大尺寸.但是如果没有最大块大小,则没有空间用于块扩展.必须有一个最大的块大小,否则我不能忽略块扩展,因为我不建议如果它无法理解(Quote :) "MUST ignore chunk-extension extensions they do not understand".
我已经有几家店铺实现了.但在某个时刻,我会在所有这些中添加HTTP标头.我怎么能用ExtJS 4做到这一点?
只是好奇,当内容类型标题是image/jpeg,binary时,HTTP响应体的内容数据类型格式是什么?在通过Mozilla Firebug查看时无法看到HTTP响应的原始内容,因为它已经弹出了图像.
在与一个人交谈之前,我从来没有这么说过,他告诉他将二进制数据编码成base64格式的数据到HTTP响应体中.有什么用例我们需要这样做吗?
我正在使用rails 4开发rails API,我想测试它.要做到这一点,我正在使用Rspec框架.
我的API有一个身份验证方法,就像这样调用:
class UsersController < ApplicationController
# Token authentication
before_action :set_user, except: [:index, :create]
before_action :authenticate, except: [:index, :create]
before_action :authenticate_admin, only: [:index, :create]
...
end
Run Code Online (Sandbox Code Playgroud)
然后我有我的UsersController Rspec:
describe UsersController do
render_views
describe "GET /users" do
it "gets all users" do
@request.env["AUTHORIZATION"] = "Token token=xxxxxxxxx"
@request.env["HTTP_ACCEPT"] = "application/json"
@request.env["CONTENT_TYPE"] = "application/json"
get :index
response.status.should be(200)
end
end
end
Run Code Online (Sandbox Code Playgroud)
当我执行测试时,它总是给我一样的:
UsersController GET /users getting all users
Failure/Error: response.status.should be(200)
expected #<Fixnum:401> => 200
got #<Fixnum:803> => 401
...
Run Code Online (Sandbox Code Playgroud)
我使用authenticate_or_request_with_http_token方法从头文件中获取令牌. …
我在JAVA EE7工作,JAX-RS 2.0 Glassfish 4是我的服务器.我想在CORS上工作以使Ajax请求从我的域中出来.我知道我需要让我的服务器启用它.我用PHP做到了.像下面的代码:
<?php header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: Authorization");
Run Code Online (Sandbox Code Playgroud)
但当我尝试做同样的事情时,我总会收到一条错误消息,例如 "这是截图".所以我试图用很多方式修改服务器的http响应......
这是我的代码,服务器端,我使用了文件管理器/提供程序:
@Provider
@CORSBinding
public class Filter implements ContainerRequestFilter{
@Override
public void filter(ContainerRequestContext request) throws IOException {
request.getHeaders().add("Access-Control-Allow-Origin", "*");
request.getHeaders().add("Access-Control-Allow-Headers", "Authorization");
if (request.getMethod().equals("OPTIONS")) {
System.out.println("OPTIONS is requested!!!!!!!!!!!!!");
}
if (request.getMethod().equals("GET")) {
System.out.println("GET is requested!!!!!!!!!!!!!");
}
if (request.getMethod().equals("POST")) {
System.out.println("POST is requested!!!!!!!!!!!!!");
}
if (request.getMethod().equals("DELETE")) {
System.out.println("DELETE is requested!!!!!!!!!!!!!");
}
if (request.getMethod().equals("PUT")) {
System.out.println("PUT is requested!!!!!!!!!!!!!");
}
}
}
Run Code Online (Sandbox Code Playgroud)
但似乎所有人都被Glassfish4服务器提供的"防火墙安全性"所阻止.这是我的简单代码javascript:
<script>
var xhr = new XMLHttpRequest();
xhr.open("POST", "http://127.0.0.1:8080/CV/api/v2/posts");
xhr.setRequestHeader('Authorization', …Run Code Online (Sandbox Code Playgroud) 我试图通过iisspeed.com使用" 用于Microsoft IIS的Brotli压缩模块 "在IIS中使用新的Brotli压缩方案.
如果我将<httpCompression>配置部分更改applicationHost.config为仅具有Brotli模块,则Brotli压缩模块本身可以正常工作.
iisspeed.com上的文档说这样做:
<httpCompression directory="path\to\temp\folder" minFileSizeForComp="50">
<scheme name="br" dll="path\to\iisbrotli.dll" />
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
...
</httpCompression>
Run Code Online (Sandbox Code Playgroud)
但是我发现这不起作用.
浏览器(本例中为Chrome)发送以下accept-encoding标头:
accept-encoding: gzip, deflate, sdch, br
这意味着浏览器可以接受Brotli编码br以及gzip.我希望IIS更喜欢br,gzip但似乎没有办法优先<scheme>配置配置中的每个元素.我已经尝试更改.config文件中的顺序,但它没有任何效果.
IIS总是使用gzip即使br受支持也是首选,因为它的文件较小.
我已经搜索谷歌,发现IIS 6中的每个压缩方案都有一个优先级设置,但似乎已经在IIS7 +中删除了.
它被调用HcPriority并进入IIS6配置数据库XML文件.
请参阅以下链接:
https://msdn.microsoft.com/en-us/library/ms525366(v=vs.90).aspx
https://blogs.iis.net/ksingla/changes-to-compression-in-iis7
https://forums.iis.net/t/1150520.aspx
br了gzip,如果客户接受呢?在我的网站上,我有一个<a download></a>链接以及一个php函数,可以很好地将文件下载到桌面上-
ob_start();
$nameOld = 'https://my-other-server.online/path/to/file.mp4';
$save = '/var/path/to/file.mp4';
$nameNew = "download.mp4";
file_put_contents($save, fopen($nameOld, 'r'));
set_time_limit(0);
header('Connection: Keep-Alive');
header('Content-Description: File Transfer');
header('Content-Type: application/force-download');
header("Content-Disposition: attachment; filename=$nameNew");
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($save));
while (ob_get_level()) {
ob_end_clean();
}
readfile($save);
exit;
unlink($save);
Run Code Online (Sandbox Code Playgroud)
在移动设备(iPhone)上,此功能不适用于Chrome浏览器。(即使我已经看到一些下载提示用户打开另一个应用程序以继续,我也已经知道Safari ios下载。)
因此,我尝试使用<a></a> download链接,但是单击它时,它只是在新标签中打开视频并播放。
如果我尝试使用php脚本,它将在新标签页中打开视频并显示划掉的播放按钮(视频甚至无法播放)。我一直在寻找答案的几天,我已经编辑了.htaccess文件并测试了不同的脚本,内容类型,标头等。
这是特定于移动设备的当前脚本的样子-
... first few lines same as above script ...
file_put_contents($save, fopen($nameOld, 'r'));
//echo file_get_contents($save);
//$headers = get_headers($nameOld, 1);
//$filesize = $headers['Content-Length'];
//set_time_limit(0); …Run Code Online (Sandbox Code Playgroud)