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

io.blitz.curl.sprint.Request Maven / Gradle / Ivy

package io.blitz.curl.sprint;

import java.util.Map;
import org.apache.commons.codec.binary.Base64;

/**
 * Represents the request object generated by the sprint. Contains all
 * of the headers and POST/PUT data, if any.
 * @author ghermeto
 */
public class Request {

    /**
     * The entire request line (GET / HTTP/1.1, for example)
     */
    private String line;
    
    /**
     * The method used in the request
     */
    private String method;
    
    /**
     * The URL, including path, query arguments and hash fragments
     */
    private String url;
    
    /**
     * All of the request headers (as a Map of name/value pairs)
     */
    private Map headers;
    
    /**
     * POST/PUT content, if any
     */
    private String content;

    public Request(String line, String method, String url, 
            Map headers, String content) {
        this.line = line;
        this.method = method;
        this.url = url;
        this.headers = headers;
        this.content = content;
    }

    public String getContent() {
        return (content == null) ? null : new String(Base64.decodeBase64(content.getBytes()));
    }

    public Map getHeaders() {
        return headers;
    }

    public String getLine() {
        return line;
    }

    public String getMethod() {
        return method;
    }

    public String getUrl() {
        return url;
    }
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy