List of usage examples for org.apache.http.protocol HTTP UTF_8
String UTF_8
To view the source code for org.apache.http.protocol HTTP UTF_8.
Click Source Link
From source file:com.atet.tvmarket.model.netroid.request.DataTaskRequest.java
@Override public NetworkResponse perform() { // TODO Auto-generated method stub try {// w ww .j a v a 2 s . c om return new NetworkResponse(null, HTTP.UTF_8); } catch (Exception e) { return new NetworkResponse(new byte[1], HTTP.UTF_8); } }
From source file:de.escidoc.core.test.sm.ScopeTestBase.java
/** * Test creating a Scope.//w ww. ja va 2 s . com * * @param dataXml The xml representation of the Scope. * @return The created Scope. * @throws Exception If anything fails. */ public String create(final String dataXml) throws Exception { Object result = getScopeClient().create(dataXml); String xmlResult = null; if (result instanceof HttpResponse) { HttpResponse httpRes = (HttpResponse) result; xmlResult = EntityUtils.toString(httpRes.getEntity(), HTTP.UTF_8); assertHttpStatusOfMethod("", httpRes); } else if (result instanceof String) { xmlResult = (String) result; } return xmlResult; }
From source file:org.changhong.sync.web.MySSLSocketFactory.java
public static DefaultHttpClient getNewHttpClient() { try {/*from w w w .j a va 2 s. c o m*/ KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType()); trustStore.load(null, null); SSLSocketFactory sf = new MySSLSocketFactory(trustStore); sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); HttpParams params = new BasicHttpParams(); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); HttpProtocolParams.setContentCharset(params, HTTP.UTF_8); SchemeRegistry registry = new SchemeRegistry(); registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); registry.register(new Scheme("https", sf, 443)); ClientConnectionManager ccm = new ThreadSafeClientConnManager(params, registry); return new DefaultHttpClient(ccm, params); } catch (Exception e) { return new DefaultHttpClient(); } }
From source file:com.baseproject.volley.NetworkResponse.java
public NetworkResponse(byte[] data, String etag) { this(HttpStatus.SC_OK, data, etag, HTTP.UTF_8, false); }
From source file:com.wialon.remote.ApacheSdkHttpClient.java
private static BasicHttpParams getBasicHttpParams(int timeout) { BasicHttpParams params = new BasicHttpParams(); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); HttpProtocolParams.setContentCharset(params, HTTP.UTF_8); HttpProtocolParams.setHttpElementCharset(params, HTTP.UTF_8); HttpConnectionParams.setConnectionTimeout(params, timeout); HttpConnectionParams.setSoTimeout(params, timeout); return params; }
From source file:com.baseproject.volley.toolbox.HttpHeaderParser.java
/** * Returns the charset specified in the Content-Type of this header, * or the HTTP default (ISO-8859-1) if none can be found. *//* ww w . j a va 2 s .c o m*/ public static String parseCharset(Map<String, String> headers) { String result = null; try { String contentType = headers.get(HTTP.CONTENT_TYPE); if (contentType != null) { String[] params = contentType.split(";"); for (int i = 1; i < params.length; i++) { String[] pair = params[i].trim().split("="); if (pair.length == 2) { if (pair[0].equals("charset")) { result = pair[1]; break; } } } } } catch (Exception e) { result = null; e.printStackTrace(); } if (!TextUtils.isEmpty(result)) { return result; } return HTTP.UTF_8; }
From source file:de.escidoc.core.test.sm.ReportDefinitionTestBase.java
/** * Test creating a reportDefinition.//from w w w . j a v a 2s . c o m * * @param dataXml The xml representation of the reportDefinition. * @return The created ReportDefinition. * @throws Exception If anything fails. */ @Override public String create(final String dataXml) throws Exception { Object result = getReportDefinitionClient().create(dataXml); String xmlResult = null; if (result instanceof HttpResponse) { HttpResponse httpRes = (HttpResponse) result; xmlResult = EntityUtils.toString(httpRes.getEntity(), HTTP.UTF_8); assertHttpStatusOfMethod("", httpRes); } else if (result instanceof String) { xmlResult = (String) result; } return xmlResult; }
From source file:com.syrup.storage.xml.XmlFactory.java
/** * Convert document to string. Helper method. * // ww w . ja v a 2s . c o m * @param document * the document object. * @return String. * @throws java.io.IOException when unable to write the xml * @throws javax.xml.transform.TransformerException when unable to transform the document */ public static String documentToString(Document document) throws IOException, TransformerException { String soapRequest = null; if (document != null) { Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); transformer.setOutputProperty(OutputKeys.ENCODING, HTTP.UTF_8); StreamResult result = new StreamResult(new StringWriter()); DOMSource source = new DOMSource(document); transformer.transform(source, result); return result.getWriter().toString(); } return soapRequest; }
From source file:com.appassit.http.ApiRequestFactory.java
/** * POSTHttpEntity// ww w . jav a 2 s. c o m * * @param params * ? * @throws UnsupportedEncodingException * ???UTF8?? */ private static HttpEntity getPostRequestEntity(ArrayList<BasicNameValuePair> params) throws UnsupportedEncodingException { if (params == null || params.isEmpty()) return null; return new UrlEncodedFormEntity(params, HTTP.UTF_8); }
From source file:com.testmax.uri.HttpRestWebservice.java
public String handleHTTPPostUnit() throws Exception { String resp = null;//w w w . j a v a 2 s .co m String replacedParam = ""; System.out.println(this.url); HttpPost httpost = new HttpPost(this.url); //System.out.println(this.url); List<NameValuePair> nvps = new ArrayList<NameValuePair>(); URLConfig urlConf = this.page.getURLConfig(); Set<String> s = urlConf.getUrlParamset(); for (String param : s) { replacedParam = urlConf.getUrlParamValue(param); System.out.println(urlConf.getUrlParamValue(param)); nvps.add(new BasicNameValuePair(param, urlConf.getUrlParamValue(param))); } httpost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8)); //set the time for this HTTP resuest this.startRecording(); long starttime = this.getCurrentTime(); HttpResponse response = this.httpsclient.execute(httpost); HttpEntity entity = response.getEntity(); // Measure the time passed between response long elaspedTime = this.getElaspedTime(starttime); this.stopRecording(response, elaspedTime); resp = this.getResponseBodyAsString(entity); System.out.println(resp); System.out.println("ElaspedTime: " + elaspedTime); WmLog.getCoreLogger().info("Response XML: " + resp); WmLog.getCoreLogger().info("ElaspedTime: " + elaspedTime); this.printRecording(); this.printLog(); if (this.getResponseStatus() == 200 && validateAssert(urlConf, resp)) { this.addThreadActionMonitor(this.action, true, elaspedTime); } else { this.addThreadActionMonitor(this.action, false, elaspedTime); WmLog.getCoreLogger().info("Input XML: " + replacedParam); WmLog.getCoreLogger().info("Response XML: " + resp); } this.closeEntity(entity); return (resp); }