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

Java NameValuePair类代码示例

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

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



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

示例1: sanitizeICalUri

import cz.msebera.android.httpclient.NameValuePair; //导入依赖的package包/类
private String sanitizeICalUri(Uri uri) {
    try {
        URIBuilder b = new URIBuilder(uri.toString());
        List<NameValuePair> params = b.getQueryParams();
        b.clearParameters();
        for (NameValuePair param : params) {
            if (param.getName().equals("uid") || param.getName().equals("key")) {
                b.addParameter(param.getName(), "hidden");
            } else {
                b.addParameter(param.getName(), param.getValue());
            }
        }
        return b.toString();
    } catch (java.net.URISyntaxException e) {
        return "<URI parsing error>";
    }
}
 
开发者ID:danvratil,项目名称:FBEventSync,代码行数:18,代码来源:CalendarSyncAdapter.java


示例2: putWikiPage

import cz.msebera.android.httpclient.NameValuePair; //导入依赖的package包/类
/**
 * Replaces an entire wiki page
 *
 * @param httpclient an active HTTP session
 * @param pagename   the name of the wiki page
 * @param content    the new content of the wiki page to be submitted
 * @param formfields a hashmap with the fields needed (besides pagename and content; those will be filled in this method)
 * @throws WikiException problem with the wiki, translate the ID
 * @throws Exception     anything else happened, use getMessage
 */
public static void putWikiPage(@NonNull CloseableHttpClient httpclient,
                               @NonNull String pagename, String content,
                               @NonNull HashMap<String, String> formfields) throws Exception {
    // If there's no edit token in the hash map, we can't do anything.
    if(!formfields.containsKey("token")) {
        throw new WikiException(R.string.wiki_error_protected);
    }

    HttpPost httppost = new HttpPost(WIKI_API_URL);

    ArrayList<NameValuePair> nvps = new ArrayList<>();
    nvps.add(new BasicNameValuePair("action", "edit"));
    nvps.add(new BasicNameValuePair("title", pagename));
    nvps.add(new BasicNameValuePair("text", content));
    nvps.add(new BasicNameValuePair("format", "xml"));
    for(String s : formfields.keySet()) {
        nvps.add(new BasicNameValuePair(s, formfields.get(s)));
    }

    httppost.setEntity(new UrlEncodedFormEntity(nvps, "utf-8"));

    getWikiResponse(httpclient, httppost);

    // And really, that's it.  We're done!
}
 
开发者ID:CaptainSpam,项目名称:geohashdroid,代码行数:36,代码来源:WikiUtils.java


示例3: deletePost

import cz.msebera.android.httpclient.NameValuePair; //导入依赖的package包/类
@Override
public String deletePost(DeletePostModel model, ProgressListener listener, CancellableTask task) throws Exception {
    String url = getUsingUrl() + "cgi/delete";
    
    List<NameValuePair> pairs = new ArrayList<NameValuePair>();
    pairs.add(new BasicNameValuePair("board", model.boardName));
    pairs.add(new BasicNameValuePair("delete_" + model.postNumber, model.postNumber));
    pairs.add(new BasicNameValuePair("task", "delete"));
    pairs.add(new BasicNameValuePair("password", model.password));
    
    HttpRequestModel request = HttpRequestModel.builder().setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")).setNoRedirect(true).build();
    HttpResponseModel response = null;
    try {
        response = HttpStreamer.getInstance().getFromUrl(url, request, httpClient, null, task);
        if (response.statusCode == 302) {
            return null;
        }
        throw new Exception(response.statusCode + " - " + response.statusReason);
    } finally {
        if (response != null) response.release();
    }
}
 
开发者ID:miku-nyan,项目名称:Overchan-Android,代码行数:23,代码来源:DvachnetModule.java


示例4: checkCaptcha

import cz.msebera.android.httpclient.NameValuePair; //导入依赖的package包/类
private void checkCaptcha(String answer, CancellableTask task) throws Exception {
    try {
        if (torCaptchaCookie == null) throw new Exception("Invalid captcha");
        String url = getUsingUrl() + "dnsbls_bypass.php";
        List<NameValuePair> pairs = new ArrayList<NameValuePair>();
        pairs.add(new BasicNameValuePair("captcha_text", answer));
        pairs.add(new BasicNameValuePair("captcha_cookie", torCaptchaCookie));
        HttpRequestModel rqModel = HttpRequestModel.builder().setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")).setTimeout(30000).build();
        String response = HttpStreamer.getInstance().getStringFromUrl(url, rqModel, httpClient, null, task, true);
        if (response.contains("Error") && !response.contains("Success")) throw new HttpWrongStatusCodeException(400, "400");
        needTorCaptcha = false;
    } catch (HttpWrongStatusCodeException e) {
        if (task != null && task.isCancelled()) throw new InterruptedException("interrupted");
        if (e.getStatusCode() == 400) throw new Exception("You failed the CAPTCHA");
        throw e;
    }
}
 
开发者ID:miku-nyan,项目名称:Overchan-Android,代码行数:18,代码来源:InfinityModule.java


示例5: uploadFiles

import cz.msebera.android.httpclient.NameValuePair; //导入依赖的package包/类
/**
 * Upload files with {@link com.loopj.android.http.SyncHttpClient}
 *
 * @param url
 * @param paramsList
 * @param fileParams
 * @param files
 * @param responseHandler
 */
public static void uploadFiles(String url, List<NameValuePair> paramsList, String fileParams, List<File> files, AsyncHttpResponseHandler responseHandler) throws Exception {
    SyncHttpClient syncHttpClient = new SyncHttpClient();
    RequestParams params = new RequestParams();

    if (BasicUtils.judgeNotNull(paramsList)) {
        for (NameValuePair nameValuePair : paramsList) {
            params.put(nameValuePair.getName(), nameValuePair.getValue());
        }
    }
    if (BasicUtils.judgeNotNull(files))
        params.put(fileParams, files);

    syncHttpClient.setTimeout(timeout);
    syncHttpClient.post(url, params, responseHandler);
}
 
开发者ID:cymcsg,项目名称:UltimateAndroid,代码行数:25,代码来源:HttpUtilsAsync.java


示例6: parseEntityParams

import cz.msebera.android.httpclient.NameValuePair; //导入依赖的package包/类
private ParameterList parseEntityParams() {	
	cz.msebera.android.httpclient.HttpEntity entity = null;
	List<cz.msebera.android.httpclient.NameValuePair> parameters = null;
	try{
		entity = ((HttpEntityEnclosingRequestBase) httpUriRequest).getEntity();
		parameters = new ArrayList<NameValuePair>( URLEncodedUtils.parse(entity));
	} catch (Exception e) { 
		return new ParameterList();
	}
	
	ParameterList list = new ParameterList();
	for (NameValuePair pair : parameters) {
		list.add(pair.getName(), pair.getValue());
	}
	return list;
}
 
开发者ID:codepath,项目名称:android-oauth-handler,代码行数:17,代码来源:ScribeRequestAdapter.java


示例7: getQuery

import cz.msebera.android.httpclient.NameValuePair; //导入依赖的package包/类
@NonNull
public static String getQuery(List<NameValuePair> params) throws UnsupportedEncodingException {
    StringBuilder result = new StringBuilder();
    boolean first = true;

    for (NameValuePair pair : params) {
        if (first) first = false;
        else result.append("&");

        result.append(URLEncoder.encode(pair.getName(), "UTF-8"));
        result.append("=");
        result.append(URLEncoder.encode(pair.getValue(), "UTF-8"));
    }
    return result.toString();
}
 
开发者ID:danimahardhika,项目名称:wallpaperboard,代码行数:16,代码来源:JsonHelper.java


示例8: doInBackground

import cz.msebera.android.httpclient.NameValuePair; //导入依赖的package包/类
@Override
protected Void doInBackground(String... message) {
    // Create a new HttpClient and Post Header
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost("http://www.instruman.it/assets/feedback/update.php");

    try {
        //add data
        List<NameValuePair> nameValuePairs = new ArrayList<>(1);
        nameValuePairs.add(new BasicNameValuePair("stars", message[0]));
        nameValuePairs.add(new BasicNameValuePair("message", message[1]));
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
        //execute http post
        HttpResponse response = httpclient.execute(httppost);

    } catch (Exception e) {

    }
    return null;
}
 
开发者ID:paolo-optc,项目名称:optc-mobile-db,代码行数:21,代码来源:FeedbackDialogFragment.java


示例9: deletePost

import cz.msebera.android.httpclient.NameValuePair; //导入依赖的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


示例10: reportPost

import cz.msebera.android.httpclient.NameValuePair; //导入依赖的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


示例11: deletePost

import cz.msebera.android.httpclient.NameValuePair; //导入依赖的package包/类
@Override
public String deletePost(DeletePostModel model, ProgressListener listener, CancellableTask task) throws Exception {
    String url = getBoardScriptUrl(model);
    List<? extends NameValuePair> pairs = getDeleteFormAllValues(model);
    HttpRequestModel request = HttpRequestModel.builder().setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")).setNoRedirect(true).build();
    String result = HttpStreamer.getInstance().getStringFromUrl(url, request, httpClient, listener, task, false);
    checkDeletePostResult(model, result);
    return null;
}
 
开发者ID:miku-nyan,项目名称:Overchan-Android,代码行数:10,代码来源:AbstractKusabaModule.java


示例12: reportPost

import cz.msebera.android.httpclient.NameValuePair; //导入依赖的package包/类
@Override
public String reportPost(DeletePostModel model, ProgressListener listener, CancellableTask task) throws Exception {
    String url = getBoardScriptUrl(model);
    List<? extends NameValuePair> pairs = getReportFormAllValues(model);
    HttpRequestModel request = HttpRequestModel.builder().setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")).setNoRedirect(true).build();
    String result = HttpStreamer.getInstance().getStringFromUrl(url, request, httpClient, listener, task, false);
    checkReportPostResult(model, result);
    return null;
}
 
开发者ID:miku-nyan,项目名称:Overchan-Android,代码行数:10,代码来源:AbstractKusabaModule.java


示例13: getDeleteFormAllValues

import cz.msebera.android.httpclient.NameValuePair; //导入依赖的package包/类
protected List<? extends NameValuePair> getDeleteFormAllValues(DeletePostModel model) throws Exception {
    List<NameValuePair> pairs = new ArrayList<NameValuePair>();
    pairs.add(new BasicNameValuePair("board", model.boardName));
    pairs.add(new BasicNameValuePair("post[]", model.postNumber));
    if (model.onlyFiles) pairs.add(new BasicNameValuePair("fileonly", "on"));
    pairs.add(new BasicNameValuePair("postpassword", model.password));
    pairs.add(new BasicNameValuePair("deletepost", getDeleteFormValue(model)));
    return pairs;
}
 
开发者ID:miku-nyan,项目名称:Overchan-Android,代码行数:10,代码来源:AbstractKusabaModule.java


示例14: getReportFormAllValues

import cz.msebera.android.httpclient.NameValuePair; //导入依赖的package包/类
protected List<? extends NameValuePair> getReportFormAllValues(DeletePostModel model) throws Exception {
    List<NameValuePair> pairs = new ArrayList<NameValuePair>();
    pairs.add(new BasicNameValuePair("board", model.boardName));
    pairs.add(new BasicNameValuePair("post[]", model.postNumber));
    pairs.add(new BasicNameValuePair("reportreason", model.reportReason));
    pairs.add(new BasicNameValuePair("reportpost", getReportFormValue(model)));
    return pairs;
}
 
开发者ID:miku-nyan,项目名称:Overchan-Android,代码行数:9,代码来源:AbstractKusabaModule.java


示例15: deletePost

import cz.msebera.android.httpclient.NameValuePair; //导入依赖的package包/类
@Override
public String deletePost(DeletePostModel model, ProgressListener listener, CancellableTask task) throws Exception {
    String url = getDomainUrl() + model.boardName + "/delete";
    String threadAPIUrl = getDomainUrl() + "api/thread/" + model.boardName + "/" + model.threadNumber + ".json";
    String threadId = Long.toString(downloadJSONObject(threadAPIUrl, false, null, task).getLong("thread_id"));
    
    List<NameValuePair> pairs = new ArrayList<NameValuePair>();
    pairs.add(new BasicNameValuePair(model.postNumber, threadId));
    pairs.add(new BasicNameValuePair("task", "delete"));
    pairs.add(new BasicNameValuePair("password", model.password));
    
    HttpRequestModel request = HttpRequestModel.builder().setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")).setNoRedirect(true).build();
    HttpResponseModel response = null;
    try {
        response = HttpStreamer.getInstance().getFromUrl(url, request, httpClient, null, task);
        if (response.statusCode == 200) {
            ByteArrayOutputStream output = new ByteArrayOutputStream(1024);
            IOUtils.copyStream(response.stream, output);
            String htmlResponse = output.toString("UTF-8");
            Matcher errorMatcher = Pattern.compile("<center><h2>([^<]*)<").matcher(htmlResponse);
            if (errorMatcher.find()) throw new Exception(errorMatcher.group(1));
        }
    } finally {
        if (response != null) response.release();
        saveHanabiraCookie();
    }
    return null;
}
 
开发者ID:miku-nyan,项目名称:Overchan-Android,代码行数:29,代码来源:DobroModule.java


示例16: deletePost

import cz.msebera.android.httpclient.NameValuePair; //导入依赖的package包/类
@Override
public String deletePost(DeletePostModel model, ProgressListener listener, CancellableTask task) throws Exception {
    String url = getUsingUrl() + model.boardName + "/wakaba.pl";
    
    List<NameValuePair> pairs = new ArrayList<NameValuePair>();
    pairs.add(new BasicNameValuePair("delete", model.postNumber));
    pairs.add(new BasicNameValuePair("task", "delete"));
    if (model.onlyFiles) pairs.add(new BasicNameValuePair("fileonly", "on"));
    pairs.add(new BasicNameValuePair("password", model.password));
    
    HttpRequestModel request = HttpRequestModel.builder().setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")).setNoRedirect(true).build();
    HttpResponseModel response = null;
    try {
        response = HttpStreamer.getInstance().getFromUrl(url, request, httpClient, null, task);
        if (response.statusCode == 200) {
            ByteArrayOutputStream output = new ByteArrayOutputStream(1024);
            IOUtils.copyStream(response.stream, output);
            String htmlResponse = output.toString("UTF-8");
            if (!htmlResponse.contains("<blockquote")) {
                int start = htmlResponse.indexOf("<h1 style=\"text-align: center\">");
                if (start != -1) {
                    int end = htmlResponse.indexOf("<br /><br />", start + 31);
                    if (end != -1) {
                        throw new Exception(htmlResponse.substring(start + 31, end).trim());
                    }
                }
            }
        }
    } finally {
        if (response != null) response.release();
    }
    return null;
}
 
开发者ID:miku-nyan,项目名称:Overchan-Android,代码行数:34,代码来源:NowereModule.java


示例17: deletePost

import cz.msebera.android.httpclient.NameValuePair; //导入依赖的package包/类
@Override
public String deletePost(DeletePostModel model, ProgressListener listener, CancellableTask task) throws Exception {
    String url = CHAN410_URL + "board.php";
    
    List<NameValuePair> pairs = new ArrayList<NameValuePair>();
    pairs.add(new BasicNameValuePair("board", model.boardName));
    pairs.add(new BasicNameValuePair("delete[]", model.postNumber));
    if (model.onlyFiles) pairs.add(new BasicNameValuePair("fileonly", "on"));
    pairs.add(new BasicNameValuePair("postpassword", model.password));
    pairs.add(new BasicNameValuePair("deletepost", "Удалить"));
    
    HttpRequestModel request = HttpRequestModel.builder().setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")).setNoRedirect(true).build();
    String result = HttpStreamer.getInstance().getStringFromUrl(url, request, httpClient, listener, task, false);
    if (result.contains("Неверный пароль")) throw new Exception("Неверный пароль");
    return null;
}
 
开发者ID:miku-nyan,项目名称:Overchan-Android,代码行数:17,代码来源:Chan410Module.java


示例18: reportPost

import cz.msebera.android.httpclient.NameValuePair; //导入依赖的package包/类
@Override
public String reportPost(DeletePostModel model, ProgressListener listener, CancellableTask task) throws Exception {
    String url = CHAN410_URL + "board.php";
    
    List<NameValuePair> pairs = new ArrayList<NameValuePair>();
    pairs.add(new BasicNameValuePair("board", model.boardName));
    pairs.add(new BasicNameValuePair("delete[]", model.postNumber));
    pairs.add(new BasicNameValuePair("reportpost", "Пожаловаться"));
    
    HttpRequestModel request = HttpRequestModel.builder().setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")).setNoRedirect(true).build();
    String result = HttpStreamer.getInstance().getStringFromUrl(url, request, httpClient, listener, task, false);
    if (result.contains("Post successfully reported")) return null;
    throw new Exception(result);
}
 
开发者ID:miku-nyan,项目名称:Overchan-Android,代码行数:15,代码来源:Chan410Module.java


示例19: deletePost

import cz.msebera.android.httpclient.NameValuePair; //导入依赖的package包/类
@Override
public String deletePost(DeletePostModel model, ProgressListener listener, CancellableTask task) throws Exception {
    String url = IICHAN_URL + "cgi-bin/wakaba.pl/" + model.boardName + "/";
    
    List<NameValuePair> pairs = new ArrayList<NameValuePair>();
    pairs.add(new BasicNameValuePair("delete", model.postNumber));
    pairs.add(new BasicNameValuePair("task", "delete"));
    if (model.onlyFiles) pairs.add(new BasicNameValuePair("fileonly", "on"));
    pairs.add(new BasicNameValuePair("password", model.password));
    
    HttpRequestModel request = HttpRequestModel.builder().setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")).setNoRedirect(true).build();
    HttpResponseModel response = null;
    try {
        response = HttpStreamer.getInstance().getFromUrl(url, request, httpClient, null, task);
        if (response.statusCode == 200) {
            ByteArrayOutputStream output = new ByteArrayOutputStream(1024);
            IOUtils.copyStream(response.stream, output);
            String htmlResponse = output.toString("UTF-8");
            if (!htmlResponse.contains("<blockquote")) {
                int start = htmlResponse.indexOf("<h1 style=\"text-align: center\">");
                if (start != -1) {
                    int end = htmlResponse.indexOf("<br /><br />", start + 31);
                    if (end != -1) {
                        throw new Exception(htmlResponse.substring(start + 31, end).trim());
                    }
                }
            }
        }
    } finally {
        if (response != null) response.release();
    }
    return null;
}
 
开发者ID:miku-nyan,项目名称:Overchan-Android,代码行数:34,代码来源:CirnoModule.java


示例20: deletePost

import cz.msebera.android.httpclient.NameValuePair; //导入依赖的package包/类
@Override
public String deletePost(DeletePostModel model, ProgressListener listener, CancellableTask task) throws Exception {
    String url = getUsingUrl() + model.boardName + "/wakaba.pl";
    
    List<NameValuePair> pairs = new ArrayList<NameValuePair>();
    pairs.add(new BasicNameValuePair("delete", model.postNumber));
    pairs.add(new BasicNameValuePair("parent", model.threadNumber));
    pairs.add(new BasicNameValuePair("task", "delete"));
    if (model.onlyFiles) pairs.add(new BasicNameValuePair("fileonly", "on"));
    pairs.add(new BasicNameValuePair("password", model.password));
    
    HttpRequestModel request = HttpRequestModel.builder().setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")).setNoRedirect(true).build();
    HttpResponseModel response = null;
    try {
        response = HttpStreamer.getInstance().getFromUrl(url, request, httpClient, null, task);
        if (response.statusCode == 200) {
            ByteArrayOutputStream output = new ByteArrayOutputStream(1024);
            IOUtils.copyStream(response.stream, output);
            String htmlResponse = output.toString("UTF-8");
            if (!htmlResponse.contains("<blockquote")) {
                int start = htmlResponse.indexOf("<h1 style='text-align: center'>");
                if (start != -1) {
                    int end = htmlResponse.indexOf("<br><br>", start + 31);
                    if (end != -1) {
                        throw new Exception(htmlResponse.substring(start + 31, end).trim());
                    }
                }
            }
        }
    } finally {
        if (response != null) response.release();
    }
    return null;
}
 
开发者ID:miku-nyan,项目名称:Overchan-Android,代码行数:35,代码来源:InachModule.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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