Changeset cd64b06 for backend/GlobeGuru-backend/src/main/java/Server.java
- Timestamp:
- 01/11/25 01:23:10 (3 weeks ago)
- Branches:
- master
- Children:
- 0a7426e
- Parents:
- 1c51912
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
backend/GlobeGuru-backend/src/main/java/Server.java
r1c51912 rcd64b06 196 196 197 197 public static void sendResponse(HttpExchange exchange, int statusCode, String response) throws IOException { 198 byte[] responseBytes = response.getBytes(StandardCharsets.UTF_8); 198 199 exchange.getResponseHeaders().add("Cross-Origin-Opener-Policy", "unsafe-none"); 199 200 exchange.getResponseHeaders().add("Cross-Origin-Embedder-Policy", "require-corp"); 200 201 exchange.getResponseHeaders().add("Content-Type", "application/json"); 201 exchange.sendResponseHeaders(statusCode, response.length()); 202 exchange.getResponseBody().write(response.getBytes()); 203 exchange.getResponseBody().close(); 204 } 205 202 exchange.getResponseHeaders().add("Transfer-Encoding", "chunked"); 203 exchange.sendResponseHeaders(statusCode, 0); 204 try (OutputStream os = exchange.getResponseBody()) { 205 os.write(responseBytes); 206 } 207 } 206 208 } 207 209
Note:
See TracChangeset
for help on using the changeset viewer.