Main MRPT website > C++ reference for MRPT 1.4.0
net_utils.h
Go to the documentation of this file.
1/* +---------------------------------------------------------------------------+
2 | Mobile Robot Programming Toolkit (MRPT) |
3 | http://www.mrpt.org/ |
4 | |
5 | Copyright (c) 2005-2016, Individual contributors, see AUTHORS file |
6 | See: http://www.mrpt.org/Authors - All rights reserved. |
7 | Released under BSD License. See details in http://www.mrpt.org/License |
8 +---------------------------------------------------------------------------+ */
9#ifndef MRPT_NET_UTILS_H
10#define MRPT_NET_UTILS_H
11
15
16namespace mrpt
17{
18 namespace utils
19 {
20 /** A set of useful routines for networking. (in #include <mrpt/utils/net_utils.h>)
21 * \ingroup network_grp
22 */
23 namespace net
24 {
25 /** \addtogroup network_grp
26 * @{ */
27
28 using std::string;
29
30 /** Possible returns from a HTTP request.
31 */
33 erOk = 0,
38 };
39
40 /** Perform an HTTP GET operation (version for retrieving the data as a vector_byte)
41 * \param url Must be a simple string of the form "http://<servername>/<relative-address>".
42 * \param port The server port, if different from 80.
43 * \param extra_headers If provided, the given extra HTTP headers will be sent.
44 * \param out_errormsg On exit will contain a description of the error or "Ok".
45 * \param out_content The buffer with the retrieved data.
46 * \param out_http_responsecode If provided, will hold the HTTP code, eg: 200, 404...
47 * \param out_headers If provided, a copy of all the headers returned by the server will be saved here.
48 * \param auth_user Send a basic HTTP authorization request with the given user & password.
49 * \param auth_pass Send a basic HTTP authorization request with the given user & password.
50 *
51 * \return The error or success code.
52 * \sa mrpt::utils::vectorToBinaryFile
53 */
56 const string &url,
57 vector_byte &out_content,
58 string &out_errormsg,
59 int port = 80,
60 const string &auth_user = string(),
61 const string &auth_pass = string(),
62 int *out_http_responsecode = NULL,
63 mrpt::utils::TParameters<string> *extra_headers = NULL,
64 mrpt::utils::TParameters<string> *out_headers = NULL,
65 int timeout_ms = 1000
66 );
67
68 /** Perform an HTTP GET operation (version for retrieving the data as text)
69 * \param url Must be a simple string of the form "http://<servername>/<relative-address>".
70 * \param port The server port, if different from 80.
71 * \param extra_headers If provided, the given extra HTTP headers will be sent.
72 * \param out_errormsg On exit will contain a description of the error or "Ok".
73 * \param out_content The buffer with the retrieved data.
74 * \param out_http_responsecode If provided, will hold the HTTP code, eg: 200, 404...
75 * \param out_headers If provided, a copy of all the headers returned by the server will be saved here.
76 * \param auth_user Send a basic HTTP authorization request with the given user & password.
77 * \param auth_pass Send a basic HTTP authorization request with the given user & password.
78 *
79 * \return The error or success code.
80 * \sa mrpt::utils::vectorToBinaryFile
81 */
84 const string &url,
85 string &out_content,
86 string &out_errormsg,
87 int port = 80,
88 const string &auth_user = string(),
89 const string &auth_pass = string(),
90 int *out_http_responsecode = NULL,
91 mrpt::utils::TParameters<string> *extra_headers = NULL,
92 mrpt::utils::TParameters<string> *out_headers = NULL,
93 int timeout_ms = 1000
94 );
95
96
97 /** Resolve a server address by its name, returning its IP address as a string - This method has a timeout for the maximum time to wait for the DNS server.
98 * For example: server_name="www.google.com" -> out_ip="209.85.227.99"
99 *
100 * \return true on success, false on timeout or other error.
101 */
103 const std::string &server_name,
104 std::string &out_ip,
105 const unsigned int timeout_ms = 3000
106 );
107
108 /** Returns a description of the last Sockets error */
110
111 /** @} */ // end grouping
112
113 } // End of namespace
114 } // End of namespace
115} // end of namespace
116
117#endif
std::vector< uint8_t > vector_byte
Definition: types_simple.h:26
ERRORCODE_HTTP
Possible returns from a HTTP request.
Definition: net_utils.h:32
bool BASE_IMPEXP DNS_resolve_async(const std::string &server_name, std::string &out_ip, const unsigned int timeout_ms=3000)
Resolve a server address by its name, returning its IP address as a string - This method has a timeou...
std::string BASE_IMPEXP getLastSocketErrorStr()
Returns a description of the last Sockets error.
ERRORCODE_HTTP BASE_IMPEXP http_get(const string &url, vector_byte &out_content, string &out_errormsg, int port=80, const string &auth_user=string(), const string &auth_pass=string(), int *out_http_responsecode=NULL, mrpt::utils::TParameters< string > *extra_headers=NULL, mrpt::utils::TParameters< string > *out_headers=NULL, int timeout_ms=1000)
Perform an HTTP GET operation (version for retrieving the data as a vector_byte)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
For usage when passing a dynamic number of (numeric) arguments to a function, by name.
Definition: TParameters.h:47



Page generated by Doxygen 1.9.6 for MRPT 1.4.0 SVN: at Tue Jan 17 22:40:29 UTC 2023