Example usage for org.springframework.http HttpHeaders HttpHeaders

List of usage examples for org.springframework.http HttpHeaders HttpHeaders

Introduction

In this page you can find the example usage for org.springframework.http HttpHeaders HttpHeaders.

Prototype

public HttpHeaders() 

Source Link

Document

Construct a new, empty instance of the HttpHeaders object.

Usage

From source file:com.goldengekko.meetr.service.salesforce.SalesforceService.java

protected static HttpEntity getRequestEntity(String accessToken) {
    HttpHeaders headers = new HttpHeaders();
    final String auth = String.format("OAuth %s", accessToken);
    headers.add("Authorization", auth);
    LOG.info("Salesforce Authorization: {}", auth);
    final HttpEntity requestEntity = new HttpEntity(headers);
    return requestEntity;
}

From source file:org.trustedanalytics.h2oscoringengine.publisher.http.HttpCommunication.java

public static HttpEntity<String> basicAuthRequest(String basicAuthToken) {
    HttpHeaders headers = new HttpHeaders();
    headers.add("Authorization", "Basic " + basicAuthToken);

    return new HttpEntity<>(headers);
}

From source file:com.royclarkson.springagram.RestUtils.java

public static HttpEntity<Void> getRequestEntity() {
    if (requestEntity == null) {
        HttpHeaders requestHeaders = new HttpHeaders();
        requestHeaders.setAccept(Collections.singletonList(new MediaType("application", "hal+json")));
        requestEntity = new HttpEntity<Void>(requestHeaders);
    }//from   w  w  w . j  a  v a2 s . c o  m
    return requestEntity;
}

From source file:com.carlomicieli.jtrains.infrastructure.web.Responses.java

public static ResponseEntity<Void> created(Link location) {
    HttpHeaders headers = new HttpHeaders();
    headers.add("Location", location.getHref());
    return new ResponseEntity<>(headers, HttpStatus.CREATED);
}

From source file:edu.infsci2560.LoginHelper.java

private static HttpHeaders getHeaders(TestRestTemplate template, String route) {
    // todo : write getHeaders test
    HttpHeaders headers = new HttpHeaders();
    ResponseEntity<String> page = template.getForEntity(route, String.class);
    assertThat(page.getStatusCode()).isEqualTo(HttpStatus.OK);

    String cookie = page.getHeaders().getFirst("Set-Cookie");
    headers.set("Cookie", cookie);

    Pattern pattern = Pattern.compile("(?s).*name=\"_csrf\".*?value=\"([^\"]+).*");
    Matcher matcher = pattern.matcher(page.getBody());
    assertThat(matcher.matches()).as(page.getBody()).isTrue();
    headers.set("X-CSRF-TOKEN", matcher.group(1));
    return headers;
}

From source file:org.dthume.spring.http.client.httpcomponents.HttpComponentsClientHttpResponse.java

private static HttpHeaders toHttpHeaders(final HttpResponse response) {
    final HttpHeaders headers = new HttpHeaders();
    for (final Header header : response.getAllHeaders())
        headers.add(header.getName(), header.getValue());
    return headers;
}

From source file:org.trustedanalytics.h2oscoringengine.publisher.http.HttpCommunication.java

public static HttpHeaders basicAuthJsonHeaders(String basicAuthToken) {
    HttpHeaders headers = new HttpHeaders();
    headers.add(CONTENT_TYPE_HEADER_NAME, JSON_ACCEPT_HEADER_VALUE);
    headers.add("Authorization", "Basic " + basicAuthToken);

    return headers;
}

From source file:monkeys.web.MonkeysController.java

@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody/* w w  w  . j  a  va2s.  c om*/
public ResponseEntity<Void> createMonkey(@RequestBody Monkey monkey) {
    monkeyRepository.save(monkey);
    HttpHeaders headers = new HttpHeaders();
    return new ResponseEntity<>(headers, HttpStatus.CREATED);
}

From source file:org.starfishrespect.myconsumption.android.util.CryptoUtils.java

/**
 * Create header for basic authentication with username and password
 * @return HttpHeaders with basic authentication
 *///  www. j a  v a 2  s.  com
public static HttpHeaders createHeaders(final String username, final String password) {
    HttpHeaders headers = new HttpHeaders() {
        {
            String auth = username + ":" + password;
            byte[] encodedAuth = Base64.encode(auth.getBytes(Charset.forName("US-ASCII")), Base64.NO_WRAP);
            String authHeader = "Basic " + new String(encodedAuth);
            //String authHeader = "Basic " + auth;
            set("Authorization", authHeader);
        }
    };
    headers.add("Content-Type", "application/json");
    headers.add("Accept", "*/*");

    return headers;
}

From source file:net.paslavsky.springrest.AuthenticationManagerImpl.java

@Override
public HttpHeaders getAuthenticationHeaders() {
    return new HttpHeaders();
}