List of usage examples for com.squareup.okhttp FormEncodingBuilder addEncoded
public FormEncodingBuilder addEncoded(String name, String value)
From source file:pw.isdust.isdust.Http.java
License:Open Source License
public String post_string_noturlencode(String url, String postbody) throws IOException { //POST/*from w w w.j ava 2 s. c om*/ String mstring_fenge1[] = postbody.split("&"); FormEncodingBuilder mFormEncodingBuilder = new FormEncodingBuilder(); Request.Builder a = new Request.Builder(); RequestBody mformBody; for (int i = 0; i < mstring_fenge1.length; i++) { String mstring_fenge2[] = mstring_fenge1[i].split("="); if (mstring_fenge2.length == 2) { mFormEncodingBuilder.addEncoded(mstring_fenge2[0], mstring_fenge2[1]); } if (mstring_fenge2.length == 1) { mFormEncodingBuilder.addEncoded(mstring_fenge1[i].replace("=", ""), ""); } } mformBody = mFormEncodingBuilder.build(); //String b=mformBody.toString(); //POST System.out.println(mformBody.toString()); //?? Request request = new Request.Builder().url(url).post(mformBody).header("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36") .build(); Response response_1; response_1 = mHTTP.newCall(request).execute(); return response_1.body().string(); }
From source file:pw.isdust.isdust.Http.java
License:Open Source License
public String post_string(String url, String postbody, final String bianma) throws IOException { //POST//from ww w . j av a 2 s . c o m String mstring_fenge1[] = postbody.split("&"); FormEncodingBuilder mFormEncodingBuilder = new FormEncodingBuilder(); RequestBody mformBody; for (int i = 0; i < mstring_fenge1.length; i++) { String mstring_fenge2[] = mstring_fenge1[i].split("="); if (mstring_fenge2.length == 2) { mFormEncodingBuilder.addEncoded(mstring_fenge2[0], mstring_fenge2[1]); } } mformBody = mFormEncodingBuilder.build(); //POST System.out.println(mformBody.toString()); //?? Request request = new Request.Builder().url(url).post(mformBody).build(); Response response_1; if (bianma == "gb2312") { response_1 = mHTTP.newCall(request).execute(); return new String(response_1.body().bytes(), "gb2312"); } return null; }