/** * Gets the request property. * * @return the request property * @throws EWSHttpException the EWS http exception */ public Map<String, String> getRequestProperty() throws EWSHttpException { throwIfRequestIsNull(); Map<String, String> map = new HashMap<String, String>(); Header[] hM = httpPost.getAllHeaders(); for (Header header : hM) { map.put(header.getName(), header.getValue()); } return map; } }
HttpPost post = new HttpPost("www.google.com"); post.setHeader(new BasicHeader("User-Agent", "random client")); HttpEntity entity = new StringEntity("yellaworld"); post.setEntity(entity); Header[] headers = post.getAllHeaders(); String content = EntityUtils.toString(entity); System.out.println(post.toString()); for (Header header : headers) { System.out.println(header.getName() + ": " + header.getValue()); } System.out.println(); System.out.println(content);
HttpClient client = new DefaultHttpClient(cm,httpParameters); // Create local context HttpContext context= new BasicHttpContext(); while (i<200) { HttpPost post = new HttpPost(send.getUrl().toString()); Header[] heads = post.getAllHeaders(); System.out.println("Request Headers size:"+heads.length); for (int ii=0; ii<heads.length; ii++) { Header head = heads[ii]; System.out.println("Name:"+head.getName()+", value:"+head.getValue()); } ContentType contentType = ContentType.create("text/xml","UTF-8"); HttpEntity entity = new StringEntity(data,contentType ); post.setEntity(entity); // Pass context for execution HttpResponse resp = client.execute(post, context); ... }
/** * Send a post request to splunk server, including event to be logged, in JSON String. * * @param schema to be used. Possible values are http, https * @param uri server uri(hostname or ip-address) * @param portNumber which is listened by Splunk server http event collector * @param request to be sent * @return response from the server * @throws ClientProtocolException * @throws IOException */ public HttpResponse sendRequest(String schema, String uri, int portNumber, HttpPost request) throws IOException { HttpHost target = new HttpHost(uri, portNumber, schema); LOGGER.debug("Sending POST request to " + schema + "://" + uri + ":" + portNumber); LOGGER.debug("Available headers:"); for (Header header : request.getAllHeaders()) { LOGGER.debug(header.getName() + ": " + header.getValue()); } return client.execute(target, request); }
/** * Send a post request to splunk server, including event to be logged, in JSON String. * * @param request to be sent * @return response from the server * @throws ClientProtocolException * @throws IOException */ public HttpResponse sendRequest(HttpPost request) throws IOException { LOGGER.debug("Sending POST request to " + request.getURI()); LOGGER.debug("Available headers:"); for (Header header : request.getAllHeaders()) { LOGGER.debug(header.getName() + ": " + header.getValue()); } return client.execute(request); }
public static void dumpRequestInfo(HttpPost postReq, Logger log) { log.info("Request method: " + postReq.getMethod()); log.info("Request line: " + postReq.getRequestLine()); Header[] allHeaders = postReq.getAllHeaders(); log.info("POST header count: " + allHeaders.length); for (Header h : allHeaders) { log.info("Header: " + h); } }
private static void dumpRequestInfo(HttpPost postReq, Logger log) { log.info("Request method: " + postReq.getMethod()); log.info("Request line: " + postReq.getRequestLine()); Header[] allHeaders = postReq.getAllHeaders(); log.info("POST header count: " + allHeaders.length); for (Header h : allHeaders) { log.info("Header: " + h); } }
/** * Send a post request to splunk server, including event to be logged, in JSON String. * * @param schema to be used. Possible values are http, https * @param uri server uri(hostname or ip-address) * @param portNumber which is listened by Splunk server http event collector * @param request to be sent * @return response from the server * @throws ClientProtocolException * @throws IOException */ public HttpResponse sendRequest(String schema, String uri, int portNumber, HttpPost request) throws IOException { HttpHost target = new HttpHost(uri, portNumber, schema); LOGGER.debug("Sending POST request to " + schema + "://" + uri + ":" + portNumber); LOGGER.debug("Available headers:"); for (Header header : request.getAllHeaders()) { LOGGER.debug(header.getName() + ": " + header.getValue()); } return client.execute(target, request); }
/** * Gets the request property. * * @return the request property * @throws EWSHttpException the EWS http exception */ public Map<String, String> getRequestProperty() throws EWSHttpException { throwIfRequestIsNull(); Map<String, String> map = new HashMap<String, String>(); Header[] hM = httpPost.getAllHeaders(); for (Header header : hM) { map.put(header.getName(), header.getValue()); } return map; } }
/** * Send a post request to splunk server, including event to be logged, in JSON String. * * @param request to be sent * @return response from the server * @throws ClientProtocolException * @throws IOException */ public HttpResponse sendRequest(HttpPost request) throws IOException { LOGGER.debug("Sending POST request to " + request.getURI()); LOGGER.debug("Available headers:"); for (Header header : request.getAllHeaders()) { LOGGER.debug(header.getName() + ": " + header.getValue()); } return client.execute(request); }
public static void dumpRequestInfo(HttpPost postReq, Logger log) { log.info("Request method: " + postReq.getMethod()); log.info("Request line: " + postReq.getRequestLine()); Header[] allHeaders = postReq.getAllHeaders(); log.info("POST header count: " + allHeaders.length); for (Header h : allHeaders) { log.info("Header: " + h); } }
public static void dumpRequestInfo(HttpPost postReq, Logger log) { log.info("Request method: " + postReq.getMethod()); log.info("Request line: " + postReq.getRequestLine()); Header[] allHeaders = postReq.getAllHeaders(); log.info("POST header count: " + allHeaders.length); for (Header h : allHeaders) { log.info("Header: " + h); } }
private HttpResponse executeBatchCall(String serviceUrl, final String body) throws ClientProtocolException, IOException { final HttpPost post = new HttpPost(URI.create(serviceUrl + "/$batch")); post.setHeader("Content-Type", "multipart/mixed;boundary=" + boundary); post.setHeader(AUTHORIZATION_HEADER, getAuthorizationHeader()); post.setHeader(CSRF_TOKEN_HEADER, getCsrfToken()); HttpEntity entity = new StringEntity(body); post.setEntity(entity); for (Header h : post.getAllHeaders()) { logger.info(h.getName() + " : " + h.getValue()); } HttpResponse response = getHttpClient().execute(post); logger.info("Response statusCode => " + response.getStatusLine().getStatusCode()); return response; }
private HttpResponse executeBatchCall(String serviceUrl, final String body) throws ClientProtocolException, IOException { final HttpPost post = new HttpPost(URI.create(serviceUrl + "/$batch")); post.setHeader("Content-Type", "multipart/mixed;boundary=" + boundary); post.setHeader(AUTHORIZATION_HEADER, getAuthorizationHeader()); post.setHeader(CSRF_TOKEN_HEADER, getCsrfToken()); HttpEntity entity = new StringEntity(body); post.setEntity(entity); String logText = "REQUEST HEADERS:\n"; for (Header h : post.getAllHeaders()) { logText = logText + h.getName() + " : " + h.getValue() + "\n"; } logger.info(logText); HttpResponse response = getHttpClient().execute(post); logger.info("$Batch Response statusCode => " + response.getStatusLine().getStatusCode()); return response; }
public void postActionReqToCogbotNow(String cmd, String args, boolean dump) throws Throwable { String doURL = myConf.findOpURL(CogSimConf.Op.DO_ACTION); theLogger.info("Posting to URL: " + doURL); HttpPost postReq = new HttpPost(doURL); List<NameValuePair> nvps = new ArrayList<NameValuePair>(); nvps.add(new BasicNameValuePair("cmd", cmd)); nvps.add(new BasicNameValuePair("args", args)); UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nvps, HTTP.UTF_8); postReq.setEntity(formEntity); Header[] allHeaders = postReq.getAllHeaders(); theLogger.info("POST header count: " + allHeaders.length); for (Header h : allHeaders) { theLogger.info("Header: " + h); } theLogger.info("Request method: " + postReq.getMethod()); theLogger.info("Request line: " + postReq.getRequestLine()); HttpResponse response = myClient.execute(postReq); String rqSummary = "Posted [cmd=" + cmd + ", args=" + args + "]"; String resultText = responseEntityText(response, dump, rqSummary); }
public static void postMessageToCogbot(HttpClient client, String cmd, String args) throws Throwable { theLogger.info("Posting to URL: " + actionURL); HttpPost postReq = new HttpPost(actionURL); /* This is for GET params and for params processed by HttpClient HttpParams params = new BasicHttpParams(); params.setParameter("cmd", cmd); params.setParameter("args", args); params.setParameter("submit", "Do it CogBot!"); theLogger.info("Post Params: " + params); postReq.setParams(params); */ List <NameValuePair> nvps = new ArrayList <NameValuePair>(); nvps.add(new BasicNameValuePair("cmd", cmd)); nvps.add(new BasicNameValuePair("args", args)); UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nvps, HTTP.UTF_8); postReq.setEntity(formEntity); Header[] allHeaders = postReq.getAllHeaders(); theLogger.info("POST header count: " + allHeaders.length); for (Header h : allHeaders) { theLogger.info("Header: " + h); } theLogger.info("Request method: " + postReq.getMethod()); theLogger.info("Request line: " + postReq.getRequestLine()); HttpResponse response = client.execute(postReq); String summary = "Posted [cmd=" + cmd + ", args=" + args + "]"; dumpResponseInfo(response, summary); }
HttpPost post = new HttpPost(); post.getAllHeaders(); post.getMethod(); // Post or get request post.getParams(); // Returns params post.getURI(); // Current Uri called
for(Header header : httppost.getAllHeaders()){ if(i == 0){ sb.append("\nHeader:");
for (final Header h : aPost.getAllHeaders ()) ret.append (h.getName ()).append ('=').append (h.getValue ()).append (CHttp.EOL); ret.append (CHttp.EOL);
for (final Header header : post.getAllHeaders()) { LOGGER.info("[ ZERO ] Normalized header: key = {0}, value = {1}.", header.getName(), header.getValue());