All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.dongliu.cute.http.Request Maven / Gradle / Ivy

The newest version!
package net.dongliu.cute.http;

import net.dongliu.cute.http.body.Body;
import org.checkerframework.checker.nullness.qual.Nullable;

import java.net.PasswordAuthentication;
import java.net.URL;
import java.nio.charset.Charset;
import java.time.Duration;
import java.util.List;
import java.util.Optional;

/**
 * Http request
 *
 * @author Liu Dong
 */
public class Request {
    private final Method method;
    private final List
headers; private final List cookies; private final List params; private final Charset urlEncoding; @Nullable private final Body body; private final boolean enableGzip; @Nullable private final PasswordAuthentication basicAuth; private final URL url; @Nullable private final String userAgent; @Nullable private final String referer; private final Duration timeout; Request(AbstractRequestBuilder builder) { method = builder.method; url = builder.url; headers = builder.headers; cookies = builder.cookies; userAgent = builder.userAgent; referer = builder.referer; urlEncoding = builder.urlEncoding; body = builder.body; enableGzip = builder.enableGzip; basicAuth = builder.basicAuth; params = builder.params; timeout = builder.timeout; } public Method method() { return method; } public List
headers() { return headers; } /** * The cookie set by user. */ public List cookies() { return cookies; } /** * The user set user-agent (in Client or in Request). If not any custom user-agent was set, return empty optional. */ public Optional userAgent() { return Optional.ofNullable(userAgent); } /** * The referer set by user. If not any custom user-agent was set, return empty optional. */ public Optional referer() { return Optional.ofNullable(referer); } /** * The charset used to encode params to url query string. */ public Charset urlEncoding() { return urlEncoding; } public Optional> body() { return Optional.ofNullable(body); } public boolean enableGzip() { return enableGzip; } /** * Basic auth for this request. * * @return if not exist, return empty Optional */ public Optional basicAuth() { return Optional.ofNullable(basicAuth); } public URL url() { return url; } public Duration timeout() { return timeout; } /** * Parameter to append to url. */ public List params() { return params; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy