Skip to content

Commit

Permalink
Finished the documentation of the request.hpp file
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuki-cpp committed Aug 20, 2018
1 parent a9f496d commit 07fc0d1
Showing 1 changed file with 88 additions and 8 deletions.
96 changes: 88 additions & 8 deletions include/yukihttp/request.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class mime;


/**
* @brief A HTTP(s) response
* @brief HTTP(S) response
*
* \todo Fix error reporting. Separate cURL error to HTTP errors
*/
Expand Down Expand Up @@ -81,50 +81,130 @@ class request
* If verbose mode is enabled, debug information provided by cURL will be written on the stream provided to set_verbose_output(std::ostream & out) const.
* If set_verbose_output(std::ostream & out) const isn't called, then the output is printed to stdcerr instead.
*
* @param is_verbose : true if verbose mode should be enable, false if not.
* @param is_verbose : true if verbose mode should be enabled, false if not.
*/
void set_verbose(bool is_verbose) const;

/**
* @brief Set up the verbose output stream.
*
* @param out : Stream to use for verbose output.
*
* @param out : Stream to use for verbose output.
*/
void set_verbose_output(std::ostream & out) const;

/**
* @brief Enable or disable the progress meter.
*
* If the progress meter is enabled, the yuki::http::progress_callback set up by set_progress_callback(yuki::http::progress_callback & callback) const will be called periodically as the transfer advances.
* If set_progress_callback(yuki::http::progress_callback & callback) const isn't called, cURL progress callback is used instead.
*
* @param is_enabled : true if the progress meter should be enabled, false if not.
*/
void enable_progress_meter(bool is_enabled) const;


/**
* @brief Set up the callback used for the progress meter.
*
* @param callback : Callback handling the progress of the transfer.
*/
void set_progress_callback(yuki::http::progress_callback & callback) const;


/**
* @brief Set the timeout for request.
*
*
* @param ms : Timeout duration in milliseconds.
*/
void set_timeout(unsigned int ms) const;

/**
* @brief Set the user agent used for the request.
*
*
* @param ua : User agent to use.
*/
void set_user_agent(const std::string & ua) const;

void set_auth_username(const std::string & username) const;
void set_auth_password(const std::string & password) const;


/**
* @brief Set up an header for the request.
*
* Add a key:value pair to the headers of the request.
* If the key already exists, the old value is overwritten.
*
* @param name : key of the header
* @param value : value associated to the key
*/
void set_header(const std::string & name, const std::string & value);


/**
* @brief Execute a GET request on the URL set up by request(const std::string & url).
*
* @return yuki::http::response
*/
yuki::http::response GET() const;

/**
* @brief Execute a HEAD request on the URL set up by request(const std::string & url).
*
* @return yuki::http::response
*/
yuki::http::response HEAD() const;

/**
* @brief Execute a DELETE request on the URL set up by request(const std::string & url).
*
* @return yuki::http::response
*/
yuki::http::response DELETE() const;


/**
* @brief Execute a POST on the URL set up by request(const std::string & url).
*
* The POST data is directly given by the user. For mime request forms, see yuki::http::response POST(const yuki::http::mime & mime_data) const.
*
* @param data : POST field data
* @return yuki::http::response
*/
yuki::http::response POST(const std::string & data) const;


/**
* @brief Execute a POST on the URL set up by request(const std::string & url).
*
* The POST data is generated from a provided MIME form.
*
* @param mime_data : mime data used to generate the request.
* @return yuki::http::response
*/
yuki::http::response POST(const yuki::http::mime & mime_data) const;

private:
/**
* @brief Actually execute the request.
*
* Set up the headers based on m_headers_map and execute the request.
*
* @return yuki::http::response The response to the request.
*/
yuki::http::response execute_request() const;

/**
* @brief cURL handle
*
* This handle is managed by this class. Be careful with it.
*/
void* m_handle = nullptr;

/**
* @brief Headers to be used by the request.
*
*/
yuki::http::headers_t m_headers_map;
};

Expand Down

0 comments on commit 07fc0d1

Please sign in to comment.