Source:
protected HttpUriRequest generateServerRequest(HttpServletRequest clientRequest) throws ProxyException { HttpUriRequest serverRequest = null; try { String serverRequestURIAsString = getServerRequestURIAsString(clientRequest); URI serverRequestURI = (new URL(serverRequestURIAsString)).toURI(); String clientRequestMethod = clientRequest.getMethod(); if ("HEAD".equals(clientRequestMethod)) { serverRequest = new HttpHead(serverRequestURI); } else if ("GET".equals(clientRequestMethod)) { serverRequest = new HttpGet(serverRequestURI); } else if ("POST".equals(clientRequestMethod)) { serverRequest = new HttpPost(serverRequestURI); } else if ("PUT".equals(clientRequestMethod)) { serverRequest = new HttpPut(serverRequestURI); } else if ("DELETE".equals(clientRequestMethod)) { serverRequest = new HttpDelete(serverRequestURI); } else if ("TRACE".equals(clientRequestMethod)) { serverRequest = new HttpTrace(serverRequestURI); } else if ("OPTIONS".equals(clientRequestMethod)) { serverRequest = new HttpOptions(serverRequestURI); } else { throw new ProxyException("Unsupported request method, " + clientRequestMethod); } generateServerRequestHeaders(clientRequest, serverRequest); int contentLength = clientRequest.getContentLength(); if (contentLength > 0) { if (serverRequest instanceof HttpEntityEnclosingRequest) { try { InputStreamEntity serverRequestEntity = new InputStreamEntity( clientRequest.getInputStream(), contentLength); serverRequestEntity.setContentType(clientRequest.getContentType()); ((HttpEntityEnclosingRequest) serverRequest).setEntity(serverRequestEntity); } catch (IOException e) { throw new ProxyException("Error reading client request body", e); } } else { throw new ProxyException("Content in request body unsupported for client request method " + serverRequest.getMethod()); } } } catch (MalformedURLException e) { throw new ProxyException("Syntax error parsing server URL", e); } catch (URISyntaxException e) { throw new ProxyException("Syntax error parsing server URI", e); } return serverRequest; }

Target:
protected HttpUriRequest generateServerRequest(HttpServletRequest clientRequest) throws ProxyException { HttpUriRequest serverRequest = null; try { String serverRequestURIAsString = getServerRequestURIAsString(clientRequest); URI serverRequestURI = (new URL(serverRequestURIAsString)).toURI(); String clientRequestMethod = clientRequest.getMethod(); if ("HEAD".equals(clientRequestMethod)) { serverRequest = new HttpHead(serverRequestURI); } else if ("GET".equals(clientRequestMethod)) { serverRequest = new HttpGet(serverRequestURI); } else if ("POST".equals(clientRequestMethod)) { serverRequest = new HttpPost(serverRequestURI); } else if ("PUT".equals(clientRequestMethod)) { serverRequest = new HttpPut(serverRequestURI); } else if ("DELETE".equals(clientRequestMethod)) { serverRequest = new HttpDelete(serverRequestURI); } else if ("TRACE".equals(clientRequestMethod)) { serverRequest = new HttpTrace(serverRequestURI); } else if ("OPTIONS".equals(clientRequestMethod)) { serverRequest = new HttpOptions(serverRequestURI); } else { throw new ProxyException("Unsupported request method, " + clientRequestMethod); } generateServerRequestHeaders(clientRequest, serverRequest); int contentLength = clientRequest.getContentLength(); if (contentLength > 0) { if (serverRequest instanceof HttpEntityEnclosingRequest) { try { InputStreamEntity serverRequestEntity = new InputStreamEntity( clientRequest.getInputStream(), contentLength); serverRequestEntity.setContentType(clientRequest.getContentType()); ((HttpEntityEnclosingRequest) serverRequest).setEntity(serverRequestEntity); } catch (IOException e) { throw new ProxyException("Error reading client request body", e); } } else { throw new ProxyException("Content in request body unsupported for client request method " + serverRequest.getMethod()); } } } catch (MalformedURLException|URISyntaxException e) { throw new ProxyException("Syntax error parsing server URL", e); } return serverRequest; }