Ignore:
Timestamp:
01/11/25 01:23:10 (3 weeks ago)
Author:
Kristijan <kristijanzafirovski26@…>
Branches:
master
Children:
0a7426e
Parents:
1c51912
Message:

Added info scraping for escape travel

File:
1 edited

Legend:

Unmodified
Added
Removed
  • backend/GlobeGuru-backend/src/main/java/Server.java

    r1c51912 rcd64b06  
    196196
    197197    public static void sendResponse(HttpExchange exchange, int statusCode, String response) throws IOException {
     198        byte[] responseBytes = response.getBytes(StandardCharsets.UTF_8);
    198199        exchange.getResponseHeaders().add("Cross-Origin-Opener-Policy", "unsafe-none");
    199200        exchange.getResponseHeaders().add("Cross-Origin-Embedder-Policy", "require-corp");
    200201        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    }
    206208}
    207209
Note: See TracChangeset for help on using the changeset viewer.