protected static String createUrl(List<NameValuePair> pairs) throws URIException{ HttpMethod method = new GetMethod("http://example.org"); method.setQueryString(pairs.toArray(new NameValuePair[]{})); return method.getURI().getEscapedURI(); }
http.setQueryString(params.toString());
private static String createUrl(String url, List<NameValuePair> pairs) throws URIException { HttpMethod method = new GetMethod(url); NameValuePair[] nameValuePairs = pairs.toArray(new NameValuePair[pairs.size()]); method.setQueryString(nameValuePairs); return method.getURI().getEscapedURI(); } }
@Override protected Void doInBackground(Void... params) { ContentValues dataToSend =new ContentValues(); dataToSend.put("name", user.name); dataToSend.put("uersname", user.username); dataToSend.put("password", user.password); dataToSend.put("age", user.age + ""); // URL myUrl = new URL("http://192.168.182.15/connection.php"); // HttpURLConnection conn = (HttpURLConnection) myUrl.openConnection(); try { URL myUrl = new URL("http://192.168.182.15/connection.php"); HttpURLConnection conn = (HttpURLConnection) myUrl.openConnection(); HttpClient client = new HttpClient(); HttpMethod post = new PostMethod("SERVER_ADDRESS"+ "Register.php"); post.setQueryString(new UrlEncodedFormEntity(dataToSend)); client.executeMethod(post); } catch (Exception e) { e.printStackTrace(); } return null; }
method.setQueryString(argsArray); String variableQueryString = method.getQueryString(); method.setQueryString(queryString);
private HttpMethod buildMethod(String url, LocationInfo locationInfo, HttpOperation httpOperation) { HttpMethod method = new GetMethod(url); ArrayList<NameValuePair> list = new ArrayList<>(5); list.add(new NameValuePair("o", httpOperation.getOperation())); locationInfo.getPackageName().ifPresent(p -> list.add(new NameValuePair("p", p))); locationInfo.getClassName().ifPresent(p -> list.add(new NameValuePair("c", p))); locationInfo.getFileName().ifPresent(p -> list.add(new NameValuePair("f", p))); locationInfo.getMessage().ifPresent(m -> list.add(new NameValuePair("m", m))); locationInfo.getLineNumber().map(i -> Integer.toString(i)).ifPresent(l -> list.add(new NameValuePair("l", l))); NameValuePair[] pair = list.toArray(new NameValuePair[0]); method.setQueryString(pair); return method; }
public HttpUrl createHttpsGatewayUrl(String gatewayUrl) throws MalformedURLException, URIException { HttpMethod method = new GetMethod(gatewayUrl); method.setQueryString("ssl=true"); String url = method.getURI().getEscapedURI(); return new HttpUrl(url); } }
method.setQueryString(encodeQuery);
httpMethod.setQueryString(query); return httpMethod;
public ApplicationServerManagerResult undeploy(String appPath) throws IOException { try { undeploy.setQueryString(buildPathQueryArgs(appPath)); client.executeMethod(undeploy); return parseResult(undeploy.getResponseBodyAsString()); } finally { undeploy.releaseConnection(); undeploy.setPath(undeployPath); } }
public ApplicationServerManagerResult start(String appPath) throws IOException { try { start.setQueryString(buildPathQueryArgs(appPath)); client.executeMethod(start); return parseResult(start.getResponseBodyAsString()); } finally { start.releaseConnection(); start.setPath(startPath); } }
public ApplicationServerManagerResult stop(String appPath) throws IOException { try { stop.setQueryString(buildPathQueryArgs(appPath)); client.executeMethod(stop); return parseResult(stop.getResponseBodyAsString()); } finally { stop.releaseConnection(); stop.setPath(stopPath); } }
public HttpMethod generateRequestFor(List<String> recipients, String message) { HttpMethod httpMethod; if (HttpMethodType.POST.equals(outgoing.getRequest().getType())) { httpMethod = new PostMethod(outgoing.getRequest().getUrlPath()); httpMethod.setRequestHeader("Content-Type", PostMethod.FORM_URL_ENCODED_CONTENT_TYPE); addBodyParameters((PostMethod) httpMethod, recipients, message); } else { httpMethod = new GetMethod(outgoing.getRequest().getUrlPath()); } httpMethod.setQueryString(addQueryParameters(recipients, message)); return httpMethod; }
abortRequest.setQueryString( new NameValuePair[] {new NameValuePair("transferId", transfer.getTransferId())});
prepareRequest.setQueryString( new NameValuePair[] {new NameValuePair("transferId", transfer.getTransferId())}); try
commitRequest.setQueryString( new NameValuePair[] {new NameValuePair("transferId", transfer.getTransferId())}); try
commitRequest.setQueryString( new NameValuePair[] {new NameValuePair("transferId", transfer.getTransferId())}); try
abortRequest.setQueryString( new NameValuePair[] {new NameValuePair("transferId", transfer.getTransferId())});
prepareRequest.setQueryString( new NameValuePair[] {new NameValuePair("transferId", transfer.getTransferId())}); try
/** * @param queryMap * @return * @throws Exception */ public String invoke(Map<String, String> queryMap) throws Exception { // set query parameters getMethod().setQueryString(getQueryString(queryMap)); // check if we have a payload to send if (getPayload() != null) { RequestEntity entity = new StringRequestEntity(getPayload(), "text/xml", "UTF-8"); ((PostMethod)getMethod()).setRequestEntity(entity); } String lResponse = null; // Execute request try { int statusCode = getClient().executeMethod(getMethod()); lResponse = getMethod().getResponseBodyAsString(); if (statusCode != HttpStatus.SC_OK) { LOG.error("Method failed: {}", getMethod().getStatusLine()); throw new InvokerException("Method failed: " + getMethod().getStatusLine()); } } finally { LOG.debug("Got the following response: {}", lResponse); // Release current connection to the connection pool once you are done getMethod().releaseConnection(); } return lResponse; }