我想在打开网页时传递一些标题.现在,我正在做类似的事情:)
browserIntent = new Intent(Intent.ACTION_VIEW,Uri.parse(data.link));
startActivity(browserIntent;
现在我卡住了,因为我不知道如何使用browserIntent传递标头.我尝试过使用browserIntent.putExtra()但它不起作用.
谁能请帮忙.!!
现在作为示例,我得到一个响应,其中部分键/值作为javascript对象:
status: '200 OK',
'content-encoding': 'gzip'
Run Code Online (Sandbox Code Playgroud)
我可以通过以下方式轻松读出并记录状态消息:headers.status但是当我尝试记录内容编码(我在这种特殊情况下需要)时,它会出错:
headers.'content-encoding' <- obviously the quotes it doesn't like
headers.content-encoding <- obviously the '-' it doesn't like
Run Code Online (Sandbox Code Playgroud)
我怎么想获取/读取/记录它的内容编码值?
映入眼帘,
m0rph3v5
什么是HTTP标头的有效值pragma.我知道no-cache是一个,但我想启用缓存,所以我应该设置它.我做了一些googleing,我得到的只是大多数客户忽略了这一点,但没有关于它接受的其他值的信息.
默认情况下,Connection标题设置为Keep-Alive浏览器,以便为浏览器的其他请求保持连接打开.
当我Connection标题时close,可能有什么区别?这会影响任何性能问题吗?
(一个补充:我从xmlhttprequest设置标题)
我正在尝试为Vary: Accept-Encoding我压缩的文件添加一个标头,如前所述.
但是,由于某种原因,无法从Visual Studio测试服务器或IIS服务器进行此操作.
我有以下代码:
if (url.Contains(".js") || url.Contains(".aspx") || url.Contains(".css"))
{
app.Response.AppendHeader("Vary", "Accept-Encoding");
app.Response.AppendHeader("Varye", "Accept-Encoding"); // for testing
app.Response.AppendHeader("Varye", "Accept-Things"); // for testing
app.Response.AppendHeader("Vary", "Accept-Stuff"); // for testing
app.Response.AppendHeader("Var", "Accept-Items"); // for testing
encodings = encodings.ToLower();
if (encodings.Contains("gzip") || encodings == "*")
{
app.Response.Filter = new GZipStream(baseStream, CompressionMode.Compress);
app.Response.AppendHeader("Content-Encoding", "gzip");
}
}
Run Code Online (Sandbox Code Playgroud)
这导致以下响应头:
Status=OK - 200
Server=ASP.NET Development Server/10.0.0.0
Date=Fri, 21 Oct 2011 12:24:11 GMT
X-AspNet-Version=4.0.30319
Varye=Accept-Encoding, Accept-Things
Var=Accept-Items
Content-Encoding=gzip
Cache-Control=public
Etag="1CC8F2E9D772300"
Content-Type=text/css
Content-Length=16200
Connection=Close …Run Code Online (Sandbox Code Playgroud) 我似乎遇到了一个有趣的问题,浏览器愉快地显示由我的Spring MVC Web应用程序生成的图像,只要我的控制器的URL设置为IMG标记的SRC,但在直接导航到URL时显示二进制数据.
我的Spring MVC Controller生成一些BufferedImage(缩略图),将其转换为byte[]并使用@ResponseBody控制器方法上的注释将其直接返回到响应主体.我已经注册了一个org.springframework.http.converter.ByteArrayHttpMessageConverter消息转换器,AnnotationMethodHandlerAdapter甚至将其supportedMediaTypes属性设置为image/jpeg,这实际上没有帮助,所以我在控制器方法中手动设置响应的Content-Type标头.
<img src="/images/thumbnail?id=1234" />
Run Code Online (Sandbox Code Playgroud)
工作正常并显示图像,但直接导航到图像的SRC(或右键单击图像并选择查看图像)最终会显示图像的原始数据.
根据Firebug,从对此 URL的请求(http:// localhost:8888/images/thumbnail?id = F0snPkvwhtDbl8eutbuq)收到的响应标头是:
HTTP/1.1 200 OK
Expires: Wed, 21 Dec 2011 12:39:07 GMT
Cache-Control: max-age=2592000
Content-Type: image/jpeg
Content-Length: 6998
Server: Jetty(6.1.10)
Run Code Online (Sandbox Code Playgroud)
最后一句话:在Firebug中,单击Response选项卡显示图像:-)我错过了什么?我认为浏览器接收内容类型和内容长度标题,知道期望jpeg图像,接收jpeg的原始数据,然后在空浏览器选项卡中显示jpeg.不知何故FF和Chrome正在显示收到的原始图像数据.
我正在使用的代码:
@RequestMapping(value = "thumbnail", method = { RequestMethod.GET })
@ResponseBody
public byte[] getImageThumbnail(@RequestParam("id") String documentId, HttpServletResponse response) {
try {
Document document = documentService.getDocumentById(documentId);
InputStream imageInputStream = new FileInputStream(document.getUri()); …Run Code Online (Sandbox Code Playgroud) 我想知道是否可以清除header_list()中存储的当前信息
if(headers_sent()){
foreach(headers_list() as $header){
header_remove($header);
}
}
var_dump(headers_list());
Run Code Online (Sandbox Code Playgroud) 如何在Django render_to_response中使用HTTP响应头
我想使用Cache-Control,但无法判断它是否正常工作.以下是正确的:
render_to_response(templatename, {'Cache-Control':'no-cache'},context_instance=RequestContext(httpreq))
Run Code Online (Sandbox Code Playgroud) 我正在尝试配置我的.htaccess文件来设置缓存时间.尝试了所有可能的配置但没有任何作用!
这是我的HTML中写的:
<meta http-equiv="Cache-Control" content="max-age=2592000, public" />
<!--
<meta http-equiv="expires" content="mon, 24 sep 2012 14:30:00 GMT">
-->
Run Code Online (Sandbox Code Playgroud)
这就是我的.htaccess文件中写的内容:
ExpiresActive On
ExpiresDefault A3600
Run Code Online (Sandbox Code Playgroud)
但是,当我在firefox中刷新包含缓存清除(ctrl + F5)时,我的firebug NET面板说缓存在我访问该文件的同一秒内到期(而不是将来,就像我希望的那样).
我究竟做错了什么??
谢谢
我想用spring在浏览器中显示pdf.我的问题是浏览器下载文件而不是显示它.这是我的代码:
@RequestMapping(value="/getpdf1", method=RequestMethod.GET)
public ResponseEntity<byte[]> getPDF1() {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.parseMediaType("application/pdf"));
String filename = "pdf1.pdf";
headers.add("content-disposition", "inline;filename=" + filename);
headers.setContentDispositionFormData(filename, filename);
headers.setCacheControl("must-revalidate, post-check=0, pre-check=0");
ResponseEntity<byte[]> response = new ResponseEntity<byte[]>(pdf1Bytes, headers, HttpStatus.OK);
return response;
}
Run Code Online (Sandbox Code Playgroud)
我期待着你的回答!谢谢