SFML

- Main Page
- Modules
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Friends | List of all members
sf::Http::Request Class Reference

Define a HTTP request. More...

`#include <Http.hpp>`

## Public Types
enum | Method { Get, Post, Head }
| Enumerate the available HTTP methods for a request. More...

## Public Member Functions
| Request (const std::string &uri="/", Method method=Get, const std::string &body="")
| Default constructor. More...
void | setField (const std::string &field, const std::string &value)
| Set the value of a field. More...
void | setMethod (Method method)
| Set the request method. More...
void | setUri (const std::string &uri)
| Set the requested URI. More...
void | setHttpVersion (unsigned int major, unsigned int minor)
| Set the HTTP version for the request. More...
void | setBody (const std::string &body)
| Set the body of the request. More...

## Friends
class | Http

## Detailed Description

Define a HTTP request.

Definition at line 54 of file Http.hpp.

## Member Enumeration Documentation

enum sf::Http::Request::Method

Enumerate the available HTTP methods for a request.

Enumerator
Get | Request in get mode, standard method to retrieve a page.
Post | Request in post mode, usually to send data to a page.
Head | Request a page's header only.

Definition at line 62 of file Http.hpp.

## Constructor & Destructor Documentation

sf::Http::Request::Request | ( | const std::string & | uri = `"/"`,
|  | Method | method = `Get`,
|  | const std::string & | body = `""`
| ) |  |

Default constructor.

This constructor creates a GET request, with the root URI ("/") and an empty body.

Parameters

  uri | Target URI
  method | Method to use for the request
  body | Content of the request's body

## Member Function Documentation

void sf::Http::Request::setBody | ( | const std::string & | body) |  |

Set the body of the request.

The body of a request is optional and only makes sense for POST requests. It is ignored for all other methods. The body is empty by default.

Parameters

  body | Content of the body

void sf::Http::Request::setField | ( | const std::string & | field,
|  | const std::string & | value
| ) |  |

Set the value of a field.

The field is created if it doesn't exist. The name of the field is case insensitive. By default, a request doesn't contain any field (but the mandatory fields are added later by the HTTP client when sending the request).

Parameters

  field | Name of the field to set
  value | Value of the field

void sf::Http::Request::setHttpVersion | ( | unsigned int | major,
|  | unsigned int | minor
| ) |  |

Set the HTTP version for the request.

The HTTP version is 1.0 by default.

Parameters

  major | Major HTTP version number
  minor | Minor HTTP version number

void sf::Http::Request::setMethod | ( | Method | method) |  |

Set the request method.

See the Method enumeration for a complete list of all the availale methods. The method is Http::Request::Get by default.

Parameters

  method | Method to use for the request

void sf::Http::Request::setUri | ( | const std::string & | uri) |  |

Set the requested URI.

The URI is the resource (usually a web page or a file) that you want to get or post. The URI is "/" (the root page) by default.

Parameters

  uri | URI to request, relative to the host

The documentation for this class was generated from the following file:

- Http.hpp