public WebdavListener(HttpDestination destination, HttpExchange ex) { // Start of sending events through to the wrapped listener // Next decision point is the onResponseStatus super(ex.getEventListener(),true); _destination=destination; _exchange=ex; // We'll only enable webdav if this is a PUT request if ( HttpMethods.PUT.equalsIgnoreCase( _exchange.getMethod() ) ) { _webdavEnabled = true; } }
@Override public void headerComplete() throws IOException { HttpExchange exchange = _exchange; if (exchange!=null) { exchange.setStatus(HttpExchange.STATUS_PARSING_CONTENT); if (HttpMethods.CONNECT.equalsIgnoreCase(exchange.getMethod())) _parser.setPersistent(true); } }
@Override public void onResponseStatus(Buffer version, int status, Buffer reason) throws IOException { // Update the exchange method to get to support the Post/Redirect/Get // http://en.wikipedia.org/wiki/Post/Redirect/Get if (exchange.getMethod().equals("POST") && (status == HttpStatus.SEE_OTHER_303 || status == HttpStatus.MOVED_TEMPORARILY_302)) { exchange.setMethod("GET"); } // Since the default RedirectListener only cares about http // response codes 301 and 302, we override this method and // trick the super class into handling this case for us. if (status == HttpStatus.SEE_OTHER_303) { status = HttpStatus.MOVED_TEMPORARILY_302; } super.onResponseStatus(version, status, reason); } }
md.update(exchange.getMethod().getBytes(StringUtil.__ISO_8859_1)); md.update((byte)':'); md.update(exchange.getURI().getBytes(StringUtil.__ISO_8859_1));
@Override public void startResponse(Buffer version, int status, Buffer reason) throws IOException { HttpExchange exchange = _exchange; if (exchange==null) { LOG.warn("No exchange for response"); _endp.close(); return; } switch(status) { case HttpStatus.CONTINUE_100: case HttpStatus.PROCESSING_102: // TODO check if appropriate expect was sent in the request. exchange.setEventListener(new NonFinalResponseListener(exchange)); break; case HttpStatus.OK_200: // handle special case for CONNECT 200 responses if (HttpMethods.CONNECT.equalsIgnoreCase(exchange.getMethod())) _parser.setHeadResponse(true); break; } _http11 = HttpVersions.HTTP_1_1_BUFFER.equals(version); _status=status; exchange.getEventListener().onResponseStatus(version,status,reason); exchange.setStatus(HttpExchange.STATUS_PARSING_HEADERS); }
_generator.setVersion(_exchange.getVersion()); String method=_exchange.getMethod(); String uri = _exchange.getRequestURI(); if (_destination.isProxied())