/** * Return the length of the content. This is always -1 except if useMultiPartContentType set as * true. Then the length will be the length of the generated request. * * @return -1 if useMultiPartContentType is false. Else the length of the generated request. */ public int getContentLength() { if (useMultiPartContentType) { byte[] request = buildRequest(); return request.length; } return -1; }
/** * Return the length of the content. This is always -1 except if useMultiPartContentType set as * true. Then the length will be the length of the generated request. * * @return -1 if useMultiPartContentType is false. Else the length of the generated request. */ public int getContentLength() { if (useMultiPartContentType) { byte[] request = buildRequest(); return request.length; } return -1; }
/** * Returns an input stream if there has been added some uploaded files. Use * {@link #addFile(String, File, String)} to add some uploaded files. * * @return The input stream * @throws IOException * If an I/O related problem occurs */ public ServletInputStream getInputStream() throws IOException { byte[] request = buildRequest(); // Ok lets make an input stream to return final ByteArrayInputStream bais = new ByteArrayInputStream(request); return new ServletInputStream() { @Override public int read() { return bais.read(); } }; }
byte[] request = buildRequest();