Package org.apache.http.entity

Examples of org.apache.http.entity.AbstractHttpEntity


            return null;

        final RequestEntityWriter requestEntityWriter = getRequestEntityWriter(cr);

        try {
            HttpEntity httpEntity = new AbstractHttpEntity() {
                    @Override
                    public boolean isRepeatable() {
                        return false;
                    }
View Full Code Here


    } else {
      encoding = EncodingEnum.XML;
      parser = myContext.newXmlParser();
    }

    AbstractHttpEntity entity;
    if (myParams != null) {
      List<NameValuePair> parameters = new ArrayList<NameValuePair>();
      for (Entry<String, List<String>> nextParam : myParams.entrySet()) {
        parameters.add(new BasicNameValuePair(nextParam.getKey(), StringUtils.join(nextParam.getValue(), ',')));
      }
View Full Code Here

    /**
     * Creates new instance of {@link HttpEntity} based on the current state.
     */
    public HttpEntity build() {
        final AbstractHttpEntity e;
        if (this.text != null) {
            e = new StringEntity(this.text, getContentOrDefault(ContentType.DEFAULT_TEXT));
        } else if (this.binary != null) {
            e = new ByteArrayEntity(this.binary, getContentOrDefault(ContentType.DEFAULT_BINARY));
        } else if (this.stream != null) {
            e = new InputStreamEntity(this.stream, 1, getContentOrDefault(ContentType.DEFAULT_BINARY));
        } else if (this.parameters != null) {
            e = new UrlEncodedFormEntity(this.parameters,
                    this.contentType != null ? this.contentType.getCharset() : null);
        } else if (this.serializable != null) {
            e = new SerializableEntity(this.serializable);
            e.setContentType(ContentType.DEFAULT_BINARY.toString());
        } else if (this.file != null) {
            e = new FileEntity(this.file, getContentOrDefault(ContentType.DEFAULT_BINARY));
        } else {
            e = new BasicHttpEntity();
        }
        if (e.getContentType() != null && this.contentType != null) {
            e.setContentType(this.contentType.toString());
        }
        e.setContentEncoding(this.contentEncoding);
        e.setChunked(this.chunked);
        if (this.gzipCompress) {
            return new GzipCompressingEntity(e);
        }
        return e;
    }
View Full Code Here

        });

        final TestHttpClient client = new TestHttpClient();
        try {
            HttpPost post = new HttpPost(DefaultServer.getDefaultServerURL());
            post.setEntity(new AbstractHttpEntity() {

                @Override
                public InputStream getContent() throws IOException, IllegalStateException {
                    return null;
                }
View Full Code Here

        }

        // Serialize body
        if (httpMethod instanceof HttpEntityEnclosingRequestBase) {
            HttpEntityEnclosingRequestBase entityEnclosingMethod = (HttpEntityEnclosingRequestBase) httpMethod;
            AbstractHttpEntity entity = null;
            // Any value set using setValueAsStream() has precedent over value
            // set using setValue()
            if (valueStream != null) {
                if (valueStreamLength != null && valueStreamLength >= 0) {
                    entity = new InputStreamEntity(valueStream, valueStreamLength);
                } else {
                    // since apache http client 4.1 no longer supports buffering stream entities, but we can't change API
                    // behaviour, here we have to buffer the whole content
                    entity = new ByteArrayEntity(ClientUtils.bufferStream(valueStream));
                }
            } else if (value != null) {
                entity = new ByteArrayEntity(value);
            } else {
                entity = new ByteArrayEntity(EMPTY);
            }
            entity.setContentType(contentType);
            entityEnclosingMethod.setEntity(entity);
        }
    }
View Full Code Here

        }

        // Serialize body
        if (httpMethod instanceof HttpEntityEnclosingRequestBase) {
            HttpEntityEnclosingRequestBase entityEnclosingMethod = (HttpEntityEnclosingRequestBase) httpMethod;
            AbstractHttpEntity entity = null;
            // Any value set using setValueAsStream() has precedent over value
            // set using setValue()
            if (valueStream != null) {
                if (valueStreamLength != null && valueStreamLength >= 0) {
                    entity = new InputStreamEntity(valueStream, valueStreamLength);
                } else {
                    // since apache http client 4.1 no longer supports buffering stream entities, but we can't change API
                    // behaviour, here we have to buffer the whole content
                    entity = new ByteArrayEntity(ClientUtils.bufferStream(valueStream));
                }
            } else if (value != null) {
                entity = new ByteArrayEntity(value);
            } else {
                entity = new ByteArrayEntity(EMPTY);
            }
            entity.setContentType(contentType);
            entityEnclosingMethod.setEntity(entity);
        }
    }
View Full Code Here

      HttpPost post = new HttpPost(strURL);
      post.addHeader("User-Agent", "OpenSIPg XML_RPC Client");

      // log.debug(stringToPost);

      AbstractHttpEntity entity = new ByteArrayEntity(
          stringToPost.getBytes(Charset.forName("ISO-8859-1")));

      // Prepare HTTP post
      HttpParams params = post.getParams();
      HttpProtocolParams.setContentCharset(params, "utf-8");
View Full Code Here

TOP

Related Classes of org.apache.http.entity.AbstractHttpEntity

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.