コード例 #1
0
    http::client::response _GetResponse(HttpRequestMethod requestMethod,
                                        http::client::request& request,
                                        const string& requestBody = "")
    {
        auto getResponse = [&]()
            {
                switch (requestMethod)
                {
                    case HttpRequestMethod::Get:
                        return _client->get(request);

                    case HttpRequestMethod::Post:
                        return _client->post(request, requestBody);

                    case HttpRequestMethod::Delete:
                        return _client->delete_(request);
                }

                throw runtime_error("HTTP request not implemented");
            };

        http::client::response response = getResponse();
        if (status(response) == http_response::forbidden && (!_accessToken.empty()))
        {
            _accessToken = _GetAccessToken(_refreshToken);

            string headerKey = "Authorization";
            request.remove_header(headerKey);
            request << header(headerKey, _GetAuthorizationHeader());

            response = getResponse();
        }

        return response;
    }
コード例 #2
0
 void RemoveHeader(cr_string n){
     request_.remove_header(n.to_string());
 }