Back to project page foxail_reader.
The source code is released under:
GNU General Public License
If you think the Android project foxail_reader listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package org.foxail.android.common.volley; /*ww w . java 2 s .c om*/ import java.io.UnsupportedEncodingException; import org.apache.http.protocol.HTTP; import com.android.volley.NetworkResponse; import com.android.volley.Response; import com.android.volley.Request.Method; import com.android.volley.Response.ErrorListener; import com.android.volley.Response.Listener; import com.android.volley.toolbox.HttpHeaderParser; import com.android.volley.toolbox.StringRequest; public class HtmlRequest extends StringRequest { public HtmlRequest(int method, String url, Listener<String> listener, ErrorListener errorListener) { super(method, url, listener, errorListener); // TODO Auto-generated constructor stub } public HtmlRequest(String url, Listener<String> listener, ErrorListener errorListener) { this(Method.GET, url, listener, errorListener); } @Override protected Response<String> parseNetworkResponse(NetworkResponse response) { String parsed; try { String charset = HTTP.UTF_8; String contentType = response.headers.get(HTTP.CONTENT_TYPE); if (contentType != null) { String[] params = contentType.split(";"); for (int i = 1; i < params.length; i++) { String[] pair = params[i].trim().split("="); if (pair.length == 2) { if (pair[0].equals("charset")) { charset = pair[1]; } } } } parsed = new String(response.data, charset); } catch (UnsupportedEncodingException e) { parsed = new String(response.data); } return Response.success(parsed, HttpHeaderParser.parseCacheHeaders(response)); } }