Java Code Examples for com.google.api.client.http.HttpMethods#POST
The following examples show how to use
com.google.api.client.http.HttpMethods#POST .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GoogleApacheHttpTransport.java From PYX-Reloaded with Apache License 2.0 | 5 votes |
@Override protected GoogleApacheHttpRequest buildRequest(String method, String url) { HttpRequestBase requestBase; switch (method) { case HttpMethods.DELETE: requestBase = new HttpDelete(url); break; case HttpMethods.GET: requestBase = new HttpGet(url); break; case HttpMethods.HEAD: requestBase = new HttpHead(url); break; case HttpMethods.POST: requestBase = new HttpPost(url); break; case HttpMethods.PUT: requestBase = new HttpPut(url); break; case HttpMethods.TRACE: requestBase = new HttpTrace(url); break; case HttpMethods.OPTIONS: requestBase = new HttpOptions(url); break; default: requestBase = new UnknownMethodRequest(method, url); break; } return new GoogleApacheHttpRequest(httpClient, requestBase); }
Example 2
Source File: BatchRequestTest.java From google-api-java-client with Apache License 2.0 | 4 votes |
public void testExecute_checkWriteTo() throws Exception { String request1Method = HttpMethods.POST; String request1Url = "http://test/dummy/url1"; String request1ContentType = "application/json"; String request1Content = "{\"data\":{\"foo\":{\"v1\":{}}}}"; String request2Method = HttpMethods.GET; String request2Url = "http://test/dummy/url2"; // MIME content boundaries are not reproducible. StringBuilder part1 = new StringBuilder(); part1.append("Content-Length: 118\r\n"); part1.append("Content-Type: application/http\r\n"); part1.append("content-id: 1\r\n"); part1.append("content-transfer-encoding: binary\r\n"); part1.append("\r\n"); part1.append("POST http://test/dummy/url1 HTTP/1.1\r\n"); part1.append("Content-Length: 26\r\n"); part1.append("Content-Type: " + request1ContentType + "\r\n"); part1.append("\r\n"); part1.append(request1Content + "\r\n"); part1.append("--__END_OF_PART__"); String expected1 = part1.toString(); StringBuilder part2 = new StringBuilder(); part2.append("Content-Length: 39\r\n"); part2.append("Content-Type: application/http\r\n"); part2.append("content-id: 2\r\n"); part2.append("content-transfer-encoding: binary\r\n"); part2.append("\r\n"); part2.append("GET http://test/dummy/url2 HTTP/1.1\r\n"); part2.append("\r\n"); part2.append("\r\n"); part2.append("--__END_OF_PART__"); String expected2 = part2.toString(); MockHttpTransport transport = new MockHttpTransport(); HttpRequest request1 = transport .createRequestFactory() .buildRequest( request1Method, new GenericUrl(request1Url), new ByteArrayContent(request1ContentType, request1Content.getBytes(UTF_8))); HttpRequest request2 = transport.createRequestFactory() .buildRequest(request2Method, new GenericUrl(request2Url), null); subtestExecute_checkWriteTo(expected1, expected2, request1, request2); }