All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.amazon.redshift.plugin.httpserver.InvalidHttpRequestHandler Maven / Gradle / Ivy

There is a newer version: 2.1.0.30
Show newest version
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); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy