File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
src/express/http/response Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 1212import java .io .IOException ;
1313import java .io .OutputStream ;
1414import java .nio .file .Files ;
15+ import java .util .List ;
1516
1617/**
1718 * @author Simon Reinisch
@@ -34,6 +35,37 @@ public Response(HttpExchange exchange) {
3435 this .BODY = exchange .getResponseBody ();
3536 }
3637
38+ /**
39+ * Add an specific value to the reponse header.
40+ *
41+ * @param key The header name.
42+ * @param value The header value.
43+ * @return This Response instance.
44+ */
45+ public Response setHeader (String key , String value ) {
46+ HEADER .add (key , value );
47+ return this ;
48+ }
49+
50+ /**
51+ * @param key The header key.
52+ * @return The values which are associated with this key.
53+ */
54+ public List <String > getHeader (String key ) {
55+ return HEADER .get (key );
56+ }
57+
58+ /**
59+ * Sets the response Location HTTP header to the specified path parameter.
60+ *
61+ * @param location The location.
62+ */
63+ public void setLocation (String location ) {
64+ HEADER .add ("Location" , location );
65+ setStatus (Status ._302 );
66+ send ();
67+ }
68+
3769 /**
3870 * Set an cookie.
3971 *
You can’t perform that action at this time.
0 commit comments