Java Code Examples for com.sun.net.httpserver.Headers#get()
The following examples show how to use
com.sun.net.httpserver.Headers#get() .
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: ParkInetServer.java From Fourinone with Apache License 2.0 | 6 votes |
public void handle(HttpExchange exchange) throws IOException { String requestMethod = exchange.getRequestMethod(); if(requestMethod.equalsIgnoreCase("GET")) { Headers responseHeaders = exchange.getResponseHeaders(); responseHeaders.set("Content-Type", "text/plain"); exchange.sendResponseHeaders(HttpURLConnection.HTTP_OK, 0); OutputStream responseBody = exchange.getResponseBody(); Headers requestHeaders = exchange.getRequestHeaders(); Set<String> keySet = requestHeaders.keySet(); Iterator<String> iter = keySet.iterator(); while (iter.hasNext()){ String key = iter.next(); List values = requestHeaders.get(key); String s = key + " = " + values.toString() + "\n"; responseBody.write(s.getBytes()); } responseBody.close(); } }
Example 2
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(); }
Example 3
Source File: AuthHttpServer.java From swift-explorer with Apache License 2.0 | 5 votes |
@Override public void handle(HttpExchange exchange) throws IOException { String requestMethod = exchange.getRequestMethod(); if (requestMethod.equalsIgnoreCase("GET")) { Headers responseHeaders = exchange.getResponseHeaders(); responseHeaders.set("Content-Type", "text/plain"); exchange.sendResponseHeaders(200, 0); OutputStream responseBody = exchange.getResponseBody(); Headers requestHeaders = exchange.getRequestHeaders(); Set<String> keySet = requestHeaders.keySet(); Iterator<String> iter = keySet.iterator(); while (iter.hasNext()) { String key = iter.next(); List<String> values = requestHeaders.get(key); String s = key + " = " + values.toString() + "\n"; responseBody.write(s.getBytes()); } responseBody.close(); if (sharedQueue != null) { String query = exchange.getRequestURI().getQuery() ; try { sharedQueue.put(queryToParameterMap(query)); } catch (InterruptedException e) { logger.error("Error occurred in the server handler", e); } } } }
Example 4
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 5
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 6
Source File: AbstractHandler.java From mateplus with GNU General Public License v2.0 | 5 votes |
static String getHeader(HttpExchange exchange, String header) { Headers h = exchange.getRequestHeaders(); List<String> values = h.get(header); if (values == null || values.size() == 0) return null; return values.get(0); }
Example 7
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 8
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 9
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 10
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 11
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 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: 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 14
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 15
Source File: HTTPServer.java From learnjavabug with MIT License | 5 votes |
@Override public void handle(HttpExchange he) throws IOException { String requestMethod = he.getRequestMethod(); System.out.println(requestMethod + " " + he.getRequestURI().getPath() + ( StringUtils.isEmpty(he.getRequestURI().getRawQuery()) ? "" : "?" + he.getRequestURI().getRawQuery()) + " " + he.getProtocol()); if (requestMethod.equalsIgnoreCase("GET")) { Headers responseHeaders = he.getResponseHeaders(); responseHeaders.set("Content-Type", contentType == null ? "application/json" : contentType); he.sendResponseHeaders(200, 0); // parse request OutputStream responseBody = he.getResponseBody(); Headers requestHeaders = he.getRequestHeaders(); Set<String> keySet = requestHeaders.keySet(); Iterator<String> iter = keySet.iterator(); while (iter.hasNext()) { String key = iter.next(); List values = requestHeaders.get(key); String s = key + ": " + values.toString(); System.out.println(s); } System.out.println(); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(he.getRequestBody())); StringBuilder stringBuilder = new StringBuilder(); String line; for (;(line = bufferedReader.readLine()) != null;) { stringBuilder.append(line); } System.out.println(stringBuilder.toString()); byte[] bytes = Files.toByteArray(new File(filePath == null ? HTTPServer.class.getClassLoader().getResource(clazz).getPath() : filePath)); // send response responseBody.write(bytes); responseBody.close(); } }
Example 16
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 17
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 18
Source File: ParkInetServer.java From Fourinone with Apache License 2.0 | 4 votes |
public void handle(HttpExchange exchange) throws IOException { try{ boolean authflag = false; Headers hds = exchange.getRequestHeaders(); List<String> auth = hds.get("Authorization"); String requesturi = exchange.getRequestURI().getPath(); String requestparam = exchange.getRequestURI().getQuery(); //System.out.println(requesturi+",param:"+requestparam);//new String(.getBytes("UTF-8")) if(auth!=null){ String authstr = new String(ObjectBytes.decode(auth.get(0).split("\u0020")[1].toCharArray())); //System.out.println("Authorization:"+authstr); //System.out.println(ObjectBytes.encodeurl("root")); //System.out.println(ObjectBytes.decodeurl("cm9vdA%3D%3D")); if(authstr!=null){ String[] autharr = authstr.split("\u003A"); //System.out.println("autharr.length:"+autharr.length); if(autharr.length==2){ String authpwd = ConfigContext.getUsersConfig().getString(autharr[0]); if(authpwd!=null&&authpwd.equals(autharr[1])) authflag = true; } } //System.out.println("authflag:"+authflag); } Headers responseHeaders = exchange.getResponseHeaders(); responseHeaders.set("Content-Type", "text/html;charset=UTF-8"); String response = ""; if(authflag){ if(requesturi.equals(ConfigContext.getProp("REQFTTP"))) response = ConfigContext.getRequest(ConfigContext.getProp("RSPFTTPJSP")); else if(requesturi.equals(ConfigContext.getProp("REQGETFTTP"))&&requestparam!=null){ String[] rqsarrstr = requestparam.split("&"); String rqtid = rqsarrstr[0].replaceAll("tid=",""); String tid = ObjectBytes.getViewUtf8UrlString(rqtid);//getViewUrlString ObjectBytes.decodeReplace(tid); //System.out.println("requesttreeId:"+rqtid); //System.out.println("treeId:"+tid); int tn = Integer.parseInt(rqsarrstr[1].replaceAll("tn=","")); //System.out.println("tn:"+tn); String eid = rqsarrstr[2].replaceAll("eid=",""); response = getResponse(tid, tn, eid); } exchange.sendResponseHeaders(HttpURLConnection.HTTP_OK, 0); }else{ response = ConfigContext.getRequest(ConfigContext.getProp("RSPE401")); responseHeaders.set("WWW-Authenticate", "Basic realm='Fttp Admin'"); exchange.sendResponseHeaders(HttpURLConnection.HTTP_UNAUTHORIZED, response.length()); } OutputStream os = exchange.getResponseBody(); os.write(response.getBytes("UTF-8")); os.close(); }catch(Exception e){ LogUtil.info("[InetServer]", "[HandlerAuth]", e.getMessage()); throw new IOException(e); } }