Java http标头西里尔文位置

时间:2015-03-17 16:16:14

标签: java http utf-8 header

我通过AsyncHttpClient向已解码的西里尔语sybols发送请求。在响应状态码= 301时,我得到了“位置”字段,其中一些路径有其他字符集。例如:

reuqest url - /%D0%B3%D0%BE%D1%81%D1%82%D0%B8%D0%BD%D0%B8%D1%86%D1%8B/%D0%A5%D0%B0%D1%80%D1%8C%D0%BA%D0%BE%D0%B2%D0%B0/hotels-%D0%B3%D0%BE%D1%81%D1%82%D0%B8%D0%BD%D0%B8%D1%86%D0%B0-%D0%A5%D0%BE%D1%81%D1%82%D0%B5%D0%BB%D0%9D%D0%B0%D0%97%D0%B0%D0%BB%D0%B5%D1%81%D1%81%D0%BA%D0%BE%D0%B9-875/%D0%BE%D1%82%D0%B7%D1%8B%D0%B2%D1%8B/

标题位置 - /%D0%93%D0%BE%D1%81%D1%82%D0%B8%D0%BD%D0%B8%D1%86%D1%8B-%D0%A5%D0%B0%D1%80%D1%8C%D0%BA%D0%BE%D0%B2%D0%B0/%D0%A5%D0%BE%D1%81%D1%82%D0%B5%D0%BB-%D0%9D%D0%B0-%D0%97%D0%B0%D0%BB%D0%B5%D1%81%D1%81%D0%BA%D0%BE%D0%B9-875/**оÑзÑвÑ**/

代码:

Future<Response> responseFuture = client
            .prepareGet(url)
            .setBodyEncoding("UTF-8")
            .execute(new AsyncCompletionHandler<Response>() {
                @Override
                public Response onCompleted(Response response) throws Exception {
                    String location = response.getHeader("Location");
                    System.out.println(location);

                    return response;
                }

            });

如何在位置字段中获取正常编码的URL?

0 个答案:

没有答案