Use camelCase for Java method names -- always
This commit is contained in:
parent
5a8a6d0fc8
commit
38a41fea90
|
@ -93,67 +93,67 @@ public class Request {
|
|||
return new Request(new HttpUriRequestBase(methodName, uri));
|
||||
}
|
||||
|
||||
public static Request Get(final URI uri) {
|
||||
public static Request get(final URI uri) {
|
||||
return new Request(ClassicHttpRequests.get(uri));
|
||||
}
|
||||
|
||||
public static Request Get(final String uri) {
|
||||
public static Request get(final String uri) {
|
||||
return new Request(ClassicHttpRequests.get(uri));
|
||||
}
|
||||
|
||||
public static Request Head(final URI uri) {
|
||||
public static Request head(final URI uri) {
|
||||
return new Request(ClassicHttpRequests.head(uri));
|
||||
}
|
||||
|
||||
public static Request Head(final String uri) {
|
||||
public static Request head(final String uri) {
|
||||
return new Request(ClassicHttpRequests.head(uri));
|
||||
}
|
||||
|
||||
public static Request Post(final URI uri) {
|
||||
public static Request post(final URI uri) {
|
||||
return new Request(ClassicHttpRequests.post(uri));
|
||||
}
|
||||
|
||||
public static Request Post(final String uri) {
|
||||
public static Request post(final String uri) {
|
||||
return new Request(ClassicHttpRequests.post(uri));
|
||||
}
|
||||
|
||||
public static Request Patch(final URI uri) {
|
||||
public static Request patch(final URI uri) {
|
||||
return new Request(ClassicHttpRequests.patch(uri));
|
||||
}
|
||||
|
||||
public static Request Patch(final String uri) {
|
||||
public static Request patch(final String uri) {
|
||||
return new Request(ClassicHttpRequests.patch(uri));
|
||||
}
|
||||
|
||||
public static Request Put(final URI uri) {
|
||||
public static Request put(final URI uri) {
|
||||
return new Request(ClassicHttpRequests.put(uri));
|
||||
}
|
||||
|
||||
public static Request Put(final String uri) {
|
||||
public static Request put(final String uri) {
|
||||
return new Request(ClassicHttpRequests.put(uri));
|
||||
}
|
||||
|
||||
public static Request Trace(final URI uri) {
|
||||
public static Request trace(final URI uri) {
|
||||
return new Request(ClassicHttpRequests.trace(uri));
|
||||
}
|
||||
|
||||
public static Request Trace(final String uri) {
|
||||
public static Request trace(final String uri) {
|
||||
return new Request(ClassicHttpRequests.trace(uri));
|
||||
}
|
||||
|
||||
public static Request Delete(final URI uri) {
|
||||
public static Request delete(final URI uri) {
|
||||
return new Request(ClassicHttpRequests.delete(uri));
|
||||
}
|
||||
|
||||
public static Request Delete(final String uri) {
|
||||
public static Request delete(final String uri) {
|
||||
return new Request(ClassicHttpRequests.delete(uri));
|
||||
}
|
||||
|
||||
public static Request Options(final URI uri) {
|
||||
public static Request options(final URI uri) {
|
||||
return new Request(ClassicHttpRequests.options(uri));
|
||||
}
|
||||
|
||||
public static Request Options(final String uri) {
|
||||
public static Request options(final String uri) {
|
||||
return new Request(ClassicHttpRequests.options(uri));
|
||||
}
|
||||
|
||||
|
|
|
@ -50,10 +50,10 @@ public class FluentAsync {
|
|||
final Async async = Async.newInstance().use(threadpool);
|
||||
|
||||
final Request[] requests = new Request[] {
|
||||
Request.Get("http://www.google.com/"),
|
||||
Request.Get("http://www.yahoo.com/"),
|
||||
Request.Get("http://www.apache.com/"),
|
||||
Request.Get("http://www.apple.com/")
|
||||
Request.get("http://www.google.com/"),
|
||||
Request.get("http://www.yahoo.com/"),
|
||||
Request.get("http://www.apache.org/"),
|
||||
Request.get("http://www.apple.com/")
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -51,13 +51,13 @@ public class FluentExecutor {
|
|||
.authPreemptive(new HttpHost("myproxy", 8080));
|
||||
|
||||
// Execute a GET with timeout settings and return response content as String.
|
||||
executor.execute(Request.Get("http://somehost/")
|
||||
executor.execute(Request.get("http://somehost/")
|
||||
.connectTimeout(Timeout.ofSeconds(1)))
|
||||
.returnContent().asString();
|
||||
|
||||
// Execute a POST with the 'expect-continue' handshake, using HTTP/1.1,
|
||||
// containing a request body as String and return response content as byte array.
|
||||
executor.execute(Request.Post("http://somehost/do-stuff")
|
||||
executor.execute(Request.post("http://somehost/do-stuff")
|
||||
.useExpectContinue()
|
||||
.version(HttpVersion.HTTP_1_1)
|
||||
.bodyString("Important stuff", ContentType.DEFAULT_TEXT)
|
||||
|
@ -65,7 +65,7 @@ public class FluentExecutor {
|
|||
|
||||
// Execute a POST with a custom header through the proxy containing a request body
|
||||
// as an HTML form and save the result to the file
|
||||
executor.execute(Request.Post("http://somehost/some-form")
|
||||
executor.execute(Request.post("http://somehost/some-form")
|
||||
.addHeader("X-Custom-header", "stuff")
|
||||
.viaProxy(new HttpHost("myproxy", 8080))
|
||||
.bodyForm(Form.form().add("username", "vip").add("password", "secret").build())
|
||||
|
|
|
@ -36,9 +36,9 @@ public class FluentQuickStart {
|
|||
// deallocation of system resources at the cost of having to buffer
|
||||
// response content in memory in some cases.
|
||||
|
||||
Request.Get("http://targethost/homepage")
|
||||
Request.get("http://targethost/homepage")
|
||||
.execute().returnContent();
|
||||
Request.Post("http://targethost/login")
|
||||
Request.post("http://targethost/login")
|
||||
.bodyForm(Form.form().add("username", "vip").add("password", "secret").build())
|
||||
.execute().returnContent();
|
||||
}
|
||||
|
|
|
@ -42,13 +42,13 @@ public class FluentRequests {
|
|||
|
||||
public static void main(final String... args)throws Exception {
|
||||
// Execute a GET with timeout settings and return response content as String.
|
||||
Request.Get("http://somehost/")
|
||||
Request.get("http://somehost/")
|
||||
.connectTimeout(Timeout.ofSeconds(1))
|
||||
.execute().returnContent().asString();
|
||||
|
||||
// Execute a POST with the 'expect-continue' handshake, using HTTP/1.1,
|
||||
// containing a request body as String and return response content as byte array.
|
||||
Request.Post("http://somehost/do-stuff")
|
||||
Request.post("http://somehost/do-stuff")
|
||||
.useExpectContinue()
|
||||
.version(HttpVersion.HTTP_1_1)
|
||||
.bodyString("Important stuff", ContentType.DEFAULT_TEXT)
|
||||
|
@ -56,7 +56,7 @@ public class FluentRequests {
|
|||
|
||||
// Execute a POST with a custom header through the proxy containing a request body
|
||||
// as an HTML form and save the result to the file
|
||||
Request.Post("http://somehost/some-form")
|
||||
Request.post("http://somehost/some-form")
|
||||
.addHeader("X-Custom-header", "stuff")
|
||||
.viaProxy(new HttpHost("myproxy", 8080))
|
||||
.bodyForm(Form.form().add("username", "vip").add("password", "secret").build())
|
||||
|
|
|
@ -52,7 +52,7 @@ import org.xml.sax.SAXException;
|
|||
public class FluentResponseHandling {
|
||||
|
||||
public static void main(final String... args)throws Exception {
|
||||
final Document result = Request.Get("http://somehost/content")
|
||||
final Document result = Request.get("http://somehost/content")
|
||||
.execute().handleResponse(new HttpClientResponseHandler<Document>() {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -41,14 +41,14 @@ public class TestRequest {
|
|||
|
||||
@Test
|
||||
public void testGetFromString() {
|
||||
final ClassicHttpRequest request = Request.Get(URI_STRING_FIXTURE).getRequest();
|
||||
final ClassicHttpRequest request = Request.get(URI_STRING_FIXTURE).getRequest();
|
||||
Assert.assertEquals(HttpGet.class, request.getClass());
|
||||
Assert.assertEquals("GET", request.getMethod());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetFromURI() {
|
||||
final ClassicHttpRequest request = Request.Get(URI_FIXTURE).getRequest();
|
||||
final ClassicHttpRequest request = Request.get(URI_FIXTURE).getRequest();
|
||||
Assert.assertEquals(HttpGet.class, request.getClass());
|
||||
Assert.assertEquals("GET", request.getMethod());
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ public class TestFluent extends LocalServerTestBase {
|
|||
public void testGetRequest() throws Exception {
|
||||
final HttpHost target = start();
|
||||
final String baseURL = "http://localhost:" + target.getPort();
|
||||
final String message = Request.Get(baseURL + "/").execute().returnContent().asString();
|
||||
final String message = Request.get(baseURL + "/").execute().returnContent().asString();
|
||||
Assert.assertEquals("All is well", message);
|
||||
}
|
||||
|
||||
|
@ -119,18 +119,18 @@ public class TestFluent extends LocalServerTestBase {
|
|||
public void testGetRequestFailure() throws Exception {
|
||||
final HttpHost target = start();
|
||||
final String baseURL = "http://localhost:" + target.getPort();
|
||||
Request.Get(baseURL + "/boom").execute().returnContent().asString();
|
||||
Request.get(baseURL + "/boom").execute().returnContent().asString();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPostRequest() throws Exception {
|
||||
final HttpHost target = start();
|
||||
final String baseURL = "http://localhost:" + target.getPort();
|
||||
final String message1 = Request.Post(baseURL + "/echo")
|
||||
final String message1 = Request.post(baseURL + "/echo")
|
||||
.bodyString("what is up?", ContentType.TEXT_PLAIN)
|
||||
.execute().returnContent().asString();
|
||||
Assert.assertEquals("what is up?", message1);
|
||||
final String message2 = Request.Post(baseURL + "/echo")
|
||||
final String message2 = Request.post(baseURL + "/echo")
|
||||
.bodyByteArray(new byte[]{1, 2, 3}, ContentType.APPLICATION_OCTET_STREAM)
|
||||
.execute().returnContent().asString();
|
||||
Assert.assertEquals("echo", message2);
|
||||
|
@ -140,7 +140,7 @@ public class TestFluent extends LocalServerTestBase {
|
|||
public void testContentAsStringWithCharset() throws Exception {
|
||||
final HttpHost target = start();
|
||||
final String baseURL = "http://localhost:" + target.getPort();
|
||||
final Content content = Request.Post(baseURL + "/echo").bodyByteArray("Ü".getBytes("utf-8")).execute()
|
||||
final Content content = Request.post(baseURL + "/echo").bodyByteArray("Ü".getBytes("utf-8")).execute()
|
||||
.returnContent();
|
||||
Assert.assertEquals((byte)-61, content.asBytes()[0]);
|
||||
Assert.assertEquals((byte)-100, content.asBytes()[1]);
|
||||
|
@ -152,10 +152,10 @@ public class TestFluent extends LocalServerTestBase {
|
|||
final HttpHost target = start();
|
||||
final String baseURL = "http://localhost:" + target.getPort();
|
||||
for (int i = 0; i < 20; i++) {
|
||||
Request.Get(baseURL + "/").execute().returnContent();
|
||||
Request.Get(baseURL + "/").execute().returnResponse();
|
||||
Request.Get(baseURL + "/").execute().discardContent();
|
||||
Request.Get(baseURL + "/").execute().handleResponse(new HttpClientResponseHandler<Object>() {
|
||||
Request.get(baseURL + "/").execute().returnContent();
|
||||
Request.get(baseURL + "/").execute().returnResponse();
|
||||
Request.get(baseURL + "/").execute().discardContent();
|
||||
Request.get(baseURL + "/").execute().handleResponse(new HttpClientResponseHandler<Object>() {
|
||||
|
||||
@Override
|
||||
public Object handleResponse(
|
||||
|
@ -166,7 +166,7 @@ public class TestFluent extends LocalServerTestBase {
|
|||
});
|
||||
final File tmpFile = File.createTempFile("test", ".bin");
|
||||
try {
|
||||
Request.Get(baseURL + "/").execute().saveContent(tmpFile);
|
||||
Request.get(baseURL + "/").execute().saveContent(tmpFile);
|
||||
} finally {
|
||||
tmpFile.delete();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue