Get current request content as {@link InputStream}

@return {@link InputStream} containing the content that is going to be analyzed
169280
public InputStream getContent() {
        switch(contentType){
            case EMPTY:
                throw new RuntimeException("There is not Content available to analyze");
            case FILE:
                if(consumed)
                    try {
                        contentStream = Optional.of((InputStream) new FileInputStream(contentFile.get()));
                    } catch (FileNotFoundException e) {
                        throw new RuntimeException(e);
                    }
                break;
                case STRING:
                    if (consumed) {
                        if (contentEncoding.isPresent()) {
                            try {
                                contentStream = Optional.of(IOUtils.toInputStream(contentString.get(), contentEncoding.get()));
                            } catch (IOException e) {
                                throw new RuntimeException(e);
                            }
                        } else {
                            contentStream = Optional.of(IOUtils.toInputStream(contentString.get()));
                        }
                    }
                    break;
                case INPUTSTREAM:
                    if (consumed) {
                        throw new RuntimeException("The Content Stream to be analyzed has been already consumed");
                    }
                    break;
                default:
                    break;
        }
        
        consumed = true;
        return contentStream.get();
    }
1129980
public InputStream getInputStream() throws APIException, IOException {
        final HttpResponse response = client.get(getUrl());
        HttpClientHelpers.throwIfNotOk(response);
        return response.getEntity().getContent();
    }
422160
public InputStream getInputStream() {
        try {
            return connection.getInputStream();
        }catch(SocketTimeoutException e){
            throw new HttpException("Failed URL: " + url +
                    ", waited for: " + connection.getConnectTimeout() + " milliseconds", e);
        }catch (Exception e) {
            throw new HttpException("Failed URL: " + url, e);
        }
    }
418662
public @Nullable InputStream getInputStream() {
    if (mInputStreamSupplier != null) {
      return mInputStreamSupplier.get();
    }
    CloseableReference<PooledByteBuffer> pooledByteBufferRef =
        CloseableReference.cloneOrNull(mPooledByteBufferRef);
    if (pooledByteBufferRef != null) {
      try {
        return new PooledByteBufferInputStream(pooledByteBufferRef.get());
      } finally {
        CloseableReference.closeSafely(pooledByteBufferRef);
      }
    }
    return null;
  }
437943
public InputStream getInputStream()
    throws IOException
  {
    if (_is == null)
      _is = new FileInputStream(_file.getFD());

    return _is;
  }
802376
protected InputStream getStream(HttpClient httpClient, String url) {
        try {
            HttpEntity entity = get(httpClient, url);
            if (entity == null) return null;
            return entity.getContent();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
962358
public byte[] drain(InputStream inputStream) throws IOException {
        List<byte[]> previousBytes = new ArrayList<byte[]>();
        byte[] currentArray = new byte[bufferSize];
        int currentIndex = 0;
        int currentRead;
        do {
            currentRead = inputStream.read(currentArray, currentIndex, bufferSize - currentIndex);
            currentIndex += currentRead > 0 ? currentRead : 0;
            if (currentIndex == bufferSize) {
                previousBytes.add(currentArray);
                currentArray = new byte[bufferSize];
                currentIndex = 0;
            }
        } while (currentRead != END_OF_STREAM);
        byte[] result = new byte[previousBytes.size() * bufferSize + currentIndex];
        int arrayIndex = 0;
        for (byte[] previousByte : previousBytes) {
            System.arraycopy(previousByte, FROM_BEGINNING, result, arrayIndex++ * bufferSize, bufferSize);
        }
        System.arraycopy(currentArray, FROM_BEGINNING, result, arrayIndex * bufferSize, currentIndex);
        return result;
    }
1209241
public static InputStream getContentStream(String stringUrl) throws MalformedURLException, IOException {
        URL url = new URL(stringUrl);
        
        URLConnection urlConnection = url.openConnection();
        
        InputStream is = urlConnection.getInputStream();
        if ("gzip".equals(urlConnection.getContentEncoding())) {
           is = new GZIPInputStream(is);
        }

        return is;
    }
842113
public InputStream asInputStream() {
        InputStream is = fromStreamOrBufferOrUrl();
        if (is != null) return is;
        String s = fromStringOrReader();
        if (s != null) return streamFrom(s);
        throw resourceUnaccessible();
    }
149886
public InputStream getAsStream() throws CacheException {
		File file = null;
		try {
			File directory = new File(System.getProperty("java.library.path"));
			file = new File(directory, filename);
			if(file.exists() && file.isFile()) {
				return new FileInputStream(file);
			}
		} catch(IOException e) {
			logger.error("file '{}' does not exist on classpath or is not a file", filename);
			throw new CacheException("File " + filename + " does not exist on classpath or is not a regular file", e);			
		}
		return null;
	}
946577
@Override
    public InputStream getInputStream() throws IOException {
        if (!exists()) {
            throw new FileNotFoundException(getPath() + " (no such file or directory)");
        }
        if (Files.isDirectory(this.path)) {
            throw new FileNotFoundException(getPath() + " (is a directory)");
        }
        return Files.newInputStream(this.path);
    }
239436
public InputStream getAsStream() throws CacheException {
		InputStream stream = null;
		try {
			logger.debug("opening connection...");
			stream = url.openConnection(proxy != null ? proxy : Proxy.NO_PROXY).getInputStream();
			if(stream == null) {
				logger.error("error opening stream");
			} else {
				logger.debug("stream opened");
			}
		} catch(IOException e) {
			logger.error("error accessing url '{}'", url);
			throw new CacheException("error accessing url " + url, e);
		}
		return stream;
	}
965069
public byte[] readToBytes() {
        try {
            try (InputStream in = body()) {
                return InputStreams.readAll(in);
            }
        } catch (IOException e) {
            throw new RequestsException(e);
        } finally {
            close();
        }
    }
155344
public static InputStream getRequestInputStream(ExternalContext ec)
            throws IOException
    {
        RequestType type = getRequestType(ec);
        if (type.isRequestFromClient())
        {
            Object req = ec.getRequest();
            if (type.isPortlet())
            {
                return (InputStream) _runMethod(req, "getPortletInputStream");
            }
            else
            {
                return ((ServletRequest) ec.getRequest()).getInputStream();
            }
        }

        return null;
    }
180947
public InputStream getResponseBodyAsStream() throws HttpException {
    try {
      HttpEntity ent = getResponseEntity();

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

      return ent.getContent();
    } catch (Throwable t) {
      throw new HttpException(t.getLocalizedMessage(), t);
    }
  }
128137
public BufferedInputStream asBufferedInputStream() {
        InputStream is = asInputStream();
        if (is == null) return null;
        if (is instanceof BufferedInputStream) return (BufferedInputStream) is;
        return new BufferedInputStream(is);
    }
699823
@SuppressWarnings("resource")
    public InputStream getInputStream(String filename)
    {
        InputStream streamIn = null;
        if (filename.indexOf(':') == -1)
        {
            String filepath = ((BaseHttpTask)this.getTask()).getRealPath(this.getServletRequest(), filename);
            if (filepath != null)
            {
	            File file = new File(filepath);
	            try   {
	                streamIn = new FileInputStream(file);
	            } catch (FileNotFoundException ex)  {
	                streamIn = null;
	            }
            }
        }
        if (streamIn == null)
            streamIn = Utility.getInputStream(filename, this.getApplication());
        return streamIn;
    }