标签: http-headers

Restangular:如何获取HTTP响应头?

我有一个REST服务器,它返回一个Link带有对PUT的响应的HTTP头,以指示新创建的实体的URL:

Link:<entities/6>; rel="created"
Run Code Online (Sandbox Code Playgroud)

有没有可能用Restangular读取该链接头?

到目前为止我唯一能够使用Restangular拦截HTTP请求的工具是在app config中注册响应拦截器:

restangular.addResponseInterceptor(function (data, operation, what, url, response, deferred) {
    console.log(response.headers())
    return response.data;
});
Run Code Online (Sandbox Code Playgroud)

但是,通过上面的演示实现,记录的唯一HTTP头是content-type.不过,我可以在一个响应来确实增加了不少额外的HTTP响应头,比如浏览器工具栏的发展看Server,Date和前述Link.

为什么我无法访问完整的HTTP响应头数组addResponseInterceptor()?有没有办法使用Restangular捕获有问题的HTTP响应头?

注意:我不使用HAL或任何其他特殊响应正文格式搜索答案.我想知道我是否可以使用带有Restangular的普通HTTP头(如果没有,我可能会使用HAL或其他东西).

http-headers restangular

3
推荐指数
1
解决办法
5606
查看次数

如何在Yii2中打开HTTP缓存?

我在控制器中设置了这些值,但它不起作用.

public function behaviors()
{
    return [
        'verbs' => [
            'class' => VerbFilter::className(),
            'actions' => [
                'delete' => ['post'],
            ],
        ],
        'httpCache' => [
          'class' => 'yii\filters\HttpCache',
          'sessionCacheLimiter' => 'public',
          'cacheControlHeader' => 'public, max-age=3600',
        ],
    ];
}
Run Code Online (Sandbox Code Playgroud)

http://www.yiiframework.com/doc-2.0/guide-caching-http.html#cache-control

$ curl -I http://localhost:81/xxxx/web/shopping/search?q=toaster
HTTP/1.1 200 OK
Date: Wed, 11 Nov 2015 08:58:57 GMT
Server: Apache/2.4.16 (Unix) OpenSSL/1.0.2d PHP/5.6.12
X-Powered-By: PHP/5.6.12
Set-Cookie: PHPSESSID=t07qapiiv7crdkva14ojn6cvg5; path=/; HttpOnly
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
Set-Cookie: search=4ef489ad7fa4567884eebc22279836f85acec05395053c863ed86c2679be9477a%3A2%3A%7Bi%3A0%3Bs%3A6%3A%22search%22%3Bi%3A1%3Bs%3A38%3A%22%2Fxxxx%2Fweb%2Fshopping%2Fsearch%3Fq%3Dtoaster%22%3B%7D; …
Run Code Online (Sandbox Code Playgroud)

php http-headers yii2

3
推荐指数
1
解决办法
3466
查看次数

在hapi中设置缓存头

如何将hapi中的缓存控制头设置为"no-cache","no-store","must-revalidate"?

在快递中,我能够做到以下几点: res.header('Cache-Control', 'no-cache, no-store, must-revalidate');

我目前在hapi中有以下内容,但我认为它可能不正确:

function(request, reply){
  var response = reply();
  response.header('Cache-Control', 'no-cache');
  response.header('Cache-Control', 'no-store');
  response.header('Cache-Control', 'must-revalidate'
}
Run Code Online (Sandbox Code Playgroud)

是否可以在hapi中执行此操作?

function(request, reply){
  var response = reply();
  response.header('Cache-Control', 'no-cache, no-store, must-revalidate');
}
Run Code Online (Sandbox Code Playgroud)

caching http-headers node.js express hapijs

3
推荐指数
1
解决办法
1493
查看次数

HTTP 1.1服务器如何响应HTTP 1.0请求?

HTTP 1.1服务器应如何响应HTTP 1.0 Pragma : no-cache中支持的HTTP 1.0请求,而不是HTTP 1.1中支持的头

protocols http cache-control http-1.1 http-headers

3
推荐指数
1
解决办法
6416
查看次数

如何在FileUtils.copyURLToFile(URL,File)方法中指定用户代理和引荐来源?

我使用FileUtils.copyURLToFile(URL, File),一个Apache的百科全书IO 2.4的一部分,下载并保存在我的电脑上的文件。问题是某些站点拒绝了没有引荐来源网址和用户代理数据的连接。

我的问题:

  1. 有什么方法可以指定该copyURLToFile方法的用户代理和引荐来源?
  2. 还是应该使用其他方法下载文件,然后将给定InputStream文件保存到文件?

java apache apache-commons http-headers

3
推荐指数
1
解决办法
1813
查看次数

spring-boot出现"400错误请求"错误,详细信息如下

春天靴子我很新.所以我问的问题可能是因为我错过了一些东西.我使用spring boot 1.3和freemarker来构建一个网站.当我提交表格(我没有填写的某些属性,这是我需要的情况)时,我收到"400错误请求".但是,当我填写表单的所有属性并提交时,它可以工作.那么,原因是什么?我该如何解决?

表单是以下代码.

    <label for="steelName" >??:</label>
    <input type="text" id="steelName" name="steelName" placeholder="??" value="${steelName!}" required><br/>

    <label for="steelCode" >??:</label>
    <input type="text" id="steelCode" name="steelCode" placeholder="??" value="${steelCode!}" required><br/>

    <label for="basic_price" >??:</label>
    <input type="text" id="basicPrice" name="basicPrice" placeholder="2000" value="${basicPrice!}" required>
    <label>?</label><br/>

    <label for="steel_factory" >??:</label>
    <input type="text" id="steelFactory" name="steelFactory" placeholder="????" value="${steelFactory!}" >

    <label for="city" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;??:</label>
    <input type="text" id="city" name="city" placeholder="??" value="${city!}" >

    <br/>

    <label for="width" >????:</label>
    <input type="text" id="lowWidth" name="lowWidth" placeholder="1.0" value="${lowWidth!}" >
    <label for=""> - </label>
    <input type="text" id="highWidth" name="highWidth" placeholder="1.6" value="${highWidth!}" >
    <label for=""> m …
Run Code Online (Sandbox Code Playgroud)

java forms spring-mvc http-headers spring-boot

3
推荐指数
1
解决办法
9025
查看次数

是否可以在URL本身中传递HTTP标头?

例如:如果我想像url Content-Type一样传递application/json,我该怎么做?

我确实了解邮递员,但使用得很少。我想知道是否可以使用chrome本身做我需要做的事情,而无需使用POSTMAN。

url http http-headers postman

3
推荐指数
1
解决办法
7025
查看次数

启用Apache http授权标头

我写的API与PHP ZF2他们使用HTTP授权.我取了所有的HTTP标题apache_request_headers()(也用ZF2测试过$this->getRequest()->getHeaders()).

它适用于我的语言环境安装版本.但是在我的服务器上,HTTP授权标头不可用.我的浏览器调试工具向我显示授权标头正确发送.

这两个服务器都使用相同的软件运行:Ubuntu 14.04与Apache2(服务器版本:阿帕奇/ 2.4.7(Ubuntu的)).

启用apache2模块(auth_basic已启用): 启用了Apache2模块

是否有PHP ini允许授权标头的设置?

编辑2015-05-13:

$headers = apache_request_headers();
if (isset($headers['Authorization'])) {
    echo 'you are auth';
} else {
    echo 'there is no Authorization';
}
Run Code Online (Sandbox Code Playgroud)

在我的语言环境系统上,这将在服务器上返回"你是auth","没有授权".在Chrome浏览器中使用Postman应用进行测试.

编辑2015-05-14:我认为这是一个Apache2主题.

如何在Apache2中启用Authorization标头?

php apache authorization http-headers

3
推荐指数
1
解决办法
7609
查看次数

Angular 2,Http和Not设置Content-Type"application/json"

我试图在服务中使用Angular 2(2.0.0-rc.1)进行简单的Check Login方法.当我尝试将内容类型设置为application/json时,它在发送到我的web api后端时从不设置标题.

import { Injectable } from '@angular/core';
import { HTTP_PROVIDERS, Http, Response, Headers, RequestOptionsArgs, RequestMethod, Request, RequestOptions } from '@angular/http';
import { Observable } from 'rxjs/Rx';
import { Other Modules Left out for Security } from 'Hidden';

@Injectable()
export class LoginService {

private _http: Http;


constructor(http: Http) {
    this._http = http;


}

CheckLogin(model: CredentialModel) {

    let url = 'http://localhost:51671/api/Login';

    let data = JSON.stringify(model);        

    let headers = new Headers();
    headers.append('Content-Type', 'application/json');
    headers.append('Accept', 'application/json');


    let requestOptions = new RequestOptions({ …
Run Code Online (Sandbox Code Playgroud)

http-headers angular

3
推荐指数
1
解决办法
8394
查看次数

java okhttp动态地使用for循环添加头文件

许多例子显示添加标题应该:

Request request = new Request.Builder()
    .url("https://api.github.com/repos/square/okhttp/issues")
    .header("User-Agent", "OkHttp Headers.java")
    .addHeader("Accept", "application/json; q=0.5")
    .addHeader("Accept", "application/vnd.github.v3+json")
    .build();
Run Code Online (Sandbox Code Playgroud)

但我想动态添加标题作为用户的标题要求,我该如何实现它?

Headers h = new Headers.Builder().build();
for (HttpHeader hh : ht.HttpRequestHeader) {
    h.newBuilder().add(hh.Name, hh.Value);
}  //<<---Nothing changed!!!!!
Run Code Online (Sandbox Code Playgroud)

java http-headers okhttp okhttp3

3
推荐指数
1
解决办法
1308
查看次数