/** * Open output stream * * @return this request * @throws IOException */ protected HttpRequest openOutput() throws IOException { if (output != null) return this; connection.setDoOutput(true); final String charset = getParam( connection.getRequestProperty(HEADER_CONTENT_TYPE), PARAM_CHARSET); output = new RequestOutputStream(connection.getOutputStream(), charset, bufferSize); return this; }
/** * Close output stream * * @return this request * @throws HttpRequestException * @throws IOException */ protected HttpRequest closeOutput() throws IOException { if (output == null) return this; if (multipart) output.write(CRLF + "--" + BOUNDARY + "--" + CRLF); if (ignoreCloseExceptions) try { output.close(); } catch (IOException ignored) { // Ignored } else output.close(); output = null; return this; }
/** * Close output stream * * @return this request * @throws HttpRequestException * @throws IOException */ protected HttpRequest closeOutput() throws IOException { if (output == null) return this; if (multipart) output.write(CRLF + "--" + BOUNDARY + "--" + CRLF); if (ignoreCloseExceptions) try { output.close(); } catch (IOException ignored) { // Ignored } else output.close(); output = null; return this; }
/** * Write part of a multipart request to the request body * * @param name * @param filename * @param contentType * value of the Content-Type part header * @param part * @return this request * @throws HttpRequestException */ public HttpRequest part(final String name, final String filename, final String contentType, final String part) throws HttpRequestException { try { startPart(); writePartHeader(name, filename, contentType); output.write(part); } catch (IOException e) { throw new HttpRequestException(e); } return this; }
/** * Write part of a multipart request to the request body * * @param name * @param filename * @param contentType * value of the Content-Type part header * @param part * @return this request * @throws HttpRequestException */ public HttpRequest part(final String name, final String filename, final String contentType, final String part) throws HttpRequestException { try { startPart(); writePartHeader(name, filename, contentType); output.write(part); } catch (IOException e) { throw new HttpRequestException(e); } return this; }
/** * Write char sequence to request body * <p> * The charset configured via {@link #contentType(String)} will be used and * UTF-8 will be used if it is unset. * * @param value * @return this request * @throws HttpRequestException */ public HttpRequest send(final CharSequence value) throws HttpRequestException { try { openOutput(); output.write(value.toString()); } catch (IOException e) { throw new HttpRequestException(e); } return this; }
/** * Close output stream * * @return this request * @throws HttpRequestException * @throws IOException */ protected HttpRequest closeOutput() throws IOException { progress(null); if (output == null) return this; if (multipart) output.write(CRLF + "--" + BOUNDARY + "--" + CRLF); if (ignoreCloseExceptions) try { output.close(); } catch (IOException ignored) { // Ignored } else output.close(); output = null; return this; }
/** * Write part of a multipart request to the request body * * @param name * @param filename * @param contentType value of the Content-Type part header * @param part * @return this request * @throws HttpRequestException */ public HttpRequest part(final String name, final String filename, final String contentType, final String part) throws HttpRequestException { try { startPart(); writePartHeader(name, filename, contentType); output.write(part); } catch (IOException e) { throw new HttpRequestException(e); } return this; }
/** * Write part of a multipart request to the request body * * @param name * @param filename * @param contentType * value of the Content-Type part header * @param part * @return this request * @throws HttpRequestException */ public HttpRequest part(final String name, final String filename, final String contentType, final String part) throws HttpRequestException { try { startPart(); writePartHeader(name, filename, contentType); output.write(part); } catch (IOException e) { throw new HttpRequestException(e); } return this; }
/** * Close output stream * * @return this request * @throws HttpRequestException * @throws IOException */ protected HttpRequest closeOutput() throws IOException { progress(null); if (output == null) return this; if (multipart) output.write(CRLF + "--" + BOUNDARY + "--" + CRLF); if (ignoreCloseExceptions) try { output.close(); } catch (IOException ignored) { // Ignored } else output.close(); output = null; return this; }
/** * Write char sequence to request body * <p/> * The charset configured via {@link #contentType(String)} will be used and * UTF-8 will be used if it is unset. * * @param value * @return this request * @throws HttpRequestException */ public HttpRequest send(final CharSequence value) throws HttpRequestException { try { openOutput(); output.write(value.toString()); } catch (IOException e) { throw new HttpRequestException(e); } return this; }
/** * Write char sequence to request body * <p> * The charset configured via {@link #contentType(String)} will be used and * UTF-8 will be used if it is unset. * * @param value * @return this request * @throws HttpRequestException */ public HttpRequest send(final CharSequence value) throws HttpRequestException { try { openOutput(); output.write(value.toString()); } catch (IOException e) { throw new HttpRequestException(e); } return this; }
/** * Open output stream * * @return this request * @throws IOException */ protected HttpRequest openOutput() throws IOException { if (output != null) return this; getConnection().setDoOutput(true); final String charset = getParam( getConnection().getRequestProperty(HEADER_CONTENT_TYPE), PARAM_CHARSET); output = new RequestOutputStream(getConnection().getOutputStream(), charset, bufferSize); return this; }
/** * Start part of a multipart * * @return this request * @throws IOException */ protected HttpRequest startPart() throws IOException { if (!multipart) { multipart = true; contentType(CONTENT_TYPE_MULTIPART).openOutput(); output.write("--" + BOUNDARY + CRLF); } else output.write(CRLF + "--" + BOUNDARY + CRLF); return this; }
/** * Write char sequence to request body * <p> * The charset configured via {@link #contentType(String)} will be used and * UTF-8 will be used if it is unset. * * @param value * @return this request * @throws HttpRequestException */ public HttpRequest send(final CharSequence value) throws HttpRequestException { try { openOutput(); output.write(value.toString()); } catch (IOException e) { throw new HttpRequestException(e); } return this; }
/** * Start part of a multipart * * @return this request * @throws IOException */ protected HttpRequest startPart() throws IOException { if (!multipart) { multipart = true; contentType(CONTENT_TYPE_MULTIPART).openOutput(); output.write("--" + BOUNDARY + CRLF); } else output.write(CRLF + "--" + BOUNDARY + CRLF); return this; }