use of org.springframework.util.MultiValueMap in project spring-security-oauth by spring-projects.
the class HttpTestUtils method postForString.
public ResponseEntity<String> postForString(String path, MultiValueMap<String, String> formData) {
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
return client.exchange(getUrl(path), HttpMethod.POST, new HttpEntity<MultiValueMap<String, String>>(formData, headers), String.class);
}
use of org.springframework.util.MultiValueMap in project geode by apache.
the class ClientHttpRequestJUnitTest method testCreateRequestEntityForPut.
@Test
@SuppressWarnings("unchecked")
public void testCreateRequestEntityForPut() throws Exception {
final Link expectedLink = new Link("put", toUri("http://host.domain.com:8080/app/libraries/{name}/books/{isbn}"), HttpMethod.PUT);
final ClientHttpRequest request = new ClientHttpRequest(expectedLink);
assertEquals(expectedLink, request.getLink());
final MultiValueMap<String, Object> expectedRequestParameters = new LinkedMultiValueMap<String, Object>(4);
expectedRequestParameters.add("year", "1979");
request.addHeaderValues(HttpHeader.ACCEPT.getName(), MediaType.TEXT_XML_VALUE);
request.addHeaderValues(HttpHeader.CONTENT_TYPE.getName(), MediaType.APPLICATION_FORM_URLENCODED_VALUE);
request.addParameterValues("year", expectedRequestParameters.getFirst("year"));
final HttpEntity<MultiValueMap<String, Object>> requestEntity = (HttpEntity<MultiValueMap<String, Object>>) request.createRequestEntity();
assertNotNull(requestEntity);
assertNotNull(requestEntity.getHeaders());
assertEquals(Collections.singletonList(MediaType.TEXT_XML), requestEntity.getHeaders().getAccept());
assertEquals(MediaType.APPLICATION_FORM_URLENCODED, requestEntity.getHeaders().getContentType());
assertEquals(expectedRequestParameters, requestEntity.getBody());
}
use of org.springframework.util.MultiValueMap in project uPortal by Jasig.
the class DefaultTinCanAPIProvider method sendRequest.
/**
* Send a request to the LRS.
*
* @param pathFragment the URL. Should be relative to the xAPI API root
* @param method the HTTP method
* @param getParams the set of GET params
* @param postData the post data.
* @param returnType the type of object to expect in the response
* @param <T> The type of object to expect in the response
* @return The response object.
*/
protected <T> ResponseEntity<T> sendRequest(String pathFragment, HttpMethod method, List<? extends NameValuePair> getParams, Object postData, Class<T> returnType) {
HttpHeaders headers = new HttpHeaders();
headers.add(XAPI_VERSION_HEADER, XAPI_VERSION_VALUE);
// make multipart data is handled correctly.
if (postData instanceof MultiValueMap) {
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
}
URI fullURI = buildRequestURI(pathFragment, getParams);
HttpEntity<?> entity = new HttpEntity<>(postData, headers);
ResponseEntity<T> response = restTemplate.exchange(fullURI, method, entity, returnType);
return response;
}
use of org.springframework.util.MultiValueMap in project h2o-2 by h2oai.
the class h2oService method ParseCSVFile.
public String ParseCSVFile(String key, String framename) throws org.json.JSONException {
//http://localhost:54321/2/Parse2.query?source_key=nfs://tmp/etsy_images/image_deep_features_csv
String h2oUrlImportEndPoint = H2O_HOST_URL + H2O_PARSE_URL + key;
log.debug("@@@ Calling endpoint {}", h2oUrlImportEndPoint);
MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
/*parser_type:CSV
separator:44
header:1
header_with_hash:0
single_quotes:0
header_from_file:
exclude:
source_key:nfs://tmp/etsy_images/deep_features_csv
destination_key:deep_features_csv.hex
preview:
delete_on_done:1*/
parameters.add("parser_type", "CSV");
parameters.add("separator", "44");
parameters.add("header", "1");
parameters.add("singleQuotes", "0");
parameters.add("source_key", key);
parameters.add("destination_key", framename);
parameters.add("delete_on_done", "true");
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.add("Accept", MediaType.APPLICATION_JSON_VALUE);
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<MultiValueMap<String, String>>(parameters, headers);
ResponseEntity<String> response = restTemplate.exchange(h2oUrlImportEndPoint, HttpMethod.GET, request, String.class);
String responseBody = response.getBody();
/*
{"Request2":0,
"response_info":{"h2o":"paragsanghavi","node":"/172.16.2.46:54321","time":25,"status":"redirect",
"redirect_url":"/2/Progress2.json?job_key=%240301ac10022e32d4ffffffff%24_96ec9394a616c1e5d4ff8a63f17b428e&destination_key=image_deep_features_csv.hex"},
"job_key":"$0301ac10022e32d4ffffffff$_96ec9394a616c1e5d4ff8a63f17b428e",
"destination_key":"image_deep_features_csv.hex"}
*/
log.debug("@@@ Response json from h2o {}", responseBody);
JSONObject jsonobject = new JSONObject(responseBody);
String job_key = (String) jsonobject.get("job_key");
log.debug("!!!!!! Job name {}", job_key);
String destination_key = (String) jsonobject.get("destination_key");
String job_status = JobStatus(job_key, destination_key);
if (job_status != null) {
return destination_key;
}
return null;
}
use of org.springframework.util.MultiValueMap in project pinpoint by naver.
the class HttpRemoteService method createPost.
private HttpPost createPost(String url, MultiValueMap<String, String> params) throws UnsupportedEncodingException {
HttpPost post = new HttpPost(url);
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
for (Map.Entry<String, List<String>> entry : params.entrySet()) {
String key = entry.getKey();
for (String value : entry.getValue()) {
nvps.add(new BasicNameValuePair(key, value));
}
}
post.setEntity(new UrlEncodedFormEntity(nvps));
return post;
}
Aggregations