Java Code Examples for org.springframework.http.HttpHeaders#getContentLanguage()

The following examples show how to use org.springframework.http.HttpHeaders#getContentLanguage() . 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: MockHttpServletResponse.java    From spring-analysis-note with MIT License 6 votes vote down vote up
private boolean setSpecialHeader(String name, Object value) {
	if (HttpHeaders.CONTENT_TYPE.equalsIgnoreCase(name)) {
		setContentType(value.toString());
		return true;
	}
	else if (HttpHeaders.CONTENT_LENGTH.equalsIgnoreCase(name)) {
		setContentLength(value instanceof Number ? ((Number) value).intValue() :
				Integer.parseInt(value.toString()));
		return true;
	}
	else if (HttpHeaders.CONTENT_LANGUAGE.equalsIgnoreCase(name)) {
		HttpHeaders headers = new HttpHeaders();
		headers.add(HttpHeaders.CONTENT_LANGUAGE, value.toString());
		Locale language = headers.getContentLanguage();
		setLocale(language != null ? language : Locale.getDefault());
		return true;
	}
	else if (HttpHeaders.SET_COOKIE.equalsIgnoreCase(name)) {
		MockCookie cookie = MockCookie.parse(value.toString());
		addCookie(cookie);
		return true;
	}
	else {
		return false;
	}
}
 
Example 2
Source File: MockHttpServletResponse.java    From spring-analysis-note with MIT License 6 votes vote down vote up
private boolean setSpecialHeader(String name, Object value) {
	if (HttpHeaders.CONTENT_TYPE.equalsIgnoreCase(name)) {
		setContentType(value.toString());
		return true;
	}
	else if (HttpHeaders.CONTENT_LENGTH.equalsIgnoreCase(name)) {
		setContentLength(value instanceof Number ? ((Number) value).intValue() :
				Integer.parseInt(value.toString()));
		return true;
	}
	else if (HttpHeaders.CONTENT_LANGUAGE.equalsIgnoreCase(name)) {
		HttpHeaders headers = new HttpHeaders();
		headers.add(HttpHeaders.CONTENT_LANGUAGE, value.toString());
		Locale language = headers.getContentLanguage();
		setLocale(language != null ? language : Locale.getDefault());
		return true;
	}
	else if (HttpHeaders.SET_COOKIE.equalsIgnoreCase(name)) {
		MockCookie cookie = MockCookie.parse(value.toString());
		addCookie(cookie);
		return true;
	}
	else {
		return false;
	}
}
 
Example 3
Source File: MockHttpServletResponse.java    From java-technology-stack with MIT License 6 votes vote down vote up
private boolean setSpecialHeader(String name, Object value) {
	if (HttpHeaders.CONTENT_TYPE.equalsIgnoreCase(name)) {
		setContentType(value.toString());
		return true;
	}
	else if (HttpHeaders.CONTENT_LENGTH.equalsIgnoreCase(name)) {
		setContentLength(value instanceof Number ? ((Number) value).intValue() :
				Integer.parseInt(value.toString()));
		return true;
	}
	else if (HttpHeaders.CONTENT_LANGUAGE.equalsIgnoreCase(name)) {
		HttpHeaders headers = new HttpHeaders();
		headers.add(HttpHeaders.CONTENT_LANGUAGE, value.toString());
		Locale language = headers.getContentLanguage();
		setLocale(language != null ? language : Locale.getDefault());
		return true;
	}
	else if (HttpHeaders.SET_COOKIE.equalsIgnoreCase(name)) {
		MockCookie cookie = MockCookie.parse(value.toString());
		addCookie(cookie);
		return true;
	}
	else {
		return false;
	}
}
 
Example 4
Source File: MockHttpServletResponse.java    From java-technology-stack with MIT License 6 votes vote down vote up
private boolean setSpecialHeader(String name, Object value) {
	if (HttpHeaders.CONTENT_TYPE.equalsIgnoreCase(name)) {
		setContentType(value.toString());
		return true;
	}
	else if (HttpHeaders.CONTENT_LENGTH.equalsIgnoreCase(name)) {
		setContentLength(value instanceof Number ? ((Number) value).intValue() :
				Integer.parseInt(value.toString()));
		return true;
	}
	else if (HttpHeaders.CONTENT_LANGUAGE.equalsIgnoreCase(name)) {
		HttpHeaders headers = new HttpHeaders();
		headers.add(HttpHeaders.CONTENT_LANGUAGE, value.toString());
		Locale language = headers.getContentLanguage();
		setLocale(language != null ? language : Locale.getDefault());
		return true;
	}
	else if (HttpHeaders.SET_COOKIE.equalsIgnoreCase(name)) {
		MockCookie cookie = MockCookie.parse(value.toString());
		addCookie(cookie);
		return true;
	}
	else {
		return false;
	}
}