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

cz.jalasoft.net.http.HttpRequest Maven / Gradle / Ivy

There is a newer version: 1.0.5
Show newest version
package cz.jalasoft.net.http;

import java.net.URI;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by honzales on 18.5.15.
 */
public abstract class HttpRequest> {

    private URI uri;
    private final Map headers = new HashMap<>();

    public final T to(URIBuilder uriBuilder) {
        return to(uriBuilder.build());
    }

    public final T to(URI uri) {

        this.uri = uri;
        return getThis();
    }

    protected URI uri() {
        return uri;
    }

    public final T header(String key, String value) {
        if (key == null || key.isEmpty()) {
            throw new IllegalArgumentException("Header key must not be null or empty.");
        }
        if (value == null || value.isEmpty()) {
            throw new IllegalArgumentException("Header value must not be null or empty");
        }
        headers.put(key, value);
        return getThis();
    }

    protected final Map headers() {
        return headers;
    }

    abstract T getThis();

    public abstract HttpResponse send();

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy