添加标题后重定位1001

时间:2013-07-07 23:46:28

标签: http-headers cors restlet restlet-2.0

我试图添加一些标题以允许CORS,它以前工作得很好,但这次它给了我一个Restlet1001连接器错误和相同的代码

    Form responseHeaders = addHeader((Form) getResponse().getAttributes().get("org.restlet.http.headers")); 
    if (responseHeaders != null){
        getResponse().getAttributes().put("org.restlet.http.headers", responseHeaders); 
    } 

所以这是调用add header方法的代码,add header方法是:

public static Form addHeader(Form responseHeaders){
    if (responseHeaders == null) { 
        responseHeaders = new Form(); 
        responseHeaders.add("Access-Control-Allow-Origin", "*");
        responseHeaders.add("Access-Control-Allow-Methods", "POST, GET, PUT, DELETE, OPTIONS");
        responseHeaders.add("Access-Control-Allow-Headers", "Content-Type");
        responseHeaders.add("Access-Control-Allow-Headers", "authCode");
        responseHeaders.add("Access-Control-Allow-Headers", "origin, x-requested-with, content-type");
        return responseHeaders;
    }
    return null;
}

经过一番尝试和错误以及谷歌,我仍然不知道为什么它给了我:

2013-07-07  19:39:24    127.0.0.1   -   -   8015    GET /api/v1.0/users/findSession -   200 -   0   159 http://localhost:8015   Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36    -
2013-07-07  19:39:24    127.0.0.1   -   -   8015    GET /api/v1.0/users/findSession -   1001    -   0   1   http://localhost:8015   Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36    -
2013-07-07  19:39:24    127.0.0.1   -   -   8015    GET /api/v1.0/users/findSession -   1001    -   0   1   http://localhost:8015   Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36    -

1 个答案:

答案 0 :(得分:0)

您使用了哪个Restlet和HTTP连接器?如果您使用Restlet的内部连接器,也许可以尝试使用simple或jetty连接器。