protected org.apache.http.HttpEntity buildPostContent(TestCase tc) throws IOException { HTTPFormBuilder builder = new HTTPFormBuilder(); builder.add("status", tc.status); builder.add("file", tc.file, tc.filename); if(tc.overwrite) builder.add("overwrite", "true"); if(tc.target != null) builder.add("target", tc.target); return builder.build(); } }
public HttpEntity build() throws HTTPException { if(this.usemultipart) return buildmultipart(); else return buildsimple(); }
public HTTPFormBuilder add(String fieldname, final InputStream content, String filename) throws HTTPException { if(isempty(fieldname) || content == null || isempty(filename)) throw new IllegalArgumentException(); Field f = new Field(Sort.STREAM, fieldname, content, filename); parts.put(fieldname, f); this.usemultipart = true; return this; }
protected HTTPFormBuilder buildForm(boolean multipart) throws HTTPException HTTPFormBuilder builder = new HTTPFormBuilder(); builder.add("fullName", NAMEENTRY); builder.add("emailAddress", EMAILENTRY); builder.add("organization", ORGENTRY); builder.add("subject", SUBJECTENTRY); builder.add("description", DESCRIPTIONENTRY); builder.add("softwarePackage", SOFTWAREPACKAGEENTRY); builder.add("packageVersion", VERSIONENTRY); builder.add("os", OSTEXT); builder.add("hardware", HARDWAREENTRY); builder.add("attachmentOne", EXTRATEXT.getBytes(HTTPUtil.ASCII), "extra.html"); builder.add("attachmentTwo", bis, "bundle.xidv"); if(attach3file != null) { builder.add("attachmentThree", attach3file);
try { HTTPFormBuilder builder = buildForm(false); HttpEntity content = builder.build(); try (HTTPMethod postMethod = HTTPFactory.Post(NULLURL)) { postMethod.setRequestContent(content);
try { HTTPFormBuilder builder = buildForm(true); HttpEntity content = builder.build(); try (HTTPMethod postMethod = HTTPFactory.Post(NULLURL)) { postMethod.setRequestContent(content);
public HTTPFormBuilder add(String fieldname, byte[] content, String filename) throws HTTPException { if(isempty(fieldname)) throw new IllegalArgumentException(); if(content == null) content = new byte[0]; if(isempty(filename)) filename = ""; Field f = new Field(Sort.BYTES, fieldname, content, filename); parts.put(fieldname, f); this.usemultipart = true; return this; }
public HTTPFormBuilder add(String fieldname, File content) throws HTTPException { if(isempty(fieldname) || content == null) throw new IllegalArgumentException(); Field f = new Field(Sort.FILE, fieldname, content, content.getName()); parts.put(fieldname, f); this.usemultipart = true; return this; }