Package org.apache.http

Examples of org.apache.http.HttpEntity


      {

         @Override
         public void process(final HttpResponse response, final HttpContext context) throws HttpException, IOException
         {
            HttpEntity entity = response.getEntity();
            if (entity != null)
            {
               Header header = entity.getContentEncoding();
               if (header != null)
               {
                  HeaderElement[] codecs = header.getElements();
                  for (int i = 0; i < codecs.length; i++)
                  {
View Full Code Here


   public String getResponseContent()
   {
      if (responseContent == null)
      {
         try {
            HttpEntity entity = getResponse().getEntity();
            if (entity != null)
            {
               responseContent = toString(entity.getContent());
            }
         }
         catch (Exception e) {
            throw new RewriteException("Could not stringify response InputStream", e);
         }
View Full Code Here

    * Copy response body data (the entity) from the proxy to the servlet client.
    */
   protected void copyResponseEntity(HttpResponse proxyResponse, HttpServletResponse servletResponse)
            throws IOException
   {
      HttpEntity entity = proxyResponse.getEntity();
      if (entity != null)
      {
         OutputStream servletOutputStream = servletResponse.getOutputStream();
         try
         {
            entity.writeTo(servletOutputStream);
         }
         finally
         {
            closeQuietly(servletOutputStream);
         }
View Full Code Here

//      });
   
    //设置响应拦截器
        httpClient.addResponseInterceptor(new HttpResponseInterceptor() {
            public void process(final HttpResponse response, final HttpContext context) throws HttpException, IOException {
                HttpEntity entity = response.getEntity();
                Header contentEncoding = entity.getContentEncoding();
                if (contentEncoding != null) {
                    HeaderElement[] codecs = contentEncoding.getElements();
                    for (HeaderElement codec : codecs) {
                      //处理GZIP解压缩
                        if (codec.getName().equalsIgnoreCase("gzip")) {
View Full Code Here

   * @return
   */
  public FetchResult fetch(FetchRequest req) throws Exception{
    FetchResult fetchResult = new FetchResult();
    HttpGet get = null;
    HttpEntity entity = null;
    String toFetchURL = req.getUrl();
    try {
      get = new HttpGet(toFetchURL);
      //设置请求GZIP压缩,注意,前面必须设置GZIP解压缩处理
      get.addHeader("Accept-Encoding", "gzip");
View Full Code Here

     * client_sig is SHA1 digest of encoded certificate on
     * <i>GoogleLoginService(package name : com.google.android.gsf)</i> system APK.
     * But google doesn't seem to care of value of this parameter.
     */
    public String loginAC2DM() throws IOException{
  HttpEntity c2dmResponseEntity = executePost(URL_LOGIN, new String[][] { { "Email", this.getEmail() },
    { "Passwd", this.password }, { "service", "ac2dm" }, { "accountType", ACCOUNT_TYPE_HOSTED_OR_GOOGLE },
    { "has_permission", "1" }, { "source", "android" }, { "app", "com.google.android.gsf" },
    { "device_country", "us" }, { "device_country", "us" }, { "lang", "en" }, { "sdk_version", "16" }, { "client_sig", "38918a453d07199354f8b19af05ec6562ced5788" }, }, null);

  Map<String, String> c2dmAuth = Utils.parseResponse(new String(Utils.readAll(c2dmResponseEntity.getContent())));
  return c2dmAuth.get("Auth");

    }
View Full Code Here

   
    public Map<String, String> c2dmRegister(String application, String sender) throws IOException{
 
  String c2dmAuth = loginAC2DM();
  String[][]  data = new String[][]{{"app", application},{"sender", sender}, {"device", new BigInteger(this.getAndroidID(), 16).toString()}};
  HttpEntity responseEntity = executePost(C2DM_REGISTER_URL, data, getHeaderParameters(c2dmAuth, null));
  return Utils.parseResponse(new String(Utils.readAll(responseEntity.getContent())));
    }
View Full Code Here

     * authentication token. This token can be used to login instead of using
     * email and password every time.
     */
    public void login() throws Exception {

  HttpEntity responseEntity = executePost(URL_LOGIN, new String[][] { { "Email", this.getEmail() }, { "Passwd", this.password },
    { "service", "androidmarket" }, { "accountType", ACCOUNT_TYPE_HOSTED_OR_GOOGLE }, { "has_permission", "1" },
    { "source", "android" }, { "androidId", this.getAndroidID() }, { "app", "com.android.vending" },
    { "device_country", "en" }, { "lang", "en" }, { "sdk_version", "16" }, { "client_sig", "38918a453d07199354f8b19af05ec6562ced5788" }, }, null);

  Map<String, String> response = Utils.parseResponse(new String(Utils.readAll(responseEntity.getContent())));
  if (response.containsKey("Auth")) {
      setToken(response.get("Auth"));
  } else {
      throw new GooglePlayException("Authentication failed!");
  }
View Full Code Here

     * Posts given check-in request content and returns
     * {@link AndroidCheckinResponse}.
     */
    private AndroidCheckinResponse postCheckin(byte[] request) throws IOException {

  HttpEntity httpEntity = executePost(CHECKIN_URL, new ByteArrayEntity(request), new String[][] {
    { "User-Agent", "Android-Checkin/2.0 (generic JRO03E); gzip" }, { "Host", "android.clients.google.com" },
    { "Content-Type", "application/x-protobuffer" } });
  return AndroidCheckinResponse.parseFrom(httpEntity.getContent());
    }
View Full Code Here

    public InputStream executeDownload(String url, String cookie) throws IOException {

  String[][] headerParams = new String[][] { { "Cookie", cookie },
    { "User-Agent", "AndroidDownloadManager/4.1.1 (Linux; U; Android 4.1.1; Nexus S Build/JRO03E)" }, };

  HttpEntity httpEntity = executeGet(url, null, headerParams);
  return httpEntity.getContent();
    }
View Full Code Here

TOP

Related Classes of org.apache.http.HttpEntity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.