• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java BasicHeader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中cz.msebera.android.httpclient.message.BasicHeader的典型用法代码示例。如果您正苦于以下问题:Java BasicHeader类的具体用法?Java BasicHeader怎么用?Java BasicHeader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BasicHeader类属于cz.msebera.android.httpclient.message包,在下文中一共展示了BasicHeader类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getRequestHeadersList

import cz.msebera.android.httpclient.message.BasicHeader; //导入依赖的package包/类
public List<Header> getRequestHeadersList() {
    List<Header> headers = new ArrayList<Header>();
    String headersRaw = headersEditText.getText() == null ? null : headersEditText.getText().toString();

    if (headersRaw != null && headersRaw.length() > 3) {
        String[] lines = headersRaw.split("\\r?\\n");
        for (String line : lines) {
            try {
                int equalSignPos = line.indexOf('=');
                if (1 > equalSignPos) {
                    throw new IllegalArgumentException("Wrong header format, may be 'Key=Value' only");
                }

                String headerName = line.substring(0, equalSignPos).trim();
                String headerValue = line.substring(1 + equalSignPos).trim();
                Log.d(LOG_TAG, String.format("Added header: [%s:%s]", headerName, headerValue));

                headers.add(new BasicHeader(headerName, headerValue));
            } catch (Throwable t) {
                Log.e(LOG_TAG, "Not a valid header line: " + line, t);
            }
        }
    }
    return headers;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:SampleParentActivity.java


示例2: getRequestHeaders

import cz.msebera.android.httpclient.message.BasicHeader; //导入依赖的package包/类
@Override
public Header[] getRequestHeaders() {
    List<Header> headers = getRequestHeadersList();

    // Add authentication header.
    if (userName != null && passWord != null) {
        byte[] base64bytes = Base64.encode(
                (userName + ":" + passWord).getBytes(),
                Base64.DEFAULT
        );
        String credentials = new String(base64bytes);
        headers.add(new BasicHeader(HEADER_AUTHORIZATION, HEADER_BASIC + " " + credentials));
    }

    return headers.toArray(new Header[headers.size()]);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:Http401AuthSample.java


示例3: deserializeHeaders

import cz.msebera.android.httpclient.message.BasicHeader; //导入依赖的package包/类
public static Header[] deserializeHeaders(String[] serialized) {
    if (serialized == null || serialized.length % 2 != 0) {
        return new Header[0];
    }
    Header[] headers = new Header[serialized.length / 2];
    for (int i = 0, h = 0; h < headers.length; i++, h++) {
        headers[h] = new BasicHeader(serialized[i], serialized[++i]);
    }
    return headers;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:IntentUtil.java


示例4: setAuthentication

import cz.msebera.android.httpclient.message.BasicHeader; //导入依赖的package包/类
/**
 * Set the different fields that are used for the various API calls.
 *
 * @param ctx The context used to make the requests.
 * @param app_id App Id from the Kairos developer dashboard.
 * @param api_key Api Key from the Kairos developer dashboard.
 */
public void setAuthentication(Context ctx, String app_id, String api_key) {
    this.my_context = ctx;
    this.my_app_id = app_id;
    this.my_api_key = api_key;
    this.my_host = "http://api.kairos.com/";

    mHeaders = new Header[]{new BasicHeader("Content-Type", "application/json"), new BasicHeader("app_id", my_app_id), new BasicHeader("app_key", my_api_key)};
}
 
开发者ID:code-mc,项目名称:FacerecognitionFlowpilots,代码行数:16,代码来源:Kairos.java


示例5: deletePost

import cz.msebera.android.httpclient.message.BasicHeader; //导入依赖的package包/类
@Override
public String deletePost(DeletePostModel model, ProgressListener listener, CancellableTask task) throws Exception {
    String url = getUsingUrl() + "post.php";
    List<NameValuePair> pairs = new ArrayList<NameValuePair>();
    pairs.add(new BasicNameValuePair("board", model.boardName));
    pairs.add(new BasicNameValuePair("delete_" + model.postNumber, "on"));
    if (model.onlyFiles) pairs.add(new BasicNameValuePair("file", "on"));
    pairs.add(new BasicNameValuePair("password", model.password));
    pairs.add(new BasicNameValuePair("delete", getDeleteFormValue(model)));
    pairs.add(new BasicNameValuePair("reason", ""));
    
    UrlPageModel refererPage = new UrlPageModel();
    refererPage.type = UrlPageModel.TYPE_THREADPAGE;
    refererPage.chanName = getChanName();
    refererPage.boardName = model.boardName;
    refererPage.threadNumber = model.threadNumber;
    Header[] customHeaders = new Header[] { new BasicHeader(HttpHeaders.REFERER, buildUrl(refererPage)) };
    HttpRequestModel rqModel = HttpRequestModel.builder().
            setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")).setCustomHeaders(customHeaders).setNoRedirect(true).build();
    HttpResponseModel response = null;
    try {
        response = HttpStreamer.getInstance().getFromUrl(url, rqModel, httpClient, listener, task);
        if (response.statusCode == 200 || response.statusCode == 400 || response.statusCode == 303) {
            ByteArrayOutputStream output = new ByteArrayOutputStream(1024);
            IOUtils.copyStream(response.stream, output);
            String htmlResponse = output.toString("UTF-8");
            Matcher errorMatcher = ERROR_PATTERN.matcher(htmlResponse);
            if (errorMatcher.find()) throw new Exception(errorMatcher.group(1));
            return null;
        }
        throw new Exception(response.statusCode + " - " + response.statusReason);
    } finally {
        if (response != null) response.release();
    }
}
 
开发者ID:miku-nyan,项目名称:Overchan-Android,代码行数:36,代码来源:AbstractVichanModule.java


示例6: reportPost

import cz.msebera.android.httpclient.message.BasicHeader; //导入依赖的package包/类
@Override
public String reportPost(DeletePostModel model, ProgressListener listener, CancellableTask task) throws Exception {
    String url = getUsingUrl() + "post.php";
    List<NameValuePair> pairs = new ArrayList<NameValuePair>();
    pairs.add(new BasicNameValuePair("board", model.boardName));
    pairs.add(new BasicNameValuePair("delete_" + model.postNumber, "on"));
    pairs.add(new BasicNameValuePair("password", ""));
    pairs.add(new BasicNameValuePair("reason", model.reportReason));
    pairs.add(new BasicNameValuePair("report", getReportFormValue(model)));
    
    UrlPageModel refererPage = new UrlPageModel();
    refererPage.type = UrlPageModel.TYPE_THREADPAGE;
    refererPage.chanName = getChanName();
    refererPage.boardName = model.boardName;
    refererPage.threadNumber = model.threadNumber;
    Header[] customHeaders = new Header[] { new BasicHeader(HttpHeaders.REFERER, buildUrl(refererPage)) };
    HttpRequestModel rqModel = HttpRequestModel.builder().
            setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")).setCustomHeaders(customHeaders).setNoRedirect(true).build();
    HttpResponseModel response = null;
    try {
        response = HttpStreamer.getInstance().getFromUrl(url, rqModel, httpClient, listener, task);
        if (response.statusCode == 200 || response.statusCode == 400 || response.statusCode == 303) {
            ByteArrayOutputStream output = new ByteArrayOutputStream(1024);
            IOUtils.copyStream(response.stream, output);
            String htmlResponse = output.toString("UTF-8");
            Matcher errorMatcher = ERROR_PATTERN.matcher(htmlResponse);
            if (errorMatcher.find()) throw new Exception(errorMatcher.group(1));
            return null;
        }
        throw new Exception(response.statusCode + " - " + response.statusReason);
    } finally {
        if (response != null) response.release();
    }
}
 
开发者ID:miku-nyan,项目名称:Overchan-Android,代码行数:35,代码来源:AbstractVichanModule.java


示例7: getAdapter

import cz.msebera.android.httpclient.message.BasicHeader; //导入依赖的package包/类
@Override
protected ImagePagerAdapter getAdapter() {
    for (int i = 0; i < urls.size(); i++) {
        urls.set(i, urls.get(i).replace("c/240x480/img-master", "img-original").replace("_master1200", ""));
    }
    return new ImagePagerAdapter(this, urls, new Header[]{new BasicHeader("Referer", Constants.BASE_API_PIXIV)});
}
 
开发者ID:SamuelGjk,项目名称:BPic,代码行数:8,代码来源:PixivGalleryActivity.java


示例8: prepareHeaders

import cz.msebera.android.httpclient.message.BasicHeader; //导入依赖的package包/类
/**
 * Ensure all required headers are present
 *
 * @param additionalHeaders List of headers specific to a single request
 * @return Complete list of headers necessary for API request
 */
private Header[] prepareHeaders(ArrayList<Header> additionalHeaders) {
    BasicHeader defaultHeader = new BasicHeader("Host", host);

    if (additionalHeaders != null) {
        ArrayList<Header> headers =
                (ArrayList<Header>) additionalHeaders.clone();
        headers.add(defaultHeader);

        return headers.toArray(new Header[headers.size()]);
    } else {
        return new Header[]{defaultHeader};
    }
}
 
开发者ID:OpenTreeMap,项目名称:otm-android,代码行数:20,代码来源:RestClient.java


示例9: createBasicAuthenticationHeader

import cz.msebera.android.httpclient.message.BasicHeader; //导入依赖的package包/类
private Header createBasicAuthenticationHeader(String username,
                                               String password) {
    String credentials = String.format("%s:%s", username, password);
    String encoded = Base64.encodeToString(credentials.getBytes(),
            Base64.NO_WRAP);
    return new BasicHeader("Authorization", String.format("%s %s", "Basic", encoded));
}
 
开发者ID:OpenTreeMap,项目名称:otm-android,代码行数:8,代码来源:RestClient.java


示例10: getContentType

import cz.msebera.android.httpclient.message.BasicHeader; //导入依赖的package包/类
@Override
public Header getContentType() {
    return new BasicHeader(
            AsyncHttpClient.HEADER_CONTENT_TYPE,
            "multipart/form-data; boundary=" + boundary);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:7,代码来源:SimpleMultipartEntity.java


示例11: tokenizeCard

import cz.msebera.android.httpclient.message.BasicHeader; //导入依赖的package包/类
void tokenizeCard(JSONObject jsonObject, AsyncHttpResponseHandler responseHandler) throws JSONException, UnsupportedEncodingException {
    ByteArrayEntity entity = new ByteArrayEntity(jsonObject.toString().getBytes("UTF-8"));
    entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
    httpClient.put(null, url + CARD_TOKENIZE + merchantToken, entity, "application/json", responseHandler);
}
 
开发者ID:bluesnap,项目名称:bluesnap-android-int,代码行数:6,代码来源:BlueSnapAPI.java


示例12: sendPost

import cz.msebera.android.httpclient.message.BasicHeader; //导入依赖的package包/类
@Override
public String sendPost(SendPostModel model, ProgressListener listener, CancellableTask task) throws Exception {
    UrlPageModel urlModel = new UrlPageModel();
    urlModel.chanName = getChanName();
    urlModel.boardName = model.boardName;
    if (model.threadNumber == null) {
        urlModel.type = UrlPageModel.TYPE_BOARDPAGE;
        urlModel.boardPage = UrlPageModel.DEFAULT_FIRST_PAGE;
    } else {
        urlModel.type = UrlPageModel.TYPE_THREADPAGE;
        urlModel.threadNumber = model.threadNumber;
    }
    String referer = buildUrl(urlModel);
    List<Pair<String, String>> fields = VichanAntiBot.getFormValues(referer, task, httpClient);
    
    if (task != null && task.isCancelled()) throw new Exception("interrupted");
    
    ExtendedMultipartBuilder postEntityBuilder = ExtendedMultipartBuilder.create().
            setCharset(Charset.forName("UTF-8")).setDelegates(listener, task);
    for (Pair<String, String> pair : fields) {
        if (pair.getKey().equals("spoiler") && !model.custommark) continue;
        String val;
        switch (pair.getKey()) {
            case "name": val = model.name; break;
            case "email": val = getSendPostEmail(model); break;
            case "subject": val = model.subject; break;
            case "body": val = model.comment; break;
            case "password": val = model.password; break;
            case "spoiler": val = "on"; break;
            default: val = pair.getValue();
        }
        if (pair.getKey().equals("file")) {
            if (model.attachments != null && model.attachments.length > 0) {
                postEntityBuilder.addFile(pair.getKey(), model.attachments[0], model.randomHash);
            } else {
                postEntityBuilder.addPart(pair.getKey(), new ByteArrayBody(new byte[0], ""));
            }
        } else {
            postEntityBuilder.addString(pair.getKey(), val);
        }
    }
    
    String url = getUsingUrl() + "post.php";
    Header[] customHeaders = new Header[] { new BasicHeader(HttpHeaders.REFERER, referer) };
    HttpRequestModel request =
            HttpRequestModel.builder().setPOST(postEntityBuilder.build()).setCustomHeaders(customHeaders).setNoRedirect(true).build();
    HttpResponseModel response = null;
    try {
        response = HttpStreamer.getInstance().getFromUrl(url, request, httpClient, listener, task);
        if (response.statusCode == 200 || response.statusCode == 400) {
            ByteArrayOutputStream output = new ByteArrayOutputStream(1024);
            IOUtils.copyStream(response.stream, output);
            String htmlResponse = output.toString("UTF-8");
            Matcher errorMatcher = ERROR_PATTERN.matcher(htmlResponse);
            if (errorMatcher.find()) throw new Exception(errorMatcher.group(1));
        } else if (response.statusCode == 303) {
            for (Header header : response.headers) {
                if (header != null && HttpHeaders.LOCATION.equalsIgnoreCase(header.getName())) {
                    return fixRelativeUrl(header.getValue());
                }
            }
        }
        throw new Exception(response.statusCode + " - " + response.statusReason);
    } finally {
        if (response != null) response.release();
    }
}
 
开发者ID:miku-nyan,项目名称:Overchan-Android,代码行数:68,代码来源:AbstractVichanModule.java


示例13: sendPost

import cz.msebera.android.httpclient.message.BasicHeader; //导入依赖的package包/类
@Override
public String sendPost(SendPostModel model, ProgressListener listener, CancellableTask task) throws Exception {
    int bVal = (int) (Math.random() * 10000);
    String banana = HttpStreamer.getInstance().getJSONObjectFromUrl((useHttps() ? "https://" : "http://") + "boards.420chan.org/bunker/",
            HttpRequestModel.builder().
            setPOST(new UrlEncodedFormEntity(Collections.singletonList(new BasicNameValuePair("b", Integer.toString(bVal))), "UTF-8")).
            setCustomHeaders(new Header[] { new BasicHeader("X-Requested-With", "XMLHttpRequest") }).
            build(), httpClient, null, task, false).optString("response");
    
    String url = (useHttps() ? "https://" : "http://") + "boards.420chan.org/" + model.boardName + "/taimaba.pl";
    ExtendedMultipartBuilder postEntityBuilder = ExtendedMultipartBuilder.create().setDelegates(listener, task).
            addString("board", model.boardName).
            addString("task", "post").
            addString("password", model.password);
    if (model.threadNumber != null) postEntityBuilder.addString("parent", model.threadNumber);
    postEntityBuilder.
            addString("field1", model.name).
            addString("field3", model.subject).
            addString("field4", model.comment);
    if (model.attachments != null && model.attachments.length > 0)
        postEntityBuilder.addFile("file", model.attachments[0], model.randomHash);
    if (model.sage) postEntityBuilder.addString("sage", "on");
    postEntityBuilder.addString("banana", banana);
    
    HttpRequestModel request = HttpRequestModel.builder().setPOST(postEntityBuilder.build()).setNoRedirect(true).build();
    HttpResponseModel response = null;
    try {
        response = HttpStreamer.getInstance().getFromUrl(url, request, httpClient, null, task);
        if (response.statusCode == 302) {
            return null;
        } else if (response.statusCode == 200) {
            ByteArrayOutputStream output = new ByteArrayOutputStream(1024);
            IOUtils.copyStream(response.stream, output);
            String htmlResponse = output.toString("UTF-8");
            Matcher errorMatcher = ERROR_PATTERN.matcher(htmlResponse);
            if (errorMatcher.find()) throw new Exception(errorMatcher.group(1));
        } else throw new Exception(response.statusCode + " - " + response.statusReason);
    } finally {
        if (response != null) response.release();
    }
    
    return null;
}
 
开发者ID:miku-nyan,项目名称:Overchan-Android,代码行数:44,代码来源:Chan420Module.java


示例14: sendPost

import cz.msebera.android.httpclient.message.BasicHeader; //导入依赖的package包/类
@Override
public String sendPost(SendPostModel model, ProgressListener listener, CancellableTask task) throws Exception {
    UrlPageModel urlModel = new UrlPageModel();
    urlModel.chanName = CHAN_NAME;
    urlModel.boardName = model.boardName;
    if (model.threadNumber == null) {
        urlModel.type = UrlPageModel.TYPE_BOARDPAGE;
        urlModel.boardPage = UrlPageModel.DEFAULT_FIRST_PAGE;
    } else {
        urlModel.type = UrlPageModel.TYPE_THREADPAGE;
        urlModel.threadNumber = model.threadNumber;
    }
    String referer = buildUrl(urlModel);
    List<Pair<String, String>> fields = VichanAntiBot.getFormValues(referer, task, httpClient);
    
    if (task != null && task.isCancelled()) throw new Exception("interrupted");
    
    ExtendedMultipartBuilder postEntityBuilder = ExtendedMultipartBuilder.create().
            setCharset(Charset.forName("UTF-8")).setDelegates(listener, task);
    for (Pair<String, String> pair : fields) {
        if (pair.getKey().equals("spoiler")) continue;
        String val;
        switch (pair.getKey()) {
            case "subject": val = model.subject; break;
            case "body": val = model.comment; break;
            case "password": val = model.password; break;
            default: val = pair.getValue();
        }
        int i = 1;
        String fileNo;
        switch (pair.getKey()) {
            case "file": case "file2": case "file3": case "file4":
                fileNo = pair.getKey().replaceAll("[\\D]", "");
                if (fileNo != "") {
                    i = Integer.parseInt(fileNo);
                }
                if (model.attachments == null || model.attachments.length < i) {
                    postEntityBuilder.addPart(pair.getKey(), new ByteArrayBody(new byte[0], ""));
                } else {
                    postEntityBuilder.addFile(pair.getKey(), model.attachments[i - 1], model.randomHash);
                }
                break;
            default:
                postEntityBuilder.addString(pair.getKey(), val);
        }
    }
    
    String url = getUsingUrl() + "post.php";
    Header[] customHeaders = new Header[] { new BasicHeader(HttpHeaders.REFERER, referer) };
    HttpRequestModel request =
            HttpRequestModel.builder().setPOST(postEntityBuilder.build()).setCustomHeaders(customHeaders).setNoRedirect(true).build();
    HttpResponseModel response = null;
    try {
        response = HttpStreamer.getInstance().getFromUrl(url, request, httpClient, listener, task);
        if (response.statusCode == 200 || response.statusCode == 400) {
            ByteArrayOutputStream output = new ByteArrayOutputStream(1024);
            IOUtils.copyStream(response.stream, output);
            String htmlResponse = output.toString("UTF-8");
            Matcher errorMatcher = ERROR_PATTERN.matcher(htmlResponse);
            if (errorMatcher.find()) throw new Exception(errorMatcher.group(1));
        } else if (response.statusCode == 303) {
            for (Header header : response.headers) {
                if (header != null && HttpHeaders.LOCATION.equalsIgnoreCase(header.getName())) {
                    return fixRelativeUrl(header.getValue());
                }
            }
        }
        throw new Exception(response.statusCode + " - " + response.statusReason);
    } finally {
        if (response != null) response.release();
    }
}
 
开发者ID:miku-nyan,项目名称:Overchan-Android,代码行数:73,代码来源:SichModule.java


示例15: sendPost

import cz.msebera.android.httpclient.message.BasicHeader; //导入依赖的package包/类
@Override
public String sendPost(SendPostModel model, ProgressListener listener, CancellableTask task) throws Exception {
    if (task != null && task.isCancelled()) throw new InterruptedException("interrupted");
    String url = getUsingUrl() + "post.php";
    ExtendedMultipartBuilder postEntityBuilder = ExtendedMultipartBuilder.create().setDelegates(listener, task).
            addString("name", model.name).
            addString("email", model.sage ? "sage" : model.email).
            addString("subject", model.subject).
            addString("body", model.comment).
            addString("post", model.threadNumber == null ? "New Topic" : "New Reply").
            addString("board", model.boardName);
    if (model.threadNumber != null) postEntityBuilder.addString("thread", model.threadNumber);
    if (model.custommark) postEntityBuilder.addString("spoiler", "on");
    postEntityBuilder.addString("password", TextUtils.isEmpty(model.password) ? getDefaultPassword() : model.password).
            addString("message", "").
            addString("json_response", "1");
    if (model.attachments != null) {
        String[] images = new String[] { "file", "file2", "file3", "file4", "file5" };
        for (int i=0; i<model.attachments.length; ++i) {
            postEntityBuilder.addFile(images[i], model.attachments[i], model.randomHash);
        }
    }
    
    UrlPageModel refererPage = new UrlPageModel();
    refererPage.chanName = getChanName();
    refererPage.boardName = model.boardName;
    if (model.threadNumber == null) {
        refererPage.type = UrlPageModel.TYPE_BOARDPAGE;
        refererPage.boardPage = UrlPageModel.DEFAULT_FIRST_PAGE;
    } else {
        refererPage.type = UrlPageModel.TYPE_THREADPAGE;
        refererPage.threadNumber = model.threadNumber;
    }
    Header[] customHeaders = new Header[] { new BasicHeader(HttpHeaders.REFERER, buildUrl(refererPage)) };
    HttpRequestModel request =
            HttpRequestModel.builder().setPOST(postEntityBuilder.build()).setCustomHeaders(customHeaders).setNoRedirect(true).build();
    JSONObject json = HttpStreamer.getInstance().getJSONObjectFromUrl(url, request, httpClient, listener, task, false);
    if (json.has("error")) {
        String error = json.getString("error");
        if (error.contains("To post on 8chan over Tor, you must use the hidden service for security reasons."))
            throw new Exception("To post on 8chan over Tor, you must use the onion domain.");
        throw new Exception(error);
    } else {
        String redirect = json.optString("redirect", "");
        if (redirect.length() > 0) return fixRelativeUrl(redirect);
        return null;
    }
}
 
开发者ID:miku-nyan,项目名称:Overchan-Android,代码行数:49,代码来源:InfinityPlModule.java


示例16: deletePost

import cz.msebera.android.httpclient.message.BasicHeader; //导入依赖的package包/类
@Override
public String deletePost(DeletePostModel model, ProgressListener listener, CancellableTask task) throws Exception {
    String url = getUsingUrl() + "post.php";
    List<NameValuePair> pairs = new ArrayList<NameValuePair>();
    pairs.add(new BasicNameValuePair("board", model.boardName));
    pairs.add(new BasicNameValuePair("delete_" + model.postNumber, "on"));
    if (model.onlyFiles) pairs.add(new BasicNameValuePair("file", "on"));
    pairs.add(new BasicNameValuePair("password", model.password));
    pairs.add(new BasicNameValuePair("delete", "Delete"));
    pairs.add(new BasicNameValuePair("reason", ""));
    
    UrlPageModel refererPage = new UrlPageModel();
    refererPage.type = UrlPageModel.TYPE_THREADPAGE;
    refererPage.chanName = getChanName();
    refererPage.boardName = model.boardName;
    refererPage.threadNumber = model.threadNumber;
    Header[] customHeaders = new Header[] { new BasicHeader(HttpHeaders.REFERER, buildUrl(refererPage)) };
    HttpRequestModel rqModel = HttpRequestModel.builder().
            setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")).setCustomHeaders(customHeaders).setNoRedirect(true).build();
    HttpResponseModel response = null;
    try {
        response = HttpStreamer.getInstance().getFromUrl(url, rqModel, httpClient, listener, task);
        if (response.statusCode == 200 || response.statusCode == 303) {
            Logger.d(TAG, response.statusCode + " - " + response.statusReason);
            return null;
        } else if (response.statusCode == 400) {
            ByteArrayOutputStream output = new ByteArrayOutputStream(1024);
            IOUtils.copyStream(response.stream, output);
            String htmlResponse = output.toString("UTF-8");
            if (htmlResponse.contains("dnsbls_bypass.php")) {
                needTorCaptcha = true;
                throw new Exception("Please complete your CAPTCHA.\n(try to post anything)");
            } else if (htmlResponse.contains("<h1>Error</h1>")) {
                Matcher errorMatcher = ERROR_PATTERN.matcher(htmlResponse);
                if (errorMatcher.find()) {
                    String error = errorMatcher.group(1);
                    if (error.contains("To post on 8chan over Tor, you must use the hidden service for security reasons."))
                        throw new Exception(resources.getString(R.string.infinity_tor_message)); //? Tor users cannot into deleting
                    throw new Exception(error);
                }
            }
        }
        throw new Exception(response.statusCode + " - " + response.statusReason);
    } finally {
        if (response != null) response.release();
    }
}
 
开发者ID:miku-nyan,项目名称:Overchan-Android,代码行数:48,代码来源:InfinityModule.java


示例17: getSignatureHeader

import cz.msebera.android.httpclient.message.BasicHeader; //导入依赖的package包/类
public Header getSignatureHeader(String verb, String url, byte[] body)
        throws URISyntaxException, SignatureException {
    String sig = getSignature(verb, url, body);
    return new BasicHeader("X-Signature", sig);
}
 
开发者ID:OpenTreeMap,项目名称:otm-android,代码行数:6,代码来源:RequestSignature.java


示例18: header

import cz.msebera.android.httpclient.message.BasicHeader; //导入依赖的package包/类
/**
 * 追加一个请求头
 *
 * @param key
 * @param value
 * @return
 */
public Req header(String key, String value) {
    this._headers.add(new BasicHeader(key, value));
    return this;
}
 
开发者ID:dtboy1995,项目名称:android-sex-http,代码行数:12,代码来源:Req.java



注:本文中的cz.msebera.android.httpclient.message.BasicHeader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Context类代码示例发布时间:2022-05-21
下一篇:
Java RequestEventListener类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap