使用volley获取HTTP网络请求接口的响应头

一丶解决这个问题的时候先得知道什么响应头,与之对应的还有请求头

二.找到volley内部访问请求返回的response,并获取响应头信息

protected Response<String> parseNetworkResponse(NetworkResponse response) {
                String parsed;
                try {
                    parsed = new String(response.data, "UTF-8");
                    LogUtil.e("Header", response.headers.toString());
                } catch (UnsupportedEncodingException var4) {
                    parsed = new String(response.data);
                }
                return Response.success(parsed, HttpHeaderParser.parseCacheHeaders(response));

            }

volley内部返回的response可以获取到Header信息,由于header信息是map类型的,所以要获取某个key的值,则通过

response.headers.get("key")来获取。

猜你喜欢

转载自blog.csdn.net/qq_28670711/article/details/84854179