VirtualBox

Changeset 73977 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Aug 30, 2018 12:13:02 PM (6 years ago)
Author:
vboxsync
Message:

IPRT/rest: More request array and map setter methods. Fixed string defaults. Safer copying and resetToDefaults. bugref:9167

Location:
trunk/src/VBox/Runtime
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/rest/RTCRestArrayBase.cpp

    r73968 r73977  
    2929*   Header Files                                                                                                                 *
    3030*********************************************************************************************************************************/
     31#define LOG_GROUP RTLOGGROUP_REST
    3132#include <iprt/cpp/restbase.h>
    3233
     
    8384*********************************************************************************************************************************/
    8485
    85 void RTCRestArrayBase::resetToDefault()
     86int RTCRestArrayBase::resetToDefault()
    8687{
    8788    /* The default state of an array is empty. At least for now. */
    8889    clear();
     90    return VINF_SUCCESS;
    8991}
    9092
  • trunk/src/VBox/Runtime/common/rest/RTCRestClientApiBase.cpp

    r73967 r73977  
    2929*   Header Files                                                                                                                 *
    3030*********************************************************************************************************************************/
     31#define LOG_GROUP RTLOGGROUP_REST
    3132#include <iprt/cpp/restbase.h>
    3233
    3334#include <iprt/err.h>
    3435#include <iprt/http.h>
     36#include <iprt/log.h>
    3537
    3638
     
    6264
    6365void RTCRestClientApiBase::doCall(RTCRestClientRequestBase const &a_rRequest, RTHTTPMETHOD a_enmHttpMethod,
    64                                   RTCRestClientResponseBase *a_pResponse)
     66                                  RTCRestClientResponseBase *a_pResponse, const char *a_pszMethod)
    6567{
     68    LogFlow(("doCall: %s %s\n", a_pszMethod, RTHttpMethodName(a_enmHttpMethod)));
     69
    6670    /*
    6771     * Initialize the HTTP instance.
     
    155159    }
    156160    a_pResponse->receiveComplete(rc, hHttp);
     161    RT_NOREF_PV(a_pszMethod);
    157162}
    158163
  • trunk/src/VBox/Runtime/common/rest/RTCRestClientRequestBase.cpp

    r73918 r73977  
    2929*   Header Files                                                                                                                 *
    3030*********************************************************************************************************************************/
     31#define LOG_GROUP RTLOGGROUP_REST
    3132#include <iprt/cpp/restbase.h>
    3233
     
    3738/**
    3839 * Default constructor.
    39  *  */
     40 */
    4041RTCRestClientRequestBase::RTCRestClientRequestBase()
     42    : m_fIsSet(0)
     43    , m_fErrorSet(0)
    4144{
    42     /* nothing to do */
     45}
     46
     47
     48/**
     49 * Copy constructor.
     50 */
     51RTCRestClientRequestBase::RTCRestClientRequestBase(RTCRestClientRequestBase const &a_rThat)
     52    : m_fIsSet(a_rThat.m_fIsSet)
     53    , m_fErrorSet(a_rThat.m_fErrorSet)
     54{
    4355}
    4456
     
    5062{
    5163    /* nothing to do */
     64}
     65
     66
     67/**
     68 * Copy assignment operator.
     69 */
     70RTCRestClientRequestBase &RTCRestClientRequestBase::operator=(RTCRestClientRequestBase const &a_rThat)
     71{
     72    m_fIsSet    = a_rThat.m_fIsSet;
     73    m_fErrorSet = a_rThat.m_fErrorSet;
     74    return *this;
    5275}
    5376
  • trunk/src/VBox/Runtime/common/rest/RTCRestClientResponseBase.cpp

    r73968 r73977  
    2929*   Header Files                                                                                                                 *
    3030*********************************************************************************************************************************/
     31#define LOG_GROUP RTLOGGROUP_REST
    3132#include <iprt/cpp/restbase.h>
    3233
  • trunk/src/VBox/Runtime/common/rest/RTCRestJsonPrimaryCursor.cpp

    r73875 r73977  
    2929*   Header Files                                                                                                                 *
    3030*********************************************************************************************************************************/
     31#define LOG_GROUP RTLOGGROUP_REST
    3132#include <iprt/cpp/restbase.h>
    3233
  • trunk/src/VBox/Runtime/common/rest/RTCRestOutputToString.cpp

    r73956 r73977  
    2929*   Header Files                                                                                                                 *
    3030*********************************************************************************************************************************/
     31#define LOG_GROUP RTLOGGROUP_REST
    3132#include <iprt/cpp/restbase.h>
    3233
  • trunk/src/VBox/Runtime/common/rest/RTCRestStringMapBase.cpp

    r73965 r73977  
    2929*   Header Files                                                                                                                 *
    3030*********************************************************************************************************************************/
     31#define LOG_GROUP RTLOGGROUP_REST
    3132#include <iprt/cpp/restbase.h>
    3233
     
    7273*********************************************************************************************************************************/
    7374
    74 void RTCRestStringMapBase::resetToDefault()
     75int RTCRestStringMapBase::resetToDefault()
    7576{
    7677    /* Default is an empty map. */
    7778    clear();
     79    return VINF_SUCCESS;
    7880}
    7981
  • trunk/src/VBox/Runtime/common/rest/rest-primary-object-types.cpp

    r73956 r73977  
    2929*   Header Files                                                                                                                 *
    3030*********************************************************************************************************************************/
     31#define LOG_GROUP RTLOGGROUP_REST
    3132#include <iprt/cpp/restbase.h>
    3233
     
    143144
    144145
    145 void RTCRestBool::resetToDefault()
     146int RTCRestBool::assignCopy(RTCRestBool const &a_rThat)
     147{
     148    m_fValue = a_rThat.m_fValue;
     149    return VINF_SUCCESS;
     150}
     151
     152
     153int RTCRestBool::resetToDefault()
    146154{
    147155    m_fValue = false;
     156    return VINF_SUCCESS;
    148157}
    149158
     
    265274
    266275
    267 void RTCRestInt64::resetToDefault()
     276int RTCRestInt64::assignCopy(RTCRestInt64 const &a_rThat)
     277{
     278    m_iValue = a_rThat.m_iValue;
     279    return VINF_SUCCESS;
     280}
     281
     282
     283int RTCRestInt64::resetToDefault()
    268284{
    269285    m_iValue = 0;
     286    return VINF_SUCCESS;
    270287}
    271288
     
    375392
    376393
    377 void RTCRestInt32::resetToDefault()
     394int RTCRestInt32::assignCopy(RTCRestInt32 const &a_rThat)
     395{
     396    m_iValue = a_rThat.m_iValue;
     397    return VINF_SUCCESS;
     398}
     399
     400
     401int RTCRestInt32::resetToDefault()
    378402{
    379403    m_iValue = 0;
     404    return VINF_SUCCESS;
    380405}
    381406
     
    491516
    492517
    493 void RTCRestInt16::resetToDefault()
     518int RTCRestInt16::assignCopy(RTCRestInt16 const &a_rThat)
     519{
     520    m_iValue = a_rThat.m_iValue;
     521    return VINF_SUCCESS;
     522}
     523
     524
     525int RTCRestInt16::resetToDefault()
    494526{
    495527    m_iValue = 0;
     528    return VINF_SUCCESS;
    496529}
    497530
     
    598631
    599632
    600 void RTCRestDouble::resetToDefault()
     633/** Copy assignment operator. */
     634RTCRestDouble &RTCRestDouble::operator=(RTCRestDouble const &a_rThat)
     635{
     636    m_rdValue = a_rThat.m_rdValue;
     637    return *this;
     638}
     639
     640
     641int RTCRestDouble::assignCopy(RTCRestDouble const &a_rThat)
     642{
     643    m_rdValue = a_rThat.m_rdValue;
     644    return VINF_SUCCESS;
     645}
     646
     647
     648int RTCRestDouble::resetToDefault()
    601649{
    602650    m_rdValue = 0.0;
     651    return VINF_SUCCESS;
    603652}
    604653
     
    715764
    716765
    717 void RTCRestString::resetToDefault()
     766int RTCRestString::assignCopy(RTCString const &a_rThat)
     767{
     768    return assignNoThrow(a_rThat);
     769}
     770
     771
     772int RTCRestString::assignCopy(const char *a_pszThat)
     773{
     774    return assignNoThrow(a_pszThat);
     775}
     776
     777
     778int RTCRestString::resetToDefault()
    718779{
    719780    setNull();
     781    return VINF_SUCCESS;
    720782}
    721783
  • trunk/src/VBox/Runtime/generic/http-curl.cpp

    r73967 r73977  
    22/** @file
    33 * IPRT - HTTP client API, cURL based.
     4 *
     5 * Logging groups:
     6 *      Log4 - request headers.
     7 *      Log5 - request body.
     8 *      Log6 - response headers.
     9 *      Log7 - response body.
    410 */
    511
     
    28742880    AssertPtrReturn(pszUrl, VERR_INVALID_POINTER);
    28752881
     2882#ifdef LOG_ENABLED
     2883    if (LogIs6Enabled() && pThis->pHeaders)
     2884    {
     2885        Log4(("RTHttpPerform: headers:\n"));
     2886        for (struct curl_slist const *pCur = pThis->pHeaders; pCur; pCur = pCur->next)
     2887            Log4(("%s", pCur->data));
     2888    }
     2889    if (pvReqBody && cbReqBody)
     2890        Log5(("RTHttpPerform: request body:\n%.*Rhxd\n", cbReqBody, pvReqBody));
     2891#endif
     2892
    28762893    /*
    28772894     * Set the busy flag (paranoia).
     
    28872904    if (RT_SUCCESS(rc))
    28882905    {
    2889 
    2890         /* HTTP method. */
     2906        /* Set the HTTP method. */
    28912907        int rcCurl = 1;
    28922908        switch (enmMethod)
     
    29702986                if (ppvHeaders)
    29712987                {
     2988                    Log(("RTHttpPerform: headers: %zx bytes (allocated %zx)\n",
     2989                         pThis->HeadersOutput.uData.Mem.cb, pThis->HeadersOutput.uData.Mem.cbAllocated));
     2990                    Log6(("RTHttpPerform: headers blob:\n%.*Rhxd\n", pThis->HeadersOutput.uData.Mem.cb, pThis->HeadersOutput.uData.Mem.pb));
    29722991                    *ppvHeaders = pThis->HeadersOutput.uData.Mem.pb;
    29732992                    *pcbHeaders = pThis->HeadersOutput.uData.Mem.cb;
    29742993                    pThis->HeadersOutput.uData.Mem.pb = NULL;
    2975                     Log(("RTHttpPerform: headers: %zx bytes (allocated %zx)\n",
    2976                          pThis->HeadersOutput.uData.Mem.cb, pThis->HeadersOutput.uData.Mem.cbAllocated));
    29772994                }
    29782995                if (ppvBody)
    29792996                {
     2997                    Log(("RTHttpPerform: body: %zx bytes (allocated %zx)\n",
     2998                         pThis->BodyOutput.uData.Mem.cb, pThis->BodyOutput.uData.Mem.cbAllocated));
     2999                    Log7(("RTHttpPerform: body blob:\n%.*Rhxd\n", pThis->BodyOutput.uData.Mem.cb, pThis->BodyOutput.uData.Mem.pb));
    29803000                    *ppvBody = pThis->BodyOutput.uData.Mem.pb;
    29813001                    *pcbBody = pThis->BodyOutput.uData.Mem.cb;
    29823002                    pThis->BodyOutput.uData.Mem.pb = NULL;
    2983                     Log(("RTHttpPerform: body: %zx bytes (allocated %zx)\n",
    2984                          pThis->HeadersOutput.uData.Mem.cb, pThis->HeadersOutput.uData.Mem.cbAllocated));
    29853003                }
    29863004            }
     
    30043022
    30053023
     3024RTR3DECL(const char *) RTHttpMethodName(RTHTTPMETHOD enmMethod)
     3025{
     3026    switch (enmMethod)
     3027    {
     3028        case RTHTTPMETHOD_INVALID:  return "invalid";
     3029        case RTHTTPMETHOD_GET:      return "GET";
     3030        case RTHTTPMETHOD_PUT:      return "PUT";
     3031        case RTHTTPMETHOD_POST:     return "POST";
     3032        case RTHTTPMETHOD_PATCH:    return "PATCH";
     3033        case RTHTTPMETHOD_DELETE:   return "DELETE";
     3034        case RTHTTPMETHOD_HEAD:     return "HEAD";
     3035        case RTHTTPMETHOD_OPTIONS:  return "OPTIONS";
     3036        case RTHTTPMETHOD_TRACE:    return "TRACE";
     3037
     3038        case RTHTTPMETHOD_END:
     3039        case RTHTTPMETHOD_32BIT_HACK:
     3040            break;
     3041    }
     3042    return "unknown";
     3043}
     3044
     3045
    30063046/*********************************************************************************************************************************
    30073047*   Callback APIs.                                                                                                               *
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette