List of usage examples for org.apache.http.client.methods HttpPost METHOD_NAME
String METHOD_NAME
To view the source code for org.apache.http.client.methods HttpPost METHOD_NAME.
Click Source Link
From source file:org.elasticsearch.client.RequestConvertersTests.java
public void testRollover() throws IOException { RolloverRequest rolloverRequest = new RolloverRequest(randomAlphaOfLengthBetween(3, 10), randomBoolean() ? null : randomAlphaOfLengthBetween(3, 10)); Map<String, String> expectedParams = new HashMap<>(); setRandomTimeout(rolloverRequest::timeout, rolloverRequest.timeout(), expectedParams); setRandomMasterTimeout(rolloverRequest, expectedParams); if (randomBoolean()) { rolloverRequest.dryRun(randomBoolean()); if (rolloverRequest.isDryRun()) { expectedParams.put("dry_run", "true"); }//from w w w.j a v a 2 s . com } if (randomBoolean()) { rolloverRequest.addMaxIndexAgeCondition(new TimeValue(randomNonNegativeLong())); } if (randomBoolean()) { String type = randomAlphaOfLengthBetween(3, 10); rolloverRequest.getCreateIndexRequest().mapping(type, RandomCreateIndexGenerator.randomMapping(type)); } if (randomBoolean()) { RandomCreateIndexGenerator.randomAliases(rolloverRequest.getCreateIndexRequest()); } if (randomBoolean()) { rolloverRequest.getCreateIndexRequest().settings(RandomCreateIndexGenerator.randomIndexSettings()); } setRandomWaitForActiveShards(rolloverRequest.getCreateIndexRequest()::waitForActiveShards, expectedParams); Request request = RequestConverters.rollover(rolloverRequest); if (rolloverRequest.getNewIndexName() == null) { assertEquals("/" + rolloverRequest.getAlias() + "/_rollover", request.getEndpoint()); } else { assertEquals("/" + rolloverRequest.getAlias() + "/_rollover/" + rolloverRequest.getNewIndexName(), request.getEndpoint()); } assertEquals(HttpPost.METHOD_NAME, request.getMethod()); assertToXContentBody(rolloverRequest, request.getEntity()); assertEquals(expectedParams, request.getParameters()); }
From source file:org.elasticsearch.client.RequestConvertersTests.java
public void testVerifyRepository() { Map<String, String> expectedParams = new HashMap<>(); String repository = randomIndicesNames(1, 1)[0]; String endpoint = "/_snapshot/" + repository + "/_verify"; VerifyRepositoryRequest verifyRepositoryRequest = new VerifyRepositoryRequest(repository); setRandomMasterTimeout(verifyRepositoryRequest, expectedParams); setRandomTimeout(verifyRepositoryRequest::timeout, AcknowledgedRequest.DEFAULT_ACK_TIMEOUT, expectedParams); Request request = RequestConverters.verifyRepository(verifyRepositoryRequest); assertThat(endpoint, equalTo(request.getEndpoint())); assertThat(HttpPost.METHOD_NAME, equalTo(request.getMethod())); assertThat(expectedParams, equalTo(request.getParameters())); }
From source file:net.toxbank.client.resource.InvestigationClient.java
/** * Posts the investigation as a new version * @param zipFile the investigation zip file * @param rootUrl the root url of the service * @param accessRights the access rights to assign * @param ftpFilename name of the file on the ftp server - optional used with ftpData type * @return the remote task created/*from ww w . j a va 2 s. c o m*/ */ public RemoteTask postInvestigation(File zipFile, URL rootUrl, List<PolicyRule> accessRights, Investigation investigation, String ftpFilename) throws Exception { MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE, null, utf8); if (investigation.getDataType() == Investigation.DataType.isaTabData || investigation.getDataType() == Investigation.DataType.unformattedData) { entity.addPart(file_param, new FileBody(zipFile, zipFile.getName(), "application/zip", null)); } if (investigation.getDataType() != Investigation.DataType.isaTabData) { addMetaData(entity, investigation); } if (investigation.getDataType() == Investigation.DataType.ftpData) { entity.addPart(ftp_file_param, new StringBody(ftpFilename)); } entity.addPart(searchable_param, new StringBody(String.valueOf(investigation.isSearchable()))); AbstractClient.addPolicyRules(entity, accessRights); RemoteTask task = new RemoteTask(getHttpClient(), rootUrl, "text/uri-list", entity, HttpPost.METHOD_NAME); return task; }
From source file:org.apache.nutch.protocol.httpclient.HttpClientRedirectStrategy.java
public HttpUriRequest getRedirect(final HttpRequest request, final HttpResponse response, final HttpContext context) throws ProtocolException { URI uri = getLocationURI(request, response, context); String method = request.getRequestLine().getMethod(); if (method.equalsIgnoreCase(HttpHead.METHOD_NAME)) { return new HttpHead(uri); } else if (method.equalsIgnoreCase(HttpGet.METHOD_NAME)) { return new HttpGet(uri); } else {/*ww w. j a v a 2 s . c o m*/ int status = response.getStatusLine().getStatusCode(); if (status == HttpStatus.SC_TEMPORARY_REDIRECT) { if (method.equalsIgnoreCase(HttpPost.METHOD_NAME)) { return copyEntity(new HttpPost(uri), request); } else if (method.equalsIgnoreCase(HttpPut.METHOD_NAME)) { return copyEntity(new HttpPut(uri), request); } else if (method.equalsIgnoreCase(HttpDelete.METHOD_NAME)) { return new HttpDelete(uri); } else if (method.equalsIgnoreCase(HttpTrace.METHOD_NAME)) { return new HttpTrace(uri); } else if (method.equalsIgnoreCase(HttpOptions.METHOD_NAME)) { return new HttpOptions(uri); } else if (method.equalsIgnoreCase(HttpPatch.METHOD_NAME)) { return copyEntity(new HttpPatch(uri), request); } } return new HttpGet(uri); } }
From source file:org.fcrepo.integration.http.api.FedoraLdpIT.java
License:asdf
private static void assertContainerOptionsHeaders(final HttpResponse httpResponse) { assertRdfOptionsHeaders(httpResponse); final List<String> methods = headerValues(httpResponse, "Allow"); assertTrue("Should allow POST", methods.contains(HttpPost.METHOD_NAME)); final List<String> postTypes = headerValues(httpResponse, "Accept-Post"); assertTrue("POST should support text/turtle", postTypes.contains(contentTypeTurtle)); assertTrue("POST should support text/rdf+n3", postTypes.contains(contentTypeN3)); assertTrue("POST should support text/n3", postTypes.contains(contentTypeN3Alt2)); assertTrue("POST should support application/rdf+xml", postTypes.contains(contentTypeRDFXML)); assertTrue("POST should support application/n-triples", postTypes.contains(contentTypeNTriples)); }