当前位置: 首页>>代码示例>>Java>>正文


Java StringEntity类代码示例

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


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

示例1: dispatchJSONPostRequest

import ch.boye.httpclientandroidlib.entity.StringEntity; //导入依赖的package包/类
public JSONObject dispatchJSONPostRequest(ApiSpec apiSpec, String requestPath, JSONObject jsonObject, AuthCredentials authCredentials) throws TeslaApiException {
    try {
        final URI uri = new URI(apiSpec.scheme, null, apiSpec.host, apiSpec.port, apiSpec.getPathForRequestPath(requestPath), null, null);
        Log.d(Config.TAG, "Executing request: " + uri.toURL());
        if(jsonObject != null){
            Log.d(Config.TAG, "Params: " + jsonObject.toString());
        }

        final HttpPost httpPost = new HttpPost(uri);
        if (authCredentials != null) {
            apiSpec.authModule.authorizeRequest(httpPost, authCredentials);
        }
        httpPost.setHeader("Content-Type", "application/json; charset=utf-8");
        if (jsonObject != null){
            httpPost.setEntity(new StringEntity(jsonObject.toString(), "UTF-8"));
        }

        return executeRequest(httpPost);
    } catch (UnsupportedEncodingException | URISyntaxException | MalformedURLException e) {
        throw new TeslaApiException(e);
    }
}
 
开发者ID:eleks,项目名称:rnd-android-wear-tesla,代码行数:23,代码来源:ApiEngine.java

示例2: simulate400

import ch.boye.httpclientandroidlib.entity.StringEntity; //导入依赖的package包/类
public static HttpResponse simulate400() {
  HttpResponse response = new BasicHttpResponse(new ProtocolVersion("HTTP", 1, 1), 400, "Bad Request") {
    @Override
    public HttpEntity getEntity() {
      try {
        return new StringEntity("16");
      } catch (UnsupportedEncodingException e) {
        // Never happens.
        return null;
      }
    }
  };
  return response;
}
 
开发者ID:jrconlin,项目名称:mc_backup,代码行数:15,代码来源:TestUpgradeRequired.java

示例3: SilkHttpBody

import ch.boye.httpclientandroidlib.entity.StringEntity; //导入依赖的package包/类
public SilkHttpBody(String body) {
    try {
        mEntity = new StringEntity(body, "UTF-8");
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:youtaya,项目名称:crabapple,代码行数:8,代码来源:SilkHttpBody.java

示例4: stringEntityWithContentTypeApplicationJSON

import ch.boye.httpclientandroidlib.entity.StringEntity; //导入依赖的package包/类
protected static StringEntity stringEntityWithContentTypeApplicationJSON(String s) {
  StringEntity e = new StringEntity(s, "UTF-8");
  e.setContentType("application/json");
  return e;
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:6,代码来源:BaseResource.java

示例5: jsonEntity

import ch.boye.httpclientandroidlib.entity.StringEntity; //导入依赖的package包/类
public static StringEntity jsonEntity(JSONObject body)
    throws UnsupportedEncodingException {
  StringEntity entity = new StringEntity(body.toJSONString(), "UTF-8");
  entity.setContentType("application/json");
  return entity;
}
 
开发者ID:jrconlin,项目名称:mc_backup,代码行数:7,代码来源:JPakeClient.java

示例6: jsonEntity

import ch.boye.httpclientandroidlib.entity.StringEntity; //导入依赖的package包/类
/**
 * Helper for turning a JSON object into a payload.
 * @throws UnsupportedEncodingException
 */
protected static StringEntity jsonEntity(JSONObject body) {
  return stringEntityWithContentTypeApplicationJSON(body.toJSONString());
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:8,代码来源:BaseResource.java


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