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

io.ultreia.java4all.http.HRequest Maven / Gradle / Ivy

There is a newer version: 2.0.6
Show newest version
package io.ultreia.java4all.http;

/*
 * #%L
 * Http :: Api
 * %%
 * Copyright (C) 2017 - 2020 Ultreia.io
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Lesser Public License for more details.
 *
 * You should have received a copy of the GNU General Lesser Public
 * License along with this program.  If not, see
 * .
 * #L%
 */

import java.io.File;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.apache.http.NameValuePair;

/**
 * Created on 06/09/15.
 *
 * @author Tony Chemit - [email protected]
 */
public class HRequest {

    private final String requestMethod;

    private final String baseUrl;

    private final String contentType;

    private final String requestBody;

    private final Map headers;

    private final List parameters;

    private final Map files;

    private final long timeout;
    private final long socketTimeout;
    private final boolean useMultipartForm;
    private final boolean quiet;

    HRequest(String requestMethod,
             String baseUrl,
             String requestBody,
             String contentType,
             Map header,
             List params,
             Map files,
             long timeout,
             long socketTimeout,
             boolean useMultipartForm,
             boolean quiet) {
        this.requestMethod = requestMethod;
        this.baseUrl = baseUrl;
        this.requestBody = requestBody;
        this.contentType = contentType;
        this.headers = Collections.unmodifiableMap(header);
        this.parameters = Collections.unmodifiableList(params);
        this.files = Collections.unmodifiableMap(files);
        this.timeout = timeout;
        this.socketTimeout = socketTimeout;
        this.useMultipartForm = useMultipartForm;
        this.quiet = quiet;
    }

    public String getRequestMethod() {
        return requestMethod;
    }

    public String getBaseUrl() {
        return baseUrl;
    }

    public String getContentType() {
        return contentType;
    }

    public String getRequestBody() {
        return requestBody;
    }

    public Map getHeaders() {
        return headers;
    }

    public List getParameters() {
        return parameters;
    }

    public Map getFiles() {
        return files;
    }

    public boolean withoutFiles() {
        return files.isEmpty();
    }

    public long getTimeout() {
        return timeout;
    }

    public boolean isUseMultipartForm() {
        return useMultipartForm;
    }

    public boolean isQuiet() {
        return quiet;
    }

    public long getSocketTimeout() {
        return socketTimeout;
    }

    @Override
    public String toString() {
        return String.format("[%S] %s", getRequestMethod(), getBaseUrl());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy