@Override public HTTPResponse post( final URL url, final InputStream postContent, final String postContentType) throws IOException { PostMethod postMethod = new PostMethod(url.toExternalForm()); postMethod.setDoAuthentication(user != null && password != null); if (tryGzip) { postMethod.setRequestHeader("Accept-Encoding", "gzip"); } if (postContentType != null) { postMethod.setRequestHeader("Content-type", postContentType); } RequestEntity requestEntity = new InputStreamRequestEntity(postContent); postMethod.setRequestEntity(requestEntity); int responseCode = executeMethod(postMethod); if (200 != responseCode) { postMethod.releaseConnection(); throw new IOException( "Server returned HTTP error code " + responseCode + " for URL " + url.toExternalForm()); } return new HttpMethodResponse(postMethod); }
@Override public HTTPResponse post( final URL url, final InputStream postContent, final String postContentType) throws IOException { PostMethod postMethod = new PostMethod(url.toExternalForm()); postMethod.setDoAuthentication(user != null && password != null); if (postContentType != null) { postMethod.setRequestHeader("Content-type", postContentType); } RequestEntity requestEntity = new InputStreamRequestEntity(postContent); postMethod.setRequestEntity(requestEntity); int responseCode = client.executeMethod(postMethod); if (200 != responseCode) { postMethod.releaseConnection(); throw new IOException( "Server returned HTTP error code " + responseCode + " for URL " + url.toExternalForm()); } return new HttpMethodResponse(postMethod); }
method.setRequestHeader("Content-type", "text/xml; charset=ISO-8859-1");
private void init() { initList(m_ipList, ipFilePath); initList(m_uaList, uaFilePath); initList(m_itemList, itmFilePath); initList(m_tsList,tsFilePath); initList(m_siteList,siteFilePath); initList(m_dsList,dsFilePath); initGUIDList(); String finalURL = ""; if (batchMode) { finalURL = BATCH_URL; } else { finalURL = URL; } m_payload = readFromResource(); HttpClientParams clientParams = new HttpClientParams(); clientParams.setSoTimeout(60000); m_client = new HttpClient(clientParams); m_method = new PostMethod(NODE + finalURL + EVENTTYPE); m_method.setRequestHeader("Connection", "Keep-Alive"); m_method.setRequestHeader("Accept-Charset", "UTF-8"); }
@Override public void prepareRequest() throws Exception { PostMethod method = new PostMethod(URL); method.setRequestHeader(HEADER_NAME, HEADER_VALUE); RequestEntity body = new StringRequestEntity(PAYLOAD,CONTENT_TYPE,null); method.setRequestEntity(body); request = new Http3RequestAdapter(method); } }
public String call(String xml) { PostMethod post = new PostMethod(url); post.setRequestEntity(new StringRequestEntity(xml)); post.setRequestHeader("Content-type", "text/xml");
postMethod.setRequestHeader(CONTENT_TYPE, JSON_CONTENT_TYPE); postMethod.setRequestEntity(entity); postMethod.setRequestHeader("Authorization", "Basic " + encodedCredentials);
[...] PostMethod post = new PostMethod(url); post.setRequestEntity(new ByteArrayEntity(bytes)); post.setRequestHeader("Content-type", "application/octet-stream"); [...]
protected String post(String path) { final PostMethod req = new PostMethod(path); req.setRequestHeader("X-Atlassian-Token", "no-check"); return send(req); }
PostMethod method = new PostMethod(); org.apache.commons.httpclient.URI newUri = new org.apache.commons.httpclient.URI(URIstring, true); method.setURI(newUri); method.setRequestBody(JsonObj().toString()); method.setRequestHeader("Content-Type", "application/json"); org.apache.commons.httpclient.HttpClient newhttpClient = new org.apache.commons.httpclient.HttpClient(); int statusCode = newhttpClient.executeMethod(method); return method.getResponseBodyAsString();
public void sendFile throws IOException { HttpClient client = new HttpClient(); PostMethod postMethod = new PostMethod("http://yourserverip:8080/yourServlet"); File f = new File(destFileName); postMethod.setRequestBody(new FileInputStream(f)); postMethod.setRequestHeader("Content-type", "text/xml; charset=ISO-8859-1"); client.executeMethod(postMethod); postMethod.releaseConnection(); }
protected PostMethod buildPostMethod(String url, HttpParameters parameters) { final PostMethod postMethod; postMethod = new PostMethod(url); postMethod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; ; charset=UTF-8"); for (String name : parameters.names()) { postMethod.setParameter(name, parameters.get(name)); } return postMethod; }
protected PostMethod buildPostMethod(String url, HttpParameters parameters) { final PostMethod postMethod; postMethod = new PostMethod(url); postMethod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; ; charset=UTF-8"); for (String name : parameters.names()) { postMethod.setParameter(name, parameters.get(name)); } return postMethod; }
protected PostMethod buildPostMethod(String url, HttpParameters parameters) { final PostMethod postMethod; postMethod = new PostMethod(url); postMethod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; ; charset=UTF-8"); for (String name : parameters.names()) { postMethod.setParameter(name, parameters.get(name)); } return postMethod; }
private PostMethod setupPostMethod() { final PostMethod m = new PostMethod(HIPCHAT_API_URL + apiToken); m.setRequestHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED + "; charset=UTF-8"); m.addParameter("room_id", room); m.addParameter("from", from); m.addParameter("notify", (notify ? "1" : "0")); return m; }
final String request = createXmlRequest(); // helper method to create the xml request final HttpClient client = new HttpClient(); final PostMethod post = new PostMehod(url); // url - www.google.cm/someoperaion post.setRequestHeader("Content-Language", "en-US"); post.setRequestEntity(new StringRequestEntity(request, "text/xml", "ISO-8859-1")); final int returnCode = client.executeMethod(post); final BufferedReader respReader = new BufferedReader(new InputStreamReader(post.getResponseBodyAsStream()));
PostMethod post = new PostMethod("http://jakarata.apache.org/"); NameValuePair[] data = { new NameValuePair("user", "joe"), new NameValuePair("password", "bloggs") }; post.setRequestBody(data); post.setRequestHeader("Content-type", "application/xhtml+xml"); // execute method and handle any error responses. ... InputStream in = post.getResponseBodyAsStream(); // handle response.
String post(String content, String url, String contentType) throws IOException { PostMethod postMethod = httpMethodProvider.postMethod(); postMethod.setRequestHeader(CONTENT_TYPE, contentType); postMethod.setRequestEntity(new StringRequestEntity(content, contentType, UTF_8)); return execute(url, postMethod, HttpStatus.SC_CREATED); }
private PostMethod getRequestMethod(boolean refresh, String id) throws UnsupportedEncodingException { GOCTransport gocTransport = new GOCTransport(); EndpointInfo endpointInfo = gocTransport.getEndpointInfo(_config, _logger, refresh); // Create upsert URI with PATCH method PostMethod post = new PostMethod(String.format("%s/services/data/v25.0/sobjects/SM_Alert__c/%s/%s", endpointInfo.getEndPoint(), urlEncode(GOCData.SM_ALERT_ID__C_FIELD), urlEncode(id))) { @Override public String getName() { return "PATCH"; } }; post.setRequestHeader("Authorization", "Bearer " + endpointInfo.getToken()); return post; }
PostMethod post = new PostMethod("http://localhost:8118/log.srv"); post.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded"); NameValuePair[] data = { new NameValuePair("action", "likearticle"), new NameValuePair("noname", "989858"), new NameValuePair("ladoi", "cutymaraton") }; post.setRequestBody(data); HttpClient httpclient = new HttpClient(); int result = httpclient.executeMethod(post); InputStream in = post.getResponseBodyAsStream(); // handle response.