Java Code Examples for org.springframework.web.server.ServerWebExchange#checkNotModified()

The following examples show how to use org.springframework.web.server.ServerWebExchange#checkNotModified() . 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: DefaultServerResponseBuilder.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public final Mono<Void> writeTo(ServerWebExchange exchange, Context context) {
	writeStatusAndHeaders(exchange.getResponse());
	Instant lastModified = Instant.ofEpochMilli(headers().getLastModified());
	HttpMethod httpMethod = exchange.getRequest().getMethod();
	if (SAFE_METHODS.contains(httpMethod) && exchange.checkNotModified(headers().getETag(), lastModified)) {
		return exchange.getResponse().setComplete();
	}
	else {
		return writeToInternal(exchange, context);
	}
}
 
Example 2
Source File: RequestMappingViewResolutionIntegrationTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@GetMapping("/html")
public String getHtmlPage(Optional<String> name, Model model, ServerWebExchange exchange) {
	if (exchange.checkNotModified("deadb33f8badf00d")) {
		return null;
	}
	model.addAttribute("hello", "Hello: " + name.orElse("<no name>") + "!");
	return "test";
}
 
Example 3
Source File: InvocableHandlerMethodTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Nullable
String notModified(ServerWebExchange exchange) {
	if (exchange.checkNotModified(Instant.ofEpochMilli(1000 * 1000))) {
		return null;
	}
	return "body";
}
 
Example 4
Source File: DefaultServerResponseBuilder.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public final Mono<Void> writeTo(ServerWebExchange exchange, Context context) {
	writeStatusAndHeaders(exchange.getResponse());
	Instant lastModified = Instant.ofEpochMilli(headers().getLastModified());
	HttpMethod httpMethod = exchange.getRequest().getMethod();
	if (SAFE_METHODS.contains(httpMethod) && exchange.checkNotModified(headers().getETag(), lastModified)) {
		return exchange.getResponse().setComplete();
	}
	else {
		return writeToInternal(exchange, context);
	}
}
 
Example 5
Source File: RequestMappingViewResolutionIntegrationTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@GetMapping("/html")
public String getHtmlPage(Optional<String> name, Model model, ServerWebExchange exchange) {
	if (exchange.checkNotModified("deadb33f8badf00d")) {
		return null;
	}
	model.addAttribute("hello", "Hello: " + name.orElse("<no name>") + "!");
	return "test";
}
 
Example 6
Source File: InvocableHandlerMethodTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Nullable
String notModified(ServerWebExchange exchange) {
	if (exchange.checkNotModified(Instant.ofEpochMilli(1000 * 1000))) {
		return null;
	}
	return "body";
}