Something went wrong. Try again.
Library for my mods and adding supporter perks
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950/* * Copyright 2026 macuguita * * Licensed under the EUPL, Version 1.2 or – as soon they will be approved by * the European Commission - subsequent versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the Licence. * You may obtain a copy of the Licence at: * * https://joinup.ec.europa.eu/software/page/eupl * * Unless required by applicable law or agreed to in writing, software * distributed under the Licence is distributed on an "AS IS" basis, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the Licence for the specific language governing permissions and * limitations under the Licence. */package com.macuguita.lib.impl.net;
import java.net.URI;import java.net.http.HttpClient;import java.net.http.HttpRequest;import java.time.Duration;
import com.macuguita.lib.impl.MacuLib;
public final class HttpHelper {
private static final HttpClient CLIENT = HttpClient.newBuilder() .connectTimeout(Duration.ofSeconds(5)) .build(); private static final Duration DEFAULT_REQUEST_TIMEOUT = Duration.ofMillis(5000);
private HttpHelper() {}
public static HttpClient client() { return CLIENT; }
public static HttpRequest.Builder get(URI uri, Duration timeout) { return HttpRequest.newBuilder(uri) .GET() .header("User-Agent", MacuLib.USER_AGENT) .timeout(timeout); }
public static HttpRequest.Builder get(URI uri) { return get(uri, DEFAULT_REQUEST_TIMEOUT); }}