@Test public void testPostBody() throws Exception { HttpServer server = HttpServer.create( new InetSocketAddress( 9290 ), 0 ); server.createContext( "/test", new MyHandler() ); server.setExecutor( null ); server.start(); Thread.sleep( 10 ); String response = HTTP.post( "http: assertTrue( response.contains( "hi mom" ) ); Thread.sleep( 10 ); server.stop( 0 ); }
public static String post( final String url, final String body ) { return postBodyTextWithContentType( url, "text/plain", body ); }
HTTP { public static String post( final String url, final String body ) { return postBodyTextWithContentType( url, "text/plain", body ); } }
HTTP { public static String post( final String url, final String body ) { return postBodyTextWithContentType( url, "text/plain", body ); }  }
HTTP { public static String post( final String url, final String body ) { return postBodyTextWithContentType( url, "text/plain", body ); }  static String get(
            final String url ); static String post(
            final String url,
            final String body ); static Response getResponse(
            final String url ); static byte[] getBytes(
            final String url, final String contentType ); static byte[] getBytesWithHeaders(
            final String url, final String contentType, final Map<String, ?> headers ); static String getWithHeaders(
            final String url,
            final Map<String, ?> headers ); static String getWithContentType(
            final String url,
            final Map<String, ?> headers,
            final String contentType ); static String getWithCharSet(
            final String url,
            final Map<String, ?> headers,
            final String contentType,
            final String charSet ); static String postText(
            final String url,
            final String body ); static String postBodyTextWithContentType(
            final String url,
            final String contentType,
            final String body ); static String postJSON(
            final String url,
            final String jsonString ); static Response jsonRestCallViaPOST(
            final String url,
            final String jsonString ); static String getJSON(
            final String url,
            final Map<String, ?> headers
    ); static Response jsonRestCallWithHeaders(
            final String url,
            final Map<String, ?> headers
    ); static Response jsonRestCall(
            final String url
    ); static Response postBodyTextWithContentTypeReturnResponse(    final String url,
            final String contentType,
            final String body ); static String getJSONWithParams(
            final String url,
            final Map<String, ?> headers, final Map<String, ?> params
    ); static String postXML(
            final String url,
            final String jsonString ); static String postWithHeaders(
            final String url,
            final Map<String, ?> headers,
            final String body ); static String postWithContentType(
            final String url,
            final Map<String, ?> headers,
            final String contentType,
            final String body ); static String postWithCharset(
            final String url,
            final Map<String, ?> headers,
            final String contentType,
            final String charSet,
            final String body ); static String postForm( final String url, final Map<String, ?> headers,
                                   final Map<String, Object> formData
    ); }
HTTP { public static String post( final String url, final String body ) { return postBodyTextWithContentType( url, "text/plain", body ); }  static String get(
            final String url ); static String post(
            final String url,
            final String body ); static Response getResponse(
            final String url ); static byte[] getBytes(
            final String url, final String contentType ); static byte[] getBytesWithHeaders(
            final String url, final String contentType, final Map<String, ?> headers ); static String getWithHeaders(
            final String url,
            final Map<String, ?> headers ); static String getWithContentType(
            final String url,
            final Map<String, ?> headers,
            final String contentType ); static String getWithCharSet(
            final String url,
            final Map<String, ?> headers,
            final String contentType,
            final String charSet ); static String postText(
            final String url,
            final String body ); static String postBodyTextWithContentType(
            final String url,
            final String contentType,
            final String body ); static String postJSON(
            final String url,
            final String jsonString ); static Response jsonRestCallViaPOST(
            final String url,
            final String jsonString ); static String getJSON(
            final String url,
            final Map<String, ?> headers
    ); static Response jsonRestCallWithHeaders(
            final String url,
            final Map<String, ?> headers
    ); static Response jsonRestCall(
            final String url
    ); static Response postBodyTextWithContentTypeReturnResponse(    final String url,
            final String contentType,
            final String body ); static String getJSONWithParams(
            final String url,
            final Map<String, ?> headers, final Map<String, ?> params
    ); static String postXML(
            final String url,
            final String jsonString ); static String postWithHeaders(
            final String url,
            final Map<String, ?> headers,
            final String body ); static String postWithContentType(
            final String url,
            final Map<String, ?> headers,
            final String contentType,
            final String body ); static String postWithCharset(
            final String url,
            final Map<String, ?> headers,
            final String contentType,
            final String charSet,
            final String body ); static String postForm( final String url, final Map<String, ?> headers,
                                   final Map<String, Object> formData
    ); static final int DEFAULT_TIMEOUT_SECONDS; static final String APPLICATION_JSON; }