public HttpRequestBase createApacheRequest ( HttpRequest smartsheetRequest ) { HttpRequestBase apacheHttpRequest ; // Create Apache HTTP request based on the smartsheetRequest request type switch ( smartsheetRequest . getMethod ( ) ) { case GET : apacheHttpRequest = new HttpGet ( smartsheetRequest . getUri ( ) ) ; break ; case POST : apacheHttpRequest = new HttpPost ( smartsheetRequest . getUri ( ) ) ; break ; case PUT : apacheHttpRequest = new HttpPut ( smartsheetRequest . getUri ( ) ) ; break ; case DELETE : apacheHttpRequest = new HttpDelete ( smartsheetRequest . getUri ( ) ) ; break ; default : throw new UnsupportedOperationException ( "Request method " + smartsheetRequest . getMethod ( ) + " is not supported!" ) ; } RequestConfig . Builder builder = RequestConfig . custom ( ) ; if ( apacheHttpRequest . getConfig ( ) != null ) { builder = RequestConfig . copy ( apacheHttpRequest . getConfig ( ) ) ; } builder . setRedirectsEnabled ( true ) ; RequestConfig config = builder . build ( ) ; apacheHttpRequest . setConfig ( config ) ; return apacheHttpRequest ; }
Create the Apache HTTP request . Override this function to inject additional haaders in the request or use a proxy .