initial commit

This commit is contained in:
Juul
2025-08-23 00:01:19 +02:00
commit 118278b139
3 changed files with 98 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
package org.example;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.zip.GZIPInputStream;
public class Main {
public static void main(String[] args) throws InterruptedException, IOException {
final URI uri = URI.create("https://coomer.st/api/v1/fansly/user/372647979531644928/posts");
HttpResponse<byte[]> response = makeRequest(uri);
decompress(response.body());
}
public static HttpResponse<byte[]> makeRequest(URI uri) throws IOException, InterruptedException {
HttpClient httpClient = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(uri)
.header("Accept", "text/css")
.header("Accept-Encoding", "gzip, deflate, br, zstd")
.build();
return httpClient.send(request, HttpResponse.BodyHandlers.ofByteArray());
}
public static void decompress(byte[] responseBody) throws IOException {
GZIPInputStream gzipInputStream = new GZIPInputStream(new ByteArrayInputStream(responseBody));
InputStreamReader reader = new InputStreamReader(gzipInputStream);
BufferedReader buffer = new BufferedReader(reader);
String line;
while((line = buffer.readLine()) != null) {
System.out.println(line);
}
}
}