equal
deleted
inserted
replaced
23 |
23 |
24 import java.io.IOException; |
24 import java.io.IOException; |
25 import java.io.InputStream; |
25 import java.io.InputStream; |
26 import java.io.OutputStream; |
26 import java.io.OutputStream; |
27 import java.util.function.Supplier; |
27 import java.util.function.Supplier; |
28 import jdk.internal.net.http.common.HttpHeadersImpl; |
28 import jdk.internal.net.http.common.HttpHeadersBuilder; |
29 |
29 |
30 public class Http2RedirectHandler implements Http2Handler { |
30 public class Http2RedirectHandler implements Http2Handler { |
31 |
31 |
32 final Supplier<String> supplier; |
32 final Supplier<String> supplier; |
33 |
33 |
42 is.readAllBytes(); |
42 is.readAllBytes(); |
43 String location = supplier.get(); |
43 String location = supplier.get(); |
44 System.err.printf("RedirectHandler request to %s from %s\n", |
44 System.err.printf("RedirectHandler request to %s from %s\n", |
45 t.getRequestURI().toString(), t.getRemoteAddress().toString()); |
45 t.getRequestURI().toString(), t.getRemoteAddress().toString()); |
46 System.err.println("Redirecting to: " + location); |
46 System.err.println("Redirecting to: " + location); |
47 HttpHeadersImpl map1 = t.getResponseHeaders(); |
47 HttpHeadersBuilder headersBuilder = t.getResponseHeaders(); |
48 map1.addHeader("Location", location); |
48 headersBuilder.addHeader("Location", location); |
49 t.sendResponseHeaders(301, 1024); |
49 t.sendResponseHeaders(301, 1024); |
50 byte[] bb = new byte[1024]; |
50 byte[] bb = new byte[1024]; |
51 OutputStream os = t.getResponseBody(); |
51 OutputStream os = t.getResponseBody(); |
52 os.write(bb); |
52 os.write(bb); |
53 os.close(); |
53 os.close(); |