Java Code Examples for com.sun.net.httpserver.Headers#put()
The following examples show how to use
com.sun.net.httpserver.Headers#put() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HttpOnly.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
@Override public void handle(HttpExchange t) throws IOException { Headers reqHeaders = t.getRequestHeaders(); // some small sanity check List<String> cookies = reqHeaders.get("Cookie"); for (String cookie : cookies) { if (!cookie.contains("JSESSIONID") || !cookie.contains("WILE_E_COYOTE")) t.sendResponseHeaders(400, -1); } // return some cookies so we can check getHeaderField(s) Headers respHeaders = t.getResponseHeaders(); List<String> values = new ArrayList<>(); values.add("ID=JOEBLOGGS; version=1; Path=" + URI_PATH); values.add("NEW_JSESSIONID=" + (SESSION_ID+1) + "; version=1; Path=" + URI_PATH +"; HttpOnly"); values.add("NEW_CUSTOMER=WILE_E_COYOTE2; version=1; Path=" + URI_PATH); respHeaders.put("Set-Cookie", values); values = new ArrayList<>(); values.add("COOKIE2_CUSTOMER=WILE_E_COYOTE2; version=1; Path=" + URI_PATH); respHeaders.put("Set-Cookie2", values); values.add("COOKIE2_JSESSIONID=" + (SESSION_ID+100) + "; version=1; Path=" + URI_PATH +"; HttpOnly"); respHeaders.put("Set-Cookie2", values); t.sendResponseHeaders(200, -1); t.close(); }
Example 2
Source File: HttpOnly.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Override public void handle(HttpExchange t) throws IOException { Headers reqHeaders = t.getRequestHeaders(); // some small sanity check List<String> cookies = reqHeaders.get("Cookie"); for (String cookie : cookies) { if (!cookie.contains("JSESSIONID") || !cookie.contains("WILE_E_COYOTE")) t.sendResponseHeaders(400, -1); } // return some cookies so we can check getHeaderField(s) Headers respHeaders = t.getResponseHeaders(); List<String> values = new ArrayList<>(); values.add("ID=JOEBLOGGS; version=1; Path=" + URI_PATH); values.add("NEW_JSESSIONID=" + (SESSION_ID+1) + "; version=1; Path=" + URI_PATH +"; HttpOnly"); values.add("NEW_CUSTOMER=WILE_E_COYOTE2; version=1; Path=" + URI_PATH); respHeaders.put("Set-Cookie", values); values = new ArrayList<>(); values.add("COOKIE2_CUSTOMER=WILE_E_COYOTE2; version=1; Path=" + URI_PATH); respHeaders.put("Set-Cookie2", values); values.add("COOKIE2_JSESSIONID=" + (SESSION_ID+100) + "; version=1; Path=" + URI_PATH +"; HttpOnly"); respHeaders.put("Set-Cookie2", values); t.sendResponseHeaders(200, -1); t.close(); }
Example 3
Source File: HttpOnly.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
@Override public void handle(HttpExchange t) throws IOException { Headers reqHeaders = t.getRequestHeaders(); // some small sanity check List<String> cookies = reqHeaders.get("Cookie"); for (String cookie : cookies) { if (!cookie.contains("JSESSIONID") || !cookie.contains("WILE_E_COYOTE")) t.sendResponseHeaders(400, -1); } // return some cookies so we can check getHeaderField(s) Headers respHeaders = t.getResponseHeaders(); List<String> values = new ArrayList<>(); values.add("ID=JOEBLOGGS; version=1; Path=" + URI_PATH); values.add("NEW_JSESSIONID=" + (SESSION_ID+1) + "; version=1; Path=" + URI_PATH +"; HttpOnly"); values.add("NEW_CUSTOMER=WILE_E_COYOTE2; version=1; Path=" + URI_PATH); respHeaders.put("Set-Cookie", values); values = new ArrayList<>(); values.add("COOKIE2_CUSTOMER=WILE_E_COYOTE2; version=1; Path=" + URI_PATH); respHeaders.put("Set-Cookie2", values); values.add("COOKIE2_JSESSIONID=" + (SESSION_ID+100) + "; version=1; Path=" + URI_PATH +"; HttpOnly"); respHeaders.put("Set-Cookie2", values); t.sendResponseHeaders(200, -1); t.close(); }
Example 4
Source File: ServerConnectionImpl.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Override public void setResponseHeaders(Map<String,List<String>> headers) { Headers r = httpExchange.getResponseHeaders(); r.clear(); for(Map.Entry <String, List<String>> entry : headers.entrySet()) { String name = entry.getKey(); List<String> values = entry.getValue(); // ignore headers that interfere with our correct operations if (!"Content-Length".equalsIgnoreCase(name) && !"Content-Type".equalsIgnoreCase(name)) { r.put(name,new ArrayList<String>(values)); } } }
Example 5
Source File: HttpOnly.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Override public void handle(HttpExchange t) throws IOException { Headers reqHeaders = t.getRequestHeaders(); // some small sanity check List<String> cookies = reqHeaders.get("Cookie"); for (String cookie : cookies) { if (!cookie.contains("JSESSIONID") || !cookie.contains("WILE_E_COYOTE")) t.sendResponseHeaders(400, -1); } // return some cookies so we can check getHeaderField(s) Headers respHeaders = t.getResponseHeaders(); List<String> values = new ArrayList<>(); values.add("ID=JOEBLOGGS; version=1; Path=" + URI_PATH); values.add("NEW_JSESSIONID=" + (SESSION_ID+1) + "; version=1; Path=" + URI_PATH +"; HttpOnly"); values.add("NEW_CUSTOMER=WILE_E_COYOTE2; version=1; Path=" + URI_PATH); respHeaders.put("Set-Cookie", values); values = new ArrayList<>(); values.add("COOKIE2_CUSTOMER=WILE_E_COYOTE2; version=1; Path=" + URI_PATH); respHeaders.put("Set-Cookie2", values); values.add("COOKIE2_JSESSIONID=" + (SESSION_ID+100) + "; version=1; Path=" + URI_PATH +"; HttpOnly"); respHeaders.put("Set-Cookie2", values); t.sendResponseHeaders(200, -1); t.close(); }
Example 6
Source File: ServerConnectionImpl.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@Override public void setResponseHeaders(Map<String,List<String>> headers) { Headers r = httpExchange.getResponseHeaders(); r.clear(); for(Map.Entry <String, List<String>> entry : headers.entrySet()) { String name = entry.getKey(); List<String> values = entry.getValue(); // ignore headers that interfere with our correct operations if (!"Content-Length".equalsIgnoreCase(name) && !"Content-Type".equalsIgnoreCase(name)) { r.put(name,new ArrayList<String>(values)); } } }
Example 7
Source File: HttpOnly.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@Override public void handle(HttpExchange t) throws IOException { Headers reqHeaders = t.getRequestHeaders(); // some small sanity check List<String> cookies = reqHeaders.get("Cookie"); for (String cookie : cookies) { if (!cookie.contains("JSESSIONID") || !cookie.contains("WILE_E_COYOTE")) t.sendResponseHeaders(400, -1); } // return some cookies so we can check getHeaderField(s) Headers respHeaders = t.getResponseHeaders(); List<String> values = new ArrayList<>(); values.add("ID=JOEBLOGGS; version=1; Path=" + URI_PATH); values.add("NEW_JSESSIONID=" + (SESSION_ID+1) + "; version=1; Path=" + URI_PATH +"; HttpOnly"); values.add("NEW_CUSTOMER=WILE_E_COYOTE2; version=1; Path=" + URI_PATH); respHeaders.put("Set-Cookie", values); values = new ArrayList<>(); values.add("COOKIE2_CUSTOMER=WILE_E_COYOTE2; version=1; Path=" + URI_PATH); respHeaders.put("Set-Cookie2", values); values.add("COOKIE2_JSESSIONID=" + (SESSION_ID+100) + "; version=1; Path=" + URI_PATH +"; HttpOnly"); respHeaders.put("Set-Cookie2", values); t.sendResponseHeaders(200, -1); t.close(); }
Example 8
Source File: ServerConnectionImpl.java From hottub with GNU General Public License v2.0 | 5 votes |
@Override public void setResponseHeaders(Map<String,List<String>> headers) { Headers r = httpExchange.getResponseHeaders(); r.clear(); for(Map.Entry <String, List<String>> entry : headers.entrySet()) { String name = entry.getKey(); List<String> values = entry.getValue(); // ignore headers that interfere with our correct operations if (!"Content-Length".equalsIgnoreCase(name) && !"Content-Type".equalsIgnoreCase(name)) { r.put(name,new ArrayList<String>(values)); } } }
Example 9
Source File: HttpOnly.java From hottub with GNU General Public License v2.0 | 5 votes |
@Override public void handle(HttpExchange t) throws IOException { Headers reqHeaders = t.getRequestHeaders(); // some small sanity check List<String> cookies = reqHeaders.get("Cookie"); for (String cookie : cookies) { if (!cookie.contains("JSESSIONID") || !cookie.contains("WILE_E_COYOTE")) t.sendResponseHeaders(400, -1); } // return some cookies so we can check getHeaderField(s) Headers respHeaders = t.getResponseHeaders(); List<String> values = new ArrayList<>(); values.add("ID=JOEBLOGGS; version=1; Path=" + URI_PATH); values.add("NEW_JSESSIONID=" + (SESSION_ID+1) + "; version=1; Path=" + URI_PATH +"; HttpOnly"); values.add("NEW_CUSTOMER=WILE_E_COYOTE2; version=1; Path=" + URI_PATH); respHeaders.put("Set-Cookie", values); values = new ArrayList<>(); values.add("COOKIE2_CUSTOMER=WILE_E_COYOTE2; version=1; Path=" + URI_PATH); respHeaders.put("Set-Cookie2", values); values.add("COOKIE2_JSESSIONID=" + (SESSION_ID+100) + "; version=1; Path=" + URI_PATH +"; HttpOnly"); respHeaders.put("Set-Cookie2", values); t.sendResponseHeaders(200, -1); t.close(); }
Example 10
Source File: HttpOnly.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Override public void handle(HttpExchange t) throws IOException { Headers reqHeaders = t.getRequestHeaders(); // some small sanity check List<String> cookies = reqHeaders.get("Cookie"); for (String cookie : cookies) { if (!cookie.contains("JSESSIONID") || !cookie.contains("WILE_E_COYOTE")) t.sendResponseHeaders(400, -1); } // return some cookies so we can check getHeaderField(s) Headers respHeaders = t.getResponseHeaders(); List<String> values = new ArrayList<>(); values.add("ID=JOEBLOGGS; version=1; Path=" + URI_PATH); values.add("NEW_JSESSIONID=" + (SESSION_ID+1) + "; version=1; Path=" + URI_PATH +"; HttpOnly"); values.add("NEW_CUSTOMER=WILE_E_COYOTE2; version=1; Path=" + URI_PATH); respHeaders.put("Set-Cookie", values); values = new ArrayList<>(); values.add("COOKIE2_CUSTOMER=WILE_E_COYOTE2; version=1; Path=" + URI_PATH); respHeaders.put("Set-Cookie2", values); values.add("COOKIE2_JSESSIONID=" + (SESSION_ID+100) + "; version=1; Path=" + URI_PATH +"; HttpOnly"); respHeaders.put("Set-Cookie2", values); t.sendResponseHeaders(200, -1); t.close(); }
Example 11
Source File: HttpOnly.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Override public void handle(HttpExchange t) throws IOException { Headers reqHeaders = t.getRequestHeaders(); // some small sanity check List<String> cookies = reqHeaders.get("Cookie"); for (String cookie : cookies) { if (!cookie.contains("JSESSIONID") || !cookie.contains("WILE_E_COYOTE")) t.sendResponseHeaders(400, -1); } // return some cookies so we can check getHeaderField(s) Headers respHeaders = t.getResponseHeaders(); List<String> values = new ArrayList<>(); values.add("ID=JOEBLOGGS; version=1; Path=" + URI_PATH); values.add("NEW_JSESSIONID=" + (SESSION_ID+1) + "; version=1; Path=" + URI_PATH +"; HttpOnly"); values.add("NEW_CUSTOMER=WILE_E_COYOTE2; version=1; Path=" + URI_PATH); respHeaders.put("Set-Cookie", values); values = new ArrayList<>(); values.add("COOKIE2_CUSTOMER=WILE_E_COYOTE2; version=1; Path=" + URI_PATH); respHeaders.put("Set-Cookie2", values); values.add("COOKIE2_JSESSIONID=" + (SESSION_ID+100) + "; version=1; Path=" + URI_PATH +"; HttpOnly"); respHeaders.put("Set-Cookie2", values); t.sendResponseHeaders(200, -1); t.close(); }
Example 12
Source File: HttpOnly.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override public void handle(HttpExchange t) throws IOException { Headers reqHeaders = t.getRequestHeaders(); // some small sanity check List<String> cookies = reqHeaders.get("Cookie"); for (String cookie : cookies) { if (!cookie.contains("JSESSIONID") || !cookie.contains("WILE_E_COYOTE")) t.sendResponseHeaders(400, -1); } // return some cookies so we can check getHeaderField(s) Headers respHeaders = t.getResponseHeaders(); List<String> values = new ArrayList<>(); values.add("ID=JOEBLOGGS; version=1; Path=" + URI_PATH); values.add("NEW_JSESSIONID=" + (SESSION_ID+1) + "; version=1; Path=" + URI_PATH +"; HttpOnly"); values.add("NEW_CUSTOMER=WILE_E_COYOTE2; version=1; Path=" + URI_PATH); respHeaders.put("Set-Cookie", values); values = new ArrayList<>(); values.add("COOKIE2_CUSTOMER=WILE_E_COYOTE2; version=1; Path=" + URI_PATH); respHeaders.put("Set-Cookie2", values); values.add("COOKIE2_JSESSIONID=" + (SESSION_ID+100) + "; version=1; Path=" + URI_PATH +"; HttpOnly"); respHeaders.put("Set-Cookie2", values); t.sendResponseHeaders(200, -1); t.close(); }
Example 13
Source File: ServerConnectionImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Override public void setResponseHeaders(Map<String,List<String>> headers) { Headers r = httpExchange.getResponseHeaders(); r.clear(); for(Map.Entry <String, List<String>> entry : headers.entrySet()) { String name = entry.getKey(); List<String> values = entry.getValue(); // ignore headers that interfere with our correct operations if (!"Content-Length".equalsIgnoreCase(name) && !"Content-Type".equalsIgnoreCase(name)) { r.put(name,new ArrayList<String>(values)); } } }
Example 14
Source File: HttpOnly.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Override public void handle(HttpExchange t) throws IOException { Headers reqHeaders = t.getRequestHeaders(); // some small sanity check List<String> cookies = reqHeaders.get("Cookie"); for (String cookie : cookies) { if (!cookie.contains("JSESSIONID") || !cookie.contains("WILE_E_COYOTE")) t.sendResponseHeaders(400, -1); } // return some cookies so we can check getHeaderField(s) Headers respHeaders = t.getResponseHeaders(); List<String> values = new ArrayList<>(); values.add("ID=JOEBLOGGS; version=1; Path=" + URI_PATH); values.add("NEW_JSESSIONID=" + (SESSION_ID+1) + "; version=1; Path=" + URI_PATH +"; HttpOnly"); values.add("NEW_CUSTOMER=WILE_E_COYOTE2; version=1; Path=" + URI_PATH); respHeaders.put("Set-Cookie", values); values = new ArrayList<>(); values.add("COOKIE2_CUSTOMER=WILE_E_COYOTE2; version=1; Path=" + URI_PATH); respHeaders.put("Set-Cookie2", values); values.add("COOKIE2_JSESSIONID=" + (SESSION_ID+100) + "; version=1; Path=" + URI_PATH +"; HttpOnly"); respHeaders.put("Set-Cookie2", values); t.sendResponseHeaders(200, -1); t.close(); }
Example 15
Source File: ServerConnectionImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override public void setResponseHeaders(Map<String,List<String>> headers) { Headers r = httpExchange.getResponseHeaders(); r.clear(); for(Map.Entry <String, List<String>> entry : headers.entrySet()) { String name = entry.getKey(); List<String> values = entry.getValue(); // ignore headers that interfere with our correct operations if (!"Content-Length".equalsIgnoreCase(name) && !"Content-Type".equalsIgnoreCase(name)) { r.put(name,new ArrayList<String>(values)); } } }
Example 16
Source File: HttpOnly.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override public void handle(HttpExchange t) throws IOException { Headers reqHeaders = t.getRequestHeaders(); // some small sanity check List<String> cookies = reqHeaders.get("Cookie"); for (String cookie : cookies) { if (!cookie.contains("JSESSIONID") || !cookie.contains("WILE_E_COYOTE")) t.sendResponseHeaders(400, -1); } // return some cookies so we can check getHeaderField(s) Headers respHeaders = t.getResponseHeaders(); List<String> values = new ArrayList<>(); values.add("ID=JOEBLOGGS; version=1; Path=" + URI_PATH); values.add("NEW_JSESSIONID=" + (SESSION_ID+1) + "; version=1; Path=" + URI_PATH +"; HttpOnly"); values.add("NEW_CUSTOMER=WILE_E_COYOTE2; version=1; Path=" + URI_PATH); respHeaders.put("Set-Cookie", values); values = new ArrayList<>(); values.add("COOKIE2_CUSTOMER=WILE_E_COYOTE2; version=1; Path=" + URI_PATH); respHeaders.put("Set-Cookie2", values); values.add("COOKIE2_JSESSIONID=" + (SESSION_ID+100) + "; version=1; Path=" + URI_PATH +"; HttpOnly"); respHeaders.put("Set-Cookie2", values); t.sendResponseHeaders(200, -1); t.close(); }
Example 17
Source File: ServerConnectionImpl.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Override public void setResponseHeaders(Map<String,List<String>> headers) { Headers r = httpExchange.getResponseHeaders(); r.clear(); for(Map.Entry <String, List<String>> entry : headers.entrySet()) { String name = entry.getKey(); List<String> values = entry.getValue(); // ignore headers that interfere with our correct operations if (!"Content-Length".equalsIgnoreCase(name) && !"Content-Type".equalsIgnoreCase(name)) { r.put(name,new ArrayList<String>(values)); } } }
Example 18
Source File: HttpOnly.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Override public void handle(HttpExchange t) throws IOException { Headers reqHeaders = t.getRequestHeaders(); // some small sanity check List<String> cookies = reqHeaders.get("Cookie"); for (String cookie : cookies) { if (!cookie.contains("JSESSIONID") || !cookie.contains("WILE_E_COYOTE")) t.sendResponseHeaders(400, -1); } // return some cookies so we can check getHeaderField(s) Headers respHeaders = t.getResponseHeaders(); List<String> values = new ArrayList<>(); values.add("ID=JOEBLOGGS; version=1; Path=" + URI_PATH); values.add("NEW_JSESSIONID=" + (SESSION_ID+1) + "; version=1; Path=" + URI_PATH +"; HttpOnly"); values.add("NEW_CUSTOMER=WILE_E_COYOTE2; version=1; Path=" + URI_PATH); respHeaders.put("Set-Cookie", values); values = new ArrayList<>(); values.add("COOKIE2_CUSTOMER=WILE_E_COYOTE2; version=1; Path=" + URI_PATH); respHeaders.put("Set-Cookie2", values); values.add("COOKIE2_JSESSIONID=" + (SESSION_ID+100) + "; version=1; Path=" + URI_PATH +"; HttpOnly"); respHeaders.put("Set-Cookie2", values); t.sendResponseHeaders(200, -1); t.close(); }
Example 19
Source File: ServerConnectionImpl.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override public void setResponseHeaders(Map<String,List<String>> headers) { Headers r = httpExchange.getResponseHeaders(); r.clear(); for(Map.Entry <String, List<String>> entry : headers.entrySet()) { String name = entry.getKey(); List<String> values = entry.getValue(); // ignore headers that interfere with our correct operations if (!"Content-Length".equalsIgnoreCase(name) && !"Content-Type".equalsIgnoreCase(name)) { r.put(name,new ArrayList<String>(values)); } } }
Example 20
Source File: HttpOnly.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override public void handle(HttpExchange t) throws IOException { Headers reqHeaders = t.getRequestHeaders(); // some small sanity check List<String> cookies = reqHeaders.get("Cookie"); for (String cookie : cookies) { if (!cookie.contains("JSESSIONID") || !cookie.contains("WILE_E_COYOTE")) t.sendResponseHeaders(400, -1); } // return some cookies so we can check getHeaderField(s) Headers respHeaders = t.getResponseHeaders(); List<String> values = new ArrayList<>(); values.add("ID=JOEBLOGGS; version=1; Path=" + URI_PATH); values.add("NEW_JSESSIONID=" + (SESSION_ID+1) + "; version=1; Path=" + URI_PATH +"; HttpOnly"); values.add("NEW_CUSTOMER=WILE_E_COYOTE2; version=1; Path=" + URI_PATH); respHeaders.put("Set-Cookie", values); values = new ArrayList<>(); values.add("COOKIE2_CUSTOMER=WILE_E_COYOTE2; version=1; Path=" + URI_PATH); respHeaders.put("Set-Cookie2", values); values.add("COOKIE2_JSESSIONID=" + (SESSION_ID+100) + "; version=1; Path=" + URI_PATH +"; HttpOnly"); respHeaders.put("Set-Cookie2", values); t.sendResponseHeaders(200, -1); t.close(); }