[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/etr/libhttpserver/master/src/httpserver/create_test_request.hpp [Back]  [Original]

/*
     This file is part of libhttpserver
     Copyright (C) 2011-2019 Sebastiano Merlino

     This library 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 2.1 of the License, or (at your option) any later version.

     This library 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
     Lesser General Public License for more details.

     You should have received a copy of the GNU Lesser General Public
     License along with this library; if not, write to the Free Software
     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
     USA
*/

#if !defined (_HTTPSERVER_HPP_INSIDE_) && !defined (HTTPSERVER_COMPILATION)
#error "Only  or  can be included directly."
#endif

#ifndef SRC_HTTPSERVER_CREATE_TEST_REQUEST_HPP_
#define SRC_HTTPSERVER_CREATE_TEST_REQUEST_HPP_

#include 
#include 
#include 

#include "httpserver/http_request.hpp"
#include "httpserver/http_utils.hpp"

namespace httpserver {

class create_test_request {
 public:
    create_test_request() = default;

    create_test_request& method(const std::string& method) {
        _method = method;
        return *this;
    }

    create_test_request& path(const std::string& path) {
        _path = path;
        return *this;
    }

    create_test_request& version(const std::string& version) {
        _version = version;
        return *this;
    }

    create_test_request& content(const std::string& content) {
        _content = content;
        return *this;
    }

    create_test_request& header(const std::string& key, const std::string& value) {
        _headers[key] = value;
        return *this;
    }

    create_test_request& footer(const std::string& key, const std::string& value) {
        _footers[key] = value;
        return *this;
    }

    create_test_request& cookie(const std::string& key, const std::string& value) {
        _cookies[key] = value;
        return *this;
    }

    create_test_request& arg(const std::string& key, const std::string& value) {
        _args[key].push_back(value);
        return *this;
    }

    create_test_request& querystring(const std::string& querystring) {
        _querystring = querystring;
        return *this;
    }

    // Setters are unconditional. On HAVE_BAUTH-off /
    // HAVE_DAUTH-off builds the values are silently dropped on .build()
    // (matching the sentinel-empty contract of the corresponding
    // http_request accessors).
    create_test_request& user(const std::string& user) {
        _user = user;
        return *this;
    }

    create_test_request& pass(const std::string& pass) {
        _pass = pass;
        return *this;
    }

    create_test_request& digested_user(const std::string& digested_user) {
        _digested_user = digested_user;
        return *this;
    }

    create_test_request& requestor(const std::string& requestor) {
        _requestor = requestor;
        return *this;
    }

    create_test_request& requestor_port(uint16_t port) {
        _requestor_port = port;
        return *this;
    }

    // Setter is unconditional. On HAVE_GNUTLS-off builds the
    // value is silently dropped (has_tls_session() returns false
    // regardless  documented sentinel contract).
    create_test_request& tls_enabled(bool enabled = true) {
        _tls_enabled = enabled;
        return *this;
    }

    // Opt out of the default credential-redaction policy in
    // http_request::operator

Web Proxy Viewer  |  New URL  |  Original Page