MXS-2208 Address review comments
Also report errors in more detailed manner.
This commit is contained in:
		@ -69,6 +69,13 @@ struct Config
 | 
			
		||||
 | 
			
		||||
struct Result
 | 
			
		||||
{
 | 
			
		||||
    enum
 | 
			
		||||
    {
 | 
			
		||||
        ERROR                = -1, // Some non-specific error occurred.
 | 
			
		||||
        COULDNT_RESOLVE_HOST = -2, // The specified host cold not be resolved.
 | 
			
		||||
        OPERATION_TIMEDOUT   = -3  // The operation timed out.
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    int                                code = 0; // HTTP response code
 | 
			
		||||
    std::string                        body;     // Response body
 | 
			
		||||
    std::map<std::string, std::string> headers;  // Headers attached to the response
 | 
			
		||||
@ -80,6 +87,9 @@ struct Result
 | 
			
		||||
 * @param url     The URL to GET.
 | 
			
		||||
 * @param config  The config to use.
 | 
			
		||||
 *
 | 
			
		||||
 * @note The @c url is assumed to be escaped in case it contain arguments
 | 
			
		||||
 *       that must be escaped.
 | 
			
		||||
 *
 | 
			
		||||
 * @return A @c Result.
 | 
			
		||||
 */
 | 
			
		||||
Result get(const std::string& url, const Config& config = Config());
 | 
			
		||||
@ -92,6 +102,9 @@ Result get(const std::string& url, const Config& config = Config());
 | 
			
		||||
 * @param password  Password for the user.
 | 
			
		||||
 * @param config    The config to use.
 | 
			
		||||
 *
 | 
			
		||||
 * @note The @c url is assumed to be escaped in case it contain arguments
 | 
			
		||||
 *       that must be escaped, but @c user and @c pass will always be escaped.
 | 
			
		||||
 *
 | 
			
		||||
 * @return A @c Result.
 | 
			
		||||
 */
 | 
			
		||||
Result get(const std::string& url,
 | 
			
		||||
@ -104,6 +117,9 @@ Result get(const std::string& url,
 | 
			
		||||
 * @param urls    The URLs to GET.
 | 
			
		||||
 * @param config  The config to use.
 | 
			
		||||
 *
 | 
			
		||||
 * @note The @c urls are assumed to be escaped in case they contain arguments
 | 
			
		||||
 *       that must be escaped.
 | 
			
		||||
 *
 | 
			
		||||
 * @return A @c Result.
 | 
			
		||||
 */
 | 
			
		||||
std::vector<Result> get(const std::vector<std::string>& urls,
 | 
			
		||||
@ -117,6 +133,9 @@ std::vector<Result> get(const std::vector<std::string>& urls,
 | 
			
		||||
 * @param password  Password for the user.
 | 
			
		||||
 * @param config    The config to use.
 | 
			
		||||
 *
 | 
			
		||||
 * @note The @c urls are assumed to be escaped in case they contain arguments
 | 
			
		||||
 *       that must be escaped, but @c user and @c pass will always be escaped.
 | 
			
		||||
 *
 | 
			
		||||
 * @return Vector of @c Results, as many as there were @c urls.
 | 
			
		||||
 */
 | 
			
		||||
std::vector<Result> get(const std::vector<std::string>& urls,
 | 
			
		||||
@ -259,6 +278,9 @@ const char* to_string(Async::status_t status);
 | 
			
		||||
 * @param urls      The URLs to GET.
 | 
			
		||||
 * @param config    The config to use.
 | 
			
		||||
 *
 | 
			
		||||
 * @note The @c urls are assumed to be escaped in case they contain arguments
 | 
			
		||||
 *       that must be escaped.
 | 
			
		||||
 *
 | 
			
		||||
 * @return An Async instance using which the operation can be performed.
 | 
			
		||||
 */
 | 
			
		||||
Async get_async(const std::vector<std::string>& urls,
 | 
			
		||||
@ -272,6 +294,9 @@ Async get_async(const std::vector<std::string>& urls,
 | 
			
		||||
 * @param password  Password for the user.
 | 
			
		||||
 * @param config    The config to use.
 | 
			
		||||
 *
 | 
			
		||||
 * @note The @c urls are assumed to be escaped in case they contains arguments
 | 
			
		||||
 *       that must be escaped, but @c user and @c pass will always be escaped.
 | 
			
		||||
 *
 | 
			
		||||
 * @return An Async instance using which the operation can be performed.
 | 
			
		||||
 */
 | 
			
		||||
Async get_async(const std::vector<std::string>& urls,
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user