Java Code Examples for org.apache.http.client.methods.HttpRequestWrapper#getURI()

The following examples show how to use org.apache.http.client.methods.HttpRequestWrapper#getURI() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WechatPay2Credentials.java    From wechatpay-apache-httpclient with Apache License 2.0 6 votes vote down vote up
protected final String buildMessage(String nonce, long timestamp, HttpRequestWrapper request)
    throws IOException {
  URI uri = request.getURI();
  String canonicalUrl = uri.getRawPath();
  if (uri.getQuery() != null) {
    canonicalUrl += "?" + uri.getRawQuery();
  }

  String body = "";
  // PATCH,POST,PUT
  if (request.getOriginal() instanceof WechatPayUploadHttpPost) {
    body = ((WechatPayUploadHttpPost) request.getOriginal()).getMeta();
  } else if (request instanceof HttpEntityEnclosingRequest) {
    body = EntityUtils.toString(((HttpEntityEnclosingRequest) request).getEntity());
  }

  return request.getRequestLine().getMethod() + "\n"
      + canonicalUrl + "\n"
      + timestamp + "\n"
      + nonce + "\n"
      + body + "\n";
}
 
Example 2
Source File: BasicHttpSolrClientTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public void process(HttpRequest request, HttpContext context) throws HttpException,
IOException {
  log.info("Intercepted params: {}", context);

  HttpRequestWrapper wrapper = (HttpRequestWrapper) request;
  URIBuilder uribuilder = new URIBuilder(wrapper.getURI());
  uribuilder.addParameter("b", "\u4321");
  try {
    wrapper.setURI(uribuilder.build());
  } catch (URISyntaxException ex) {
    throw new HttpException("Invalid request URI", ex);
  }
}