Examples of InputStreamEntity


Examples of com.cloudera.lib.wsrs.InputStreamEntity

        //FileSystemReleaseFilter
        FSOpen command = new FSOpen(path.value());
        FileSystem fs = createFileSystem(user, doAs.value());
        InputStream is = command.execute(fs);
        AUDIT_LOG.info("[{}] offset [{}] len [{}]", new Object[]{path, offset, len});
        InputStreamEntity entity = new InputStreamEntity(is, offset.value(), len.value());
        response = Response.ok(entity).type(MediaType.APPLICATION_OCTET_STREAM).build();
        break;
      }
      case STATUS: {
        FSFileStatus command = new FSFileStatus(path.value());
View Full Code Here

Examples of org.apache.hadoop.lib.wsrs.InputStreamEntity

        InputStream is = command.execute(fs);
        Long offset = params.get(OffsetParam.NAME, OffsetParam.class);
        Long len = params.get(LenParam.NAME, LenParam.class);
        AUDIT_LOG.info("[{}] offset [{}] len [{}]",
                       new Object[]{path, offset, len});
        InputStreamEntity entity = new InputStreamEntity(is, offset, len);
        response =
          Response.ok(entity).type(MediaType.APPLICATION_OCTET_STREAM).build();
        break;
      }
      case GETFILESTATUS: {
View Full Code Here

Examples of org.apache.http.entity.InputStreamEntity

        final HttpPost httpPost = new HttpPost(url.toNormalform(true, false, true, false));
        String host = url.getHost();
        if (host == null) host = "127.0.0.1";
        setHost(host); // overwrite resolved IP, needed for shared web hosting DO NOT REMOVE, see http://en.wikipedia.org/wiki/Shared_web_hosting_service

        final InputStreamEntity inputStreamEntity = new InputStreamEntity(instream, length);
        // statistics
        this.upbytes = length;
        httpPost.setEntity(inputStreamEntity);
        return getContentBytes(httpPost, Long.MAX_VALUE);
    }
View Full Code Here

Examples of org.apache.http.entity.InputStreamEntity

        clone = (HttpPost) httppost.clone();
        assertTrue(clone.getEntity() instanceof StringEntity);
        assertFalse(clone.getEntity().equals(e1));
       
        ByteArrayInputStream instream = new ByteArrayInputStream(new byte[] {});
        InputStreamEntity e2 = new InputStreamEntity(instream, -1);
        httppost.setEntity(e2);
       
        try {
            httppost.clone();
            fail("CloneNotSupportedException should have been thrown");
View Full Code Here

Examples of org.apache.http.entity.InputStreamEntity

        FaultyHttpClient client = new FaultyHttpClient();
        HttpContext context = new BasicHttpContext();

        String s = "http://localhost:" + port;
        HttpPost httppost = new HttpPost(s);
        httppost.setEntity(new InputStreamEntity(
                new ByteArrayInputStream(
                        new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 } ),
                        -1));

        try {
View Full Code Here

Examples of org.apache.http.entity.InputStreamEntity

     @param data the content
     *  @param length Use -1 if unknown
     *  @param createFolders if true, intermediate folders are created via mkdirs
     */
    public void upload(String path, InputStream data, int length, boolean createFolders) throws IOException {
        final HttpEntity e = new InputStreamEntity(data, length);
        if(createFolders) {
            mkdirs(getParentPath(path));
        }
        executor.execute(
        builder.buildOtherRequest(
View Full Code Here

Examples of org.apache.http.entity.InputStreamEntity

      // Add the input entity (streamed) then execute the request.
      HttpResponse proxyResponse = null;
      InputStream servletRequestInputStream = servletRequest.getInputStream();
      try {
        try {
          proxyRequest.setEntity(new InputStreamEntity(servletRequestInputStream, servletRequest.getContentLength()));

          // Execute the request
          logger.debug("proxy " + servletRequest.getMethod() + " uri: " + servletRequest.getRequestURI() + " -- " + proxyRequest.getRequestLine().getUri());
          proxyResponse = proxyClient.execute(URIUtils.extractHost(targetUri), proxyRequest);
        } finally {
View Full Code Here

Examples of org.apache.http.entity.InputStreamEntity

      LOG.error("Unable to parse HTTP response"); return null;
    }     

    // Set the reset of the payload as the HTTP entity.  Use an InputStreamEntity
    // to avoid a memory copy.
    InputStreamEntity entity = new InputStreamEntity(new ByteArrayInputStream(this._payload, end, this._payload.length - end), this._payload.length - end);
    entity.setContentType(this._httpResponse.getFirstHeader("Content-Type"));
    entity.setContentEncoding(this._httpResponse.getFirstHeader("Content-Encoding"));
    this._httpResponse.setEntity(entity);

    return this._httpResponse;
  }
View Full Code Here

Examples of org.apache.http.entity.InputStreamEntity

                httpEntityRequest.setHeader(header, response.getHeader(header));
            }

            // get (http) entity which is for default Olingo2 implementation an InputStream
            if (response.getEntity() instanceof InputStream) {
                httpEntityRequest.setEntity(new InputStreamEntity((InputStream) response.getEntity()));
/*
                // avoid sending it without a header field set
                if (!httpEntityRequest.containsHeader(HttpHeaders.CONTENT_TYPE)) {
                    httpEntityRequest.addHeader(HttpHeaders.CONTENT_TYPE, getContentType());
                }
View Full Code Here

Examples of org.apache.http.entity.InputStreamEntity

            return null;
        }
    }

    private static HttpEntity asHttpEntity(InputStream in, Exchange exchange) throws IOException {
        InputStreamEntity entity;
        if (!exchange.getProperty(Exchange.SKIP_GZIP_ENCODING, Boolean.FALSE, Boolean.class)) {
            String contentEncoding = exchange.getIn().getHeader(Exchange.CONTENT_ENCODING, String.class);
            InputStream stream = GZIPHelper.compressGzip(contentEncoding, in);
            entity = new InputStreamEntity(stream, stream instanceof ByteArrayInputStream
                ? stream.available() != 0 ? stream.available() : -1 : -1);
        } else {
            entity = new InputStreamEntity(in, -1);
        }
        if (exchange != null) {
            String contentEncoding = exchange.getIn().getHeader(Exchange.CONTENT_ENCODING, String.class);
            String contentType = ExchangeHelper.getContentType(exchange);
            entity.setContentEncoding(contentEncoding);
            entity.setContentType(contentType);
        }
        return entity;
    }
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.