@Test public void testPost_ShouldIncludePostBody() throws Exception { http.post("www.example.com", new HashMap<String, String>(), "a post body", null, null); HttpPost sentHttpRequest = (HttpPost) Robolectric.getSentHttpRequest(0); StringEntity entity = (StringEntity) sentHttpRequest.getEntity(); String sentPostBody = fromStream(entity.getContent()); assertThat(sentPostBody, equalTo("a post body")); assertThat(entity.getContentType().getValue(), equalTo("text/plain; charset=UTF-8")); }
public Response post(String url, Map<String, String> headers, String postBody, String username, String password) throws IOException, URISyntaxException { URI uri = new URI(url); HttpPost method = new HttpPost(uri); method.setEntity(new StringEntity(postBody, "UTF-8")); return makeRequest(headers, username, password, method, uri.getHost()); }
Http { public Response post(String url, Map<String, String> headers, String postBody, String username, String password) throws IOException, URISyntaxException { URI uri = new URI(url); HttpPost method = new HttpPost(uri); method.setEntity(new StringEntity(postBody, "UTF-8")); return makeRequest(headers, username, password, method, uri.getHost()); } }
Http { public Response post(String url, Map<String, String> headers, String postBody, String username, String password) throws IOException, URISyntaxException { URI uri = new URI(url); HttpPost method = new HttpPost(uri); method.setEntity(new StringEntity(postBody, "UTF-8")); return makeRequest(headers, username, password, method, uri.getHost()); }  }
Http { public Response post(String url, Map<String, String> headers, String postBody, String username, String password) throws IOException, URISyntaxException { URI uri = new URI(url); HttpPost method = new HttpPost(uri); method.setEntity(new StringEntity(postBody, "UTF-8")); return makeRequest(headers, username, password, method, uri.getHost()); }  Response get(String url, Map<String, String> headers, String username, String password); Response post(String url, Map<String, String> headers, String postBody, String username, String password); }
Http { public Response post(String url, Map<String, String> headers, String postBody, String username, String password) throws IOException, URISyntaxException { URI uri = new URI(url); HttpPost method = new HttpPost(uri); method.setEntity(new StringEntity(postBody, "UTF-8")); return makeRequest(headers, username, password, method, uri.getHost()); }  Response get(String url, Map<String, String> headers, String username, String password); Response post(String url, Map<String, String> headers, String postBody, String username, String password);  }