Java Code Examples for cz.msebera.android.httpclient.entity.ContentType

The following examples show how to use cz.msebera.android.httpclient.entity.ContentType. These examples are extracted from open source projects. 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 Project: BaiduPanApi-Java   Author: xm0625   File: BaseClass.java    License: MIT License 6 votes vote down vote up
protected CloseableHttpResponse checkLogin(CloseableHttpResponse closeableHttpResponse) throws IOException {
    HttpEntity bufferedHttpEntity = closeableHttpResponse.getEntity();
    String mimeString = ContentType.getOrDefault(bufferedHttpEntity).getMimeType();
    if(mimeString.contains("application/json") || mimeString.contains("text/html")) {
        String content = HttpClientHelper.getResponseString(closeableHttpResponse);
        System.out.println("checkLogin() content:"+content);
        try {
            JSONObject jsonObject = (JSONObject) JSON.parse(content);
            if (jsonObject.containsKey("errno") && String.valueOf(jsonObject.get("errno")).equals("-6")) {
                clearCookies();
                initiate();
            }
        } catch (Exception e) {
        }
    }
    return closeableHttpResponse;
}
 
Example #2
Source Project: Overchan-Android   Author: miku-nyan   File: ExtendedMultipartBuilder.java    License: GNU General Public License v3.0 2 votes vote down vote up
/**
 * Добавить строку в кодировке UTF-8
 * @param key имя (ключ)
 * @param value строка
 * @return этот объект
 */
public ExtendedMultipartBuilder addString(String key, String value) {
    return addPart(key, new StringBody(value, ContentType.create("text/plain", "UTF-8")));
}