コード例 #1
0
 HeadersType GetHeaders(){
     HeadersType ret;
     for(auto h: request_.headers()){
         ret.push_back(h);
     }
     return ret;
 }
コード例 #2
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;
    }
コード例 #3
0
 void SetUriString(cr_string s){
     request_.uri(s.to_string());
 }
コード例 #4
0
 void SetBody(cr_string body){
    request_.body(body.to_string());
 }
コード例 #5
0
 std::string GetBody(){
     return request_.body();
 }
コード例 #6
0
 void RemoveHeader(cr_string n){
     request_.remove_header(n.to_string());
 }
コード例 #7
0
 void AddHeader(cr_string n,cr_string v){
     request_.add_header(std::make_pair(n.to_string(),v.to_string()));
 }
コード例 #8
0
  use_unknown<IUri> GetUri(){
     auto u = ImplementUri::create(request_.uri());
     return u.QueryInterface<IUri>();
 }
コード例 #9
0
    void SetUri(use_unknown<IUri> u){
        boost::network::uri::uri uri(u.ToString());

        request_.uri(uri);

    }