• Android 使用httpClient POST 模拟发送 multipart表单内容


    使用的环境:apache-mime4j-0.6.jar,httpcore-4.3.2.jar,httpmime-4.3.3.jar

    try {
                        HttpPost httpPost = new HttpPost(GlobalData.urls.get("awsSub"));
                        MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder.create();
                        multipartEntityBuilder.addTextBody("title", "send by mobile");
                        multipartEntityBuilder.addTextBody("id", "");
                        multipartEntityBuilder.addTextBody("op", "");
                        multipartEntityBuilder.addTextBody("type1", "1");
                        multipartEntityBuilder.addTextBody("ip", "");
                        multipartEntityBuilder.addTextBody("admuser", "");
                        multipartEntityBuilder.addTextBody("admpass", "");
                        multipartEntityBuilder.addTextBody("ftpname", "");
                        multipartEntityBuilder.addTextBody("url", "");
                        multipartEntityBuilder.addTextBody("Body", "手机端发送滴哟 内容");
                        multipartEntityBuilder.addTextBody("autofix", "1");
                        multipartEntityBuilder.addTextBody("Submitend", "提交");
                        multipartEntityBuilder.addTextBody("Submit", "继续发表");
                        multipartEntityBuilder.addTextBody("XQtitle", "");
                        multipartEntityBuilder.addTextBody("theBody", "");
                        multipartEntityBuilder.addBinaryBody("aboutimg1", new byte[0], ContentType.MULTIPART_FORM_DATA,"");
                        multipartEntityBuilder.addBinaryBody("aboutimg2", new byte[0], ContentType.MULTIPART_FORM_DATA,"");
                        multipartEntityBuilder.addBinaryBody("aboutimg3", new byte[0], ContentType.MULTIPART_FORM_DATA,"");
                        multipartEntityBuilder.addBinaryBody("aboutimg4", new byte[0], ContentType.MULTIPART_FORM_DATA,"");
                        multipartEntityBuilder.addBinaryBody("aboutimg5", new byte[0], ContentType.MULTIPART_FORM_DATA,"");
                        multipartEntityBuilder.addTextBody("endtest", "");
    
                        httpPost.setEntity(multipartEntityBuilder.build());
                        HttpResponse httpResponse = HttpUtil.httpClient.execute(httpPost);
                        String txt = EntityUtils.toString(httpResponse.getEntity(),"gbk");
                        Intent intent = new Intent(KeFuActivity.this, ResultActivity.class);
                        intent.putExtra("html",txt);
                        startActivity(intent);
                    } catch (Exception e) {
                      e.printStackTrace();
                    }
  • 相关阅读:
    istringstream、ostringstream、stringstream 类介绍 .
    istringstream、ostringstream、stringstream 类介绍 .
    Leading and Trailing(LightOJ
    欧拉函数(重要性质)
    UML——概述
    UML——用例视图
    JUnit——assertThat(acture,matcher)
    JUnit——Failure与Error
    JUnit——Annotation
    JUnit——运行多个测试方法
  • 原文地址:https://www.cnblogs.com/wuyou/p/3640325.html
Copyright © 2020-2023  润新知