Java Code Examples for cn.hutool.http.HttpResponse#close()

The following examples show how to use cn.hutool.http.HttpResponse#close() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebUtils.java    From tools-ocr with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static String getHtml(String url) {
    HttpResponse response = get(url);
    String html = getSafeHtml(response);
    if (response != null) {
        response.close();
    }
    return html;
}
 
Example 2
Source File: WebUtils.java    From tools-ocr with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static String getLocation(String url, String cookie) {
    try {
        HttpResponse response = get(url, 0, new Hashtable<String, String>() {{
            put("Cookie", cookie);
        }}, false);
        if (response == null) {
            return url;
        }
        String location = response.header(Header.LOCATION);
        response.close();
        return location;
    } catch (Exception ex) {
        return "";
    }
}