sendError(ctx, request.getDecoderResult().toString(), HttpResponseStatus.BAD_REQUEST); return;
sendError(ctx, request.getDecoderResult().toString(), HttpResponseStatus.BAD_REQUEST); return;
/*************************************************************************** * Reading **************************************************************************/ @Override protected ConnectionState readHTTPInitial(HttpRequest httpRequest) { LOG.debug("Received raw request: {}", httpRequest); // if we cannot parse the request, immediately return a 400 and close the connection, since we do not know what state // the client thinks the connection is in if (httpRequest.getDecoderResult().isFailure()) { LOG.debug("Could not parse request from client. Decoder result: {}", httpRequest.getDecoderResult().toString()); FullHttpResponse response = ProxyUtils.createFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.BAD_REQUEST, "Unable to parse HTTP request"); HttpHeaders.setKeepAlive(response, false); respondWithShortCircuitResponse(response); return DISCONNECT_REQUESTED; } boolean authenticationRequired = authenticationRequired(httpRequest); if (authenticationRequired) { LOG.debug("Not authenticated!!"); return AWAITING_PROXY_AUTHENTICATION; } else { return doReadHTTPInitial(httpRequest); } }
/*************************************************************************** * Reading **************************************************************************/ @Override protected ConnectionState readHTTPInitial(HttpRequest httpRequest) { LOG.debug("Received raw request: {}", httpRequest); // if we cannot parse the request, immediately return a 400 and close the connection, since we do not know what state // the client thinks the connection is in if (httpRequest.getDecoderResult().isFailure()) { LOG.debug("Could not parse request from client. Decoder result: {}", httpRequest.getDecoderResult().toString()); FullHttpResponse response = ProxyUtils.createFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.BAD_REQUEST, "Unable to parse HTTP request"); HttpHeaders.setKeepAlive(response, false); respondWithShortCircuitResponse(response); return DISCONNECT_REQUESTED; } boolean authenticationRequired = authenticationRequired(httpRequest); if (authenticationRequired) { LOG.debug("Not authenticated!!"); return AWAITING_PROXY_AUTHENTICATION; } else { return doReadHTTPInitial(httpRequest); } }
/*************************************************************************** * Reading **************************************************************************/ @Override protected ConnectionState readHTTPInitial(HttpRequest httpRequest) { LOG.debug("Received raw request: {}", httpRequest); // if we cannot parse the request, immediately return a 400 and close the connection, since we do not know what state // the client thinks the connection is in if (httpRequest.getDecoderResult().isFailure()) { LOG.debug("Could not parse request from client. Decoder result: {}", httpRequest.getDecoderResult().toString()); FullHttpResponse response = ProxyUtils.createFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.BAD_REQUEST, "Unable to parse HTTP request"); HttpHeaders.setKeepAlive(response, false); respondWithShortCircuitResponse(response); return DISCONNECT_REQUESTED; } boolean authenticationRequired = authenticationRequired(httpRequest); if (authenticationRequired) { LOG.debug("Not authenticated!!"); return AWAITING_PROXY_AUTHENTICATION; } else { return doReadHTTPInitial(httpRequest); } }
@Override protected ConnectionState readHTTPInitial(HttpResponse httpResponse) { LOG.debug("Received raw response: {}", httpResponse); if (httpResponse.getDecoderResult().isFailure()) { LOG.debug("Could not parse response from server. Decoder result: {}", httpResponse.getDecoderResult().toString()); // create a "substitute" Bad Gateway response from the server, since we couldn't understand what the actual // response from the server was. set the keep-alive on the substitute response to false so the proxy closes // the connection to the server, since we don't know what state the server thinks the connection is in. FullHttpResponse substituteResponse = ProxyUtils.createFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.BAD_GATEWAY, "Unable to parse response from server"); HttpHeaders.setKeepAlive(substituteResponse, false); httpResponse = substituteResponse; } currentFilters.serverToProxyResponseReceiving(); rememberCurrentResponse(httpResponse); respondWith(httpResponse); if (ProxyUtils.isChunked(httpResponse)) { return AWAITING_CHUNK; } else { currentFilters.serverToProxyResponseReceived(); return AWAITING_INITIAL; } }
@Override protected ConnectionState readHTTPInitial(HttpResponse httpResponse) { LOG.debug("Received raw response: {}", httpResponse); if (httpResponse.getDecoderResult().isFailure()) { LOG.debug("Could not parse response from server. Decoder result: {}", httpResponse.getDecoderResult().toString()); // create a "substitute" Bad Gateway response from the server, since we couldn't understand what the actual // response from the server was. set the keep-alive on the substitute response to false so the proxy closes // the connection to the server, since we don't know what state the server thinks the connection is in. FullHttpResponse substituteResponse = ProxyUtils.createFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.BAD_GATEWAY, "Unable to parse response from server"); HttpHeaders.setKeepAlive(substituteResponse, false); httpResponse = substituteResponse; } currentFilters.serverToProxyResponseReceiving(); rememberCurrentResponse(httpResponse); respondWith(httpResponse); if (ProxyUtils.isChunked(httpResponse)) { return AWAITING_CHUNK; } else { currentFilters.serverToProxyResponseReceived(); return AWAITING_INITIAL; } }
@Override protected ConnectionState readHTTPInitial(HttpResponse httpResponse) { LOG.debug("Received raw response: {}", httpResponse); if (httpResponse.decoderResult().isFailure()) { LOG.debug("Could not parse response from server. Decoder result: {}", httpResponse.decoderResult().toString()); // create a "substitute" Bad Gateway response from the server, since we couldn't understand what the actual // response from the server was. set the keep-alive on the substitute response to false so the proxy closes // the connection to the server, since we don't know what state the server thinks the connection is in. FullHttpResponse substituteResponse = ProxyUtils.createFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.BAD_GATEWAY, "Unable to parse response from server"); HttpUtil.setKeepAlive(substituteResponse, false); httpResponse = substituteResponse; } currentFilters.serverToProxyResponseReceiving(); rememberCurrentResponse(httpResponse); respondWith(httpResponse); if (ProxyUtils.isChunked(httpResponse)) { return AWAITING_CHUNK; } else { currentFilters.serverToProxyResponseReceived(); return AWAITING_INITIAL; } }