com.amazon.redshift.plugin.httpserver.ValidHttpRequestHandler 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 valid HTML for all requests.
*/
public class ValidHttpRequestHandler implements HttpRequestHandler
{
private static final String VALID_RESPONSE = "" +
"" +
"Thank you for using Amazon Redshift! You can now close this window.
" + "";
@Override
public void handle(HttpRequest request, HttpResponse response, HttpContext context)
throws HttpException, IOException
{
response.setEntity(new StringEntity(VALID_RESPONSE, StandardCharsets.UTF_8));
response.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.TEXT_HTML.withCharset(StandardCharsets.UTF_8).toString());
response.setStatusCode(HttpStatus.SC_OK);
}
}