public RestfulRequest createRequest(final RestfulHttpMethod httpMethod, final String uriTemplate) { final boolean includesScheme = uriTemplate.startsWith("http:") || uriTemplate.startsWith("https:"); final String base = clientRequestFactory.getBase().toString(); final String uri = (includesScheme ? "" : base) + uriTemplate; final ClientRequestConfigurer clientRequestConfigurer = ClientRequestConfigurer.create(executor, uri); clientRequestConfigurer.accept(MediaType.APPLICATION_JSON_TYPE); clientRequestConfigurer.setHttpMethod(httpMethod); return new RestfulRequest(clientRequestConfigurer); }
/** * It's a bit nasty that we need to ask for the {@link UriBuilderImpl} as * well as the {@link ClientRequest}, but that's because the * {@link ClientRequest} does not allow us to setup raw query strings (only * query name/arg pairs) * * @param restEasyRequest * @param uriBuilder * - that sits underneath the restEasyRequest * @param requestArgs */ public void setUpArgs(final ClientRequestConfigurer clientRequestConfigurer, final JsonRepresentation requestArgs) { clientRequestConfigurer.setHttpMethod(this); if (requestArgs == null) { return; } if (!requestArgs.isMap()) { throw new IllegalArgumentException("requestArgs must be a map; instead got: " + requestArgs); } argStrategy.setUpArgs(clientRequestConfigurer, requestArgs); }
public <T extends JsonRepresentation> RestfulResponse<T> follow(final ClientExecutor executor, final JsonRepresentation requestArgs) throws Exception { final ClientRequestConfigurer clientRequestConfigurer = ClientRequestConfigurer.create(executor, getHref()); clientRequestConfigurer.accept(MediaType.APPLICATION_JSON_TYPE); clientRequestConfigurer.setHttpMethod(getHttpMethod()); clientRequestConfigurer.configureArgs(requestArgs); final RestfulRequest restfulRequest = new RestfulRequest(clientRequestConfigurer); return restfulRequest.executeT(); }
private void setsUpQueryString(final RestfulHttpMethod httpMethod) throws UnsupportedEncodingException { context.checking(new Expectations() { { one(requestConfigurer).setHttpMethod(httpMethod); one(requestConfigurer).queryString(repr); } }); httpMethod.setUpArgs(requestConfigurer, repr); }
private void setsUpQueryString(final RestfulHttpMethod httpMethod) throws UnsupportedEncodingException { context.checking(new Expectations() { { one(requestConfigurer).setHttpMethod(httpMethod); one(requestConfigurer).queryString(repr); } }); httpMethod.setUpArgs(requestConfigurer, repr); }
private void setsUpBody(final RestfulHttpMethod httpMethod) throws UnsupportedEncodingException { context.checking(new Expectations() { { one(requestConfigurer).setHttpMethod(httpMethod); one(requestConfigurer).body(repr); } }); httpMethod.setUpArgs(requestConfigurer, repr); }
private void setsUpBody(final RestfulHttpMethod httpMethod) throws UnsupportedEncodingException { context.checking(new Expectations() { { one(requestConfigurer).setHttpMethod(httpMethod); one(requestConfigurer).body(repr); } }); httpMethod.setUpArgs(requestConfigurer, repr); }