/** * GET 요청을 처리한다. * * @param baseUrl 기본 URL * @param httpInvocation 기본 URL뒤에 붙는 경로 * @return */ public <T> T get(String baseUrl, HttpInvocation<T> httpInvocation) { Assert.notNull(httpInvocation, "httpInvocation 값은 null일 수 없다."); GetMethod getMethod = new GetMethod(baseUrl + httpInvocation.getUri()); if (httpInvocation.getParameters().length > 0) { getMethod.setQueryString(httpInvocation.getParameters()); } return invoke(getMethod, httpInvocation); }
/** * POST 요청을 처리한다. * * @param <T> * @param baseUrl * @param httpInvocation * @return */ public <T> T post(String baseUrl, HttpInvocation<T> httpInvocation) { Assert.notNull(httpInvocation, "httpInvocation 값은 null일 수 없다."); PostMethod postMethod = new PostMethod(baseUrl + httpInvocation.getUri()); postMethod.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded; charset=" + httpInvocation.getEncoding()); String parameterEncoding = httpInvocation.getParameterEncoding(); if (StringUtils.isNotBlank(parameterEncoding)) { postMethod.getParams().setContentCharset(parameterEncoding); } postMethod.addParameters(httpInvocation.getParameters()); return invoke(postMethod, httpInvocation); }