equal
deleted
inserted
replaced
20 * or visit www.oracle.com if you need additional information or have any |
20 * or visit www.oracle.com if you need additional information or have any |
21 * questions. |
21 * questions. |
22 */ |
22 */ |
23 |
23 |
24 import java.io.*; |
24 import java.io.*; |
|
25 import java.nio.file.Files; |
|
26 import java.nio.file.Path; |
|
27 import java.nio.file.Paths; |
|
28 |
25 import jdk.internal.net.http.common.HttpHeadersImpl; |
29 import jdk.internal.net.http.common.HttpHeadersImpl; |
26 |
30 |
27 public class EchoHandler implements Http2Handler { |
31 public class EchoHandler implements Http2Handler { |
|
32 static final Path CWD = Paths.get("."); |
|
33 |
28 public EchoHandler() {} |
34 public EchoHandler() {} |
29 |
35 |
30 @Override |
36 @Override |
31 public void handle(Http2TestExchange t) |
37 public void handle(Http2TestExchange t) |
32 throws IOException { |
38 throws IOException { |
36 HttpHeadersImpl map = t.getRequestHeaders(); |
42 HttpHeadersImpl map = t.getRequestHeaders(); |
37 HttpHeadersImpl map1 = t.getResponseHeaders(); |
43 HttpHeadersImpl map1 = t.getResponseHeaders(); |
38 map1.addHeader("X-Hello", "world"); |
44 map1.addHeader("X-Hello", "world"); |
39 map1.addHeader("X-Bye", "universe"); |
45 map1.addHeader("X-Bye", "universe"); |
40 String fixedrequest = map.firstValue("XFixed").orElse(null); |
46 String fixedrequest = map.firstValue("XFixed").orElse(null); |
41 File outfile = File.createTempFile("foo", "bar"); |
47 File outfile = Files.createTempFile(CWD, "foo", "bar").toFile(); |
42 //System.err.println ("QQQ = " + outfile.toString()); |
48 //System.err.println ("QQQ = " + outfile.toString()); |
43 FileOutputStream fos = new FileOutputStream(outfile); |
49 FileOutputStream fos = new FileOutputStream(outfile); |
44 int count = (int) is.transferTo(fos); |
50 int count = (int) is.transferTo(fos); |
45 System.err.printf("EchoHandler read %d bytes\n", count); |
51 System.err.printf("EchoHandler read %d bytes\n", count); |
46 is.close(); |
52 is.close(); |