@Test public void redirect() throws ExpressionException, HandlerException, IOException { StaticResponseHandler handler = new StaticResponseHandler(); handler.status = 302; handler.reason = "Found"; handler.headers.add("Location", new Expression("http: Exchange exchange = new Exchange(); handler.handle(exchange); assertThat(exchange.response.status).isEqualTo(302); assertThat(exchange.response.reason).isEqualTo("Found"); assertThat(exchange.response.headers.getFirst("Location")).isEqualTo("http: }
@Override public void handle(Exchange exchange) throws HandlerException, IOException { LogTimer timer = logger.getTimer().start(); Response response = new Response(); response.status = this.status; response.reason = this.reason; if (response.reason == null) { response.reason = HttpUtil.getReason(response.status); } if (response.reason == null) { response.reason = "Uncertain"; } if (this.version != null) { response.version = this.version; } for (String key : this.headers.keySet()) { for (Expression expression : this.headers.get(key)) { String eval = expression.eval(exchange, String.class); if (eval != null) { response.headers.add(key, eval); } } } if (this.entity != null) { HttpUtil.toEntity(response, entity, null); } exchange.response = response; timer.stop(); }
StaticResponseHandler extends GenericHandler { @Override public void handle(Exchange exchange) throws HandlerException, IOException { LogTimer timer = logger.getTimer().start(); Response response = new Response(); response.status = this.status; response.reason = this.reason; if (response.reason == null) { response.reason = HttpUtil.getReason(response.status); } if (response.reason == null) { response.reason = "Uncertain"; } if (this.version != null) { response.version = this.version; } for (String key : this.headers.keySet()) { for (Expression expression : this.headers.get(key)) { String eval = expression.eval(exchange, String.class); if (eval != null) { response.headers.add(key, eval); } } } if (this.entity != null) { HttpUtil.toEntity(response, entity, null); } exchange.response = response; timer.stop(); } }
StaticResponseHandler extends GenericHandler { @Override public void handle(Exchange exchange) throws HandlerException, IOException { LogTimer timer = logger.getTimer().start(); Response response = new Response(); response.status = this.status; response.reason = this.reason; if (response.reason == null) { response.reason = HttpUtil.getReason(response.status); } if (response.reason == null) { response.reason = "Uncertain"; } if (this.version != null) { response.version = this.version; } for (String key : this.headers.keySet()) { for (Expression expression : this.headers.get(key)) { String eval = expression.eval(exchange, String.class); if (eval != null) { response.headers.add(key, eval); } } } if (this.entity != null) { HttpUtil.toEntity(response, entity, null); } exchange.response = response; timer.stop(); }  }
StaticResponseHandler extends GenericHandler { @Override public void handle(Exchange exchange) throws HandlerException, IOException { LogTimer timer = logger.getTimer().start(); Response response = new Response(); response.status = this.status; response.reason = this.reason; if (response.reason == null) { response.reason = HttpUtil.getReason(response.status); } if (response.reason == null) { response.reason = "Uncertain"; } if (this.version != null) { response.version = this.version; } for (String key : this.headers.keySet()) { for (Expression expression : this.headers.get(key)) { String eval = expression.eval(exchange, String.class); if (eval != null) { response.headers.add(key, eval); } } } if (this.entity != null) { HttpUtil.toEntity(response, entity, null); } exchange.response = response; timer.stop(); }  @Override void handle(Exchange exchange); }
StaticResponseHandler extends GenericHandler { @Override public void handle(Exchange exchange) throws HandlerException, IOException { LogTimer timer = logger.getTimer().start(); Response response = new Response(); response.status = this.status; response.reason = this.reason; if (response.reason == null) { response.reason = HttpUtil.getReason(response.status); } if (response.reason == null) { response.reason = "Uncertain"; } if (this.version != null) { response.version = this.version; } for (String key : this.headers.keySet()) { for (Expression expression : this.headers.get(key)) { String eval = expression.eval(exchange, String.class); if (eval != null) { response.headers.add(key, eval); } } } if (this.entity != null) { HttpUtil.toEntity(response, entity, null); } exchange.response = response; timer.stop(); }  @Override void handle(Exchange exchange); public Integer status; public String reason; public String version; final MultiValueMap<String, Expression> headers; public String entity; }