Examples of AbstractHttpEntity


Examples of org.apache.http.entity.AbstractHttpEntity

        }

        // 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

Examples of org.apache.http.entity.AbstractHttpEntity

   *             if something goes wrong.
   */
  public String upload(InputStream content) throws RedmineException {
    final URI uploadURI = getURIConfigurator().getUploadURI();
    final HttpPost request = new HttpPost(uploadURI);
    final AbstractHttpEntity entity = new InputStreamEntity(content, -1);
    /* Content type required by a Redmine */
    entity.setContentType("application/octet-stream");
    request.setEntity(entity);

    final String result = getCommunicator().sendRequest(request);
    return parseResponse(result, "upload",
            RedmineJSONParser.UPLOAD_TOKEN_PARSER);
View Full Code Here

Examples of org.apache.http.entity.AbstractHttpEntity

    private ContentType getContentOrDefault(final ContentType def) {
        return this.contentType != null ? this.contentType : def;
    }

    public HttpEntity build() {
        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

Examples of org.apache.http.entity.AbstractHttpEntity

    /**
     * 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

Examples of org.apache.http.entity.AbstractHttpEntity

        return null;
    }

    public String grabPageHTML(int verb, URIParameterBuilder builder) throws IOException, URISyntaxException {
        HttpResponse response;
        AbstractHttpEntity entity = null;
        URI uri = builder.buildURI();
        switch (builder.getEntityType()) {
            case ENTITY_STRING:
                entity = builder.buildStringEntity();
                break;
View Full Code Here

Examples of org.apache.http.entity.AbstractHttpEntity

        if (entity == null) {
            return null;
        }

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

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

Examples of org.apache.http.entity.AbstractHttpEntity

        if (entity == null) {
            return null;
        }

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

Examples of org.apache.http.entity.AbstractHttpEntity

        ByteArrayOutputStream b_out = new ByteArrayOutputStream() ;
        IndentedWriter out = new IndentedWriter(b_out) ;
        UpdateWriter.output(request, out) ;
        out.flush() ;
        byte[] bytes = b_out.toByteArray() ;
        AbstractHttpEntity reqEntity = new ByteArrayEntity(bytes) ;
        reqEntity.setContentType(WebContent.contentTypeSPARQLUpdate) ;
        reqEntity.setContentEncoding(HTTP.UTF_8) ;
        httpPost.setEntity(reqEntity) ;
        HttpClient httpclient = new DefaultHttpClient() ;

        try
        {
View Full Code Here

Examples of org.apache.http.entity.AbstractHttpEntity

                // Create and set RequestEntity
                ReqEntity bean = request.getBody();
                if (bean != null) {
                    try {
                        if(bean instanceof ReqEntitySimple) {
                            AbstractHttpEntity e = HTTPClientUtil.getEntity((ReqEntitySimple)bean);
                           
                            reqBuilder.setEntity(e);
                        }
                        else if(bean instanceof ReqEntityMultipart) {
                            ReqEntityMultipart multipart = (ReqEntityMultipart)bean;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.