/** * HttpPost constructor. * * @param url The POST destination * @param content The content to post. * @param contentType The type of the content. * @param followRedirects Whether or not to follow server redirects. * @deprecated use a FileContent object instead */ @Deprecated public HttpPost(URL url, String content, String contentType, boolean followRedirects) { this(url, new FileContent(content, contentType, Charset.forName("UTF-8")), followRedirects); }
private void writeFilePart(String fieldName, FileContent uploadContent, OutputStream w, Charset utf8) throws IOException { StringBuilder sb = new StringBuilder(); log.warn(uploadContent.getContentType()); sb.append(LINE_FEED).append("--" + MULTIPART_BOUNDARY); // 'filename' for data entry is needed so this data is treated as // stream input by the accepting web service sb.append(LINE_FEED).append("Content-Disposition: form-data; name=\"" + fieldName + "\";" + " filename=\"dummyFile\""); if (uploadContent.getContentType() != null ) { sb.append(LINE_FEED).append("Content-Type: " + uploadContent.getContentType()); } sb.append(LINE_FEED); sb.append(LINE_FEED); log.debug("MULTIPART PORTION: " + sb.toString()); w.write(sb.toString().getBytes(utf8)); w.write(uploadContent.getBytes()); w.flush(); }
transferWriter.write(transfer, stringWriter); FileContent transferContent = new FileContent(stringWriter.toString(), "text/xml", Charset.forName("UTF-8")); HttpPost httpPost = new HttpPost(vospaceURL, transferContent, false);
setRequestSSOCookie(conn); conn.setRequestMethod("POST"); byte[] buf = input.getBytes(); String len = Long.toString(buf.length); conn.setRequestProperty("Content-Length", len); log.debug("POST Content-Length: " + len); conn.setRequestProperty("Content-Type", input.getContentType()); log.debug("POST Content-Type: " + input.getContentType()); ostream.write(input.getBytes()); } finally { ostream.flush();
FileContent nodeContent = new FileContent(stringWriter.toString(), "text/xml", Charset.forName("UTF-8")); HttpPost httpPost = new HttpPost(vospaceURL, nodeContent, false);
nodeWriter.write(node, nodeXML); FileContent nodeContent = new FileContent(nodeXML.toString(), "text/xml", Charset.forName("UTF-8")); HttpPost httpPost = new HttpPost(url, nodeContent, false);
writer.write(transfer, sw); FileContent transferContent = new FileContent(sw.toString(), "text/xml", Charset.forName("UTF-8")); httpPost = new HttpPost(vospaceURL, transferContent, false);