com.amazon.redshift.plugin.httpserver.InvalidHttpRequestHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of redshift-jdbc42 Show documentation
Show all versions of redshift-jdbc42 Show documentation
Java JDBC 4.2 (JRE 8+) driver for Redshift database
package com.amazon.redshift.plugin.httpserver;
import org.apache.http.*;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.protocol.HttpContext;
import org.apache.http.protocol.HttpRequestHandler;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
/**
* Return invalid HTML for all requests.
*/
public class InvalidHttpRequestHandler implements HttpRequestHandler
{
private static final String INVALID_RESPONSE =
"The request could not be understood by the server!
";
@Override
public void handle(HttpRequest request, HttpResponse response, HttpContext context)
throws HttpException, IOException
{
response.setEntity(new StringEntity(INVALID_RESPONSE,
StandardCharsets.UTF_8));
response.setHeader(
HttpHeaders.CONTENT_TYPE,
ContentType.TEXT_HTML.withCharset(StandardCharsets.UTF_8).toString());
response.setStatusCode(HttpStatus.SC_BAD_REQUEST);
}
}