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:org.jnrain.mobile.accounts.kbs.KBSLoginRequest.java

@Override
public SimpleReturnCode loadDataFromNetwork() throws Exception {
    MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>();
    params.set("uid", _uid);
    params.set("psw", _password);

    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
    HttpEntity<MultiValueMap<String, String>> req = new HttpEntity<MultiValueMap<String, String>>(params,
            headers);/* www .ja  v a 2  s  .  co m*/

    return getRestTemplate().postForObject(
            /* "http://rhymin.jnrain.com/api/login/", */
            "http://bbs.jnrain.com/rainstyle/apilogin.php", req, SimpleReturnCode.class);
}

From source file:org.openmrs.module.patientimage.rest.controller.PatientImageController.java

/**
 * @param patientid int//w w w.  ja  va 2s  .  c o  m
 * @param pageid int
 * @return ResponseEntity<byte[]> containing image binary data with JPEG
 *    image header.
 * @throws ResponseException
 * @throws IOException 
 */
@RequestMapping(value = "/{patientid}/{pageid}", method = RequestMethod.GET)
public ResponseEntity<byte[]> retrieve(@PathVariable("patientid") String patientIdStr,
        @PathVariable("pageid") String pageIdStr, HttpServletRequest request) throws IOException {
    //RequestContext context = RestUtil.getRequestContext(request);
    int patientId = Integer.parseInt(patientIdStr);
    int pageId = Integer.parseInt(pageIdStr);
    final HttpHeaders headers = new HttpHeaders();
    byte[] imageData = null;
    HttpStatus status = null;
    headers.setContentType(MediaType.IMAGE_JPEG);
    status = HttpStatus.OK;
    return new ResponseEntity<byte[]>(imageData, headers, status);
}

From source file:edu.infsci2560.services.BlogsService.java

@RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = "application/json")
public ResponseEntity<Blog> list(@PathVariable("id") Long id) {
    HttpHeaders headers = new HttpHeaders();
    return new ResponseEntity<>(repository.findOne(id), headers, HttpStatus.OK);
}

From source file:com.profiles.rest.RestExceptionHandler.java

@ExceptionHandler(value = { ConstraintViolationException.class })
public final ResponseEntity<?> handleException(ConstraintViolationException ex, WebRequest request) {
    Map<String, String> errors = BeanValidators.extractPropertyAndMessage(ex.getConstraintViolations());
    String body = jsonMapper.toJson(errors);
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.TEXT_PLAIN);
    return handleExceptionInternal(ex, body, null, HttpStatus.BAD_REQUEST, request);
}

From source file:monkeys.web.BananasController.java

@RequestMapping(method = RequestMethod.GET, value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Banana> getBanana(@PathVariable Long id) {
    Banana banana = bananaRepository.findOne(id);
    HttpHeaders headers = new HttpHeaders();
    return new ResponseEntity<>(banana, headers, HttpStatus.OK);
}

From source file:fi.helsinki.opintoni.integration.pagemetadata.SpringPageMetaDataHttpClient.java

@Override
public Optional<String> getPageBody(String pageUrl) {
    Optional<String> pageBody = Optional.empty();
    try {//from w  w  w  .  ja  va2s. co m
        HttpHeaders headers = new HttpHeaders();
        headers.setAccept(Lists.newArrayList(MediaType.TEXT_HTML));
        headers.add(USER_AGENT_KEY, USER_AGENT);
        HttpEntity<String> entity = new HttpEntity<>(PARAMETERS_KEY, headers);

        ResponseEntity<String> response = metaDataRestTemplate.exchange(pageUrl, HttpMethod.GET, entity,
                String.class);
        if (response.getStatusCode().equals(HttpStatus.OK)) {
            pageBody = Optional.ofNullable(response.getBody());
        }
    } catch (Exception e) {
    }

    return pageBody;

}

From source file:com.grizzly.rest.WebServiceFactory.java

public void resetHeaders() {
    requestHeaders = new HttpHeaders();
    responseHeaders = new HttpHeaders();
}

From source file:edu.infsci2560.services.FriendService.java

@RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = "application/json")
public ResponseEntity<Friend> list(@PathVariable("id") Long id) {
    HttpHeaders headers = new HttpHeaders();
    return new ResponseEntity<>(repository.findOne(id), headers, HttpStatus.OK);
}

From source file:ai.emot.api.impl.EmotionTemplate.java

@Override
public EmotionProfile getFaceImageEmotionProfile(BufferedImage image) {

    HttpHeaders headers = new HttpHeaders();
    headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
    headers.setContentType(MediaType.IMAGE_JPEG);
    HttpEntity<BufferedImage> entity = new HttpEntity<BufferedImage>(image, headers);

    ResponseEntity<EmotionProfile> response = restTemplate.exchange(apiBaseUrl + "/face/emotion",
            HttpMethod.POST, entity, EmotionProfile.class);
    return response.getBody();

}

From source file:edu.infsci2560.services.DvdsService.java

@RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = "application/json")
public ResponseEntity<Dvd> list(@PathVariable("id") Long id) {
    HttpHeaders headers = new HttpHeaders();
    return new ResponseEntity<>(repository.findOne(id), headers, HttpStatus.OK);
}