/** * adds a string parameter to the request * * @param name parameter name * @param value parameter value * @throws IOException */ public void setParameter(String name, String value) throws IOException { boundary(); writeName(name); newline(); newline(); writeln(value); }
/** * adds a file parameter to the request * * @param name parameter name * @param filename the name of the file * @param is input stream to read the contents of the file from * @throws IOException */ public void setParameter(String name, String filename, InputStream is) throws IOException { boundary(); writeName(name); write("; filename=\""); write(filename); write('"'); newline(); write("Content-Type: "); String type = connection.guessContentTypeFromName(filename); if (type == null) type = "application/octet-stream"; writeln(type); newline(); pipe(is, os); newline(); }
protected void writeln(String s) throws IOException { connect(); write(s); newline(); }
private void writeName(String name) throws IOException { newline(); write("Content-Disposition: form-data; name=\""); write(name); write('"'); }