VirtualBox

Changeset 74351 in vbox for trunk/include/iprt/cpp


Ignore:
Timestamp:
Sep 18, 2018 8:01:28 PM (6 years ago)
Author:
vboxsync
Message:

IPRT/rest: Redid the previous attempt at making sense of the basepath/host/url stuff. Tried to gear it a little in the direction of OpenAPI v3. bugref:9167

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/cpp/restclient.h

    r74348 r74351  
    638638     * @{ */
    639639    /**
    640      * Gets the default host (start of URL) as specified in the specs.
    641      *
     640     * Gets the server URL.
     641     */
     642    const char *getServerUrl(void) const;
     643
     644    /**
     645     * Sets the whole server URL.
     646     * @returns IPRT status code.
     647     * @param   a_pszUrl        The new server URL.  NULL/empty to reset to default.
     648     */
     649    int setServerUrl(const char *a_pszUrl);
     650
     651    /**
     652     * Sets the scheme part of the the server URL.
     653     * @returns IPRT status code.
     654     * @param   a_pszScheme     The new scheme.  Does not accept NULL or empty string.
     655     */
     656    int setServerScheme(const char *a_pszScheme);
     657
     658    /**
     659     * Sets the authority (hostname + port) part of the the server URL.
     660     * @returns IPRT status code.
     661     * @param   a_pszAuthority  The new authority.  Does not accept NULL or empty string.
     662     */
     663    int setServerAuthority(const char *a_pszAuthority);
     664
     665    /**
     666     * Sets the base path part of the the server URL.
     667     * @returns IPRT status code.
     668     * @param   a_pszBasePath   The new base path.  Does not accept NULL or empty string.
     669     */
     670    int setServerBasePath(const char *a_pszBasePath);
     671
     672    /**
     673     * Gets the default server URL as specified in the specs.
     674     * @returns Server URL.
     675     */
     676    virtual const char *getDefaultServerUrl() const = 0;
     677
     678    /**
     679     * Gets the default server base path as specified in the specs.
    642680     * @returns Host string (start of URL).
    643681     */
    644     virtual const char *getDefaultHost() const = 0;
    645 
    646     /**
    647      * Gets the host we're using.
    648      *
    649      * @returns Host URL string.
    650      */
    651     const char *getHost(void) const;
    652 
    653     /**
    654      * Sets the host (URL) to use when talking to the server.
    655      *
    656      * Setting the host is only required if there is a desire to use a
    657      * different server from the one specified in the API specification, like
    658      * for instance regional one.
    659      *
    660      * @returns IPRT status code.
    661      * @param   a_pszHost   The base path to use.
    662      */
    663     virtual int setHost(const char *a_pszHost);
    664 
    665     /**
    666      * Sets the base path (URL) to use when talking to the server.
    667      *
    668      * Setting the base path is only required if there is a desire to use a
    669      * different server from the one specified in the API specification, like
    670      * for instance regional one.
    671      *
    672      * @returns IPRT status code.
    673      * @param   a_strHost   The base path to use.
    674      * @note    Defers to the C-string variant.
    675      */
    676     int setHost(RTCString const &a_strHost);
    677 
    678 
    679     /**
    680      * Gets the default base path (relative to getHost()) as specified in the specs.
    681      *
    682      * @returns Base path string.
    683      */
    684     virtual const char *getDefaultBasePath() const = 0;
    685 
    686     /**
    687      * Gets the base path we're using (relative to getHost).
    688      *
    689      * @returns Base path string.
    690      */
    691     const char *getBasePath(void) const;
    692 
    693     /**
    694      * Sets the base path (relative to getHost()) to use when talking to the server.
    695      *
    696      * It is assumed that the base path is at the minimum a lone slash, so an
    697      * empty (or NULL) string is understood to mean reverting to the default
    698      * (see getDefaultBasePath()).
    699      *
    700      * @param   a_pszPath   The base path to use.
    701      */
    702     virtual int setBasePath(const char *a_pszPath);
    703 
    704     /**
    705      * Sets the base path (relative to getHost()) to use when talking to the server.
    706      *
    707      * @param   a_strPath   The base path to use.
    708      * @note    Defers to the C-string variant.
    709      */
    710     int setBasePath(RTCString const &a_strPath);
    711 
     682    virtual const char *getDefaultServerBasePath() const = 0;
    712683    /** @} */
    713684
     
    721692    /** Handle to the HTTP connection object. */
    722693    RTHTTP  m_hHttp;
    723     /** The host to use.  If empty use the default. */
    724     RTCString m_strHost;
    725     /** The base path to use.  If empty use the default. */
    726     RTCString m_strBasePath;
     694    /** The server URL to use.  If empty use the default. */
     695    RTCString m_strServerUrl;
    727696
    728697    /* Make non-copyable (RTCNonCopyable causes warnings): */
     
    782751    int ociSignRequest(RTHTTP a_hHttp, RTCString const &a_rStrFullUrl, RTHTTPMETHOD a_enmHttpMethod,
    783752                       RTCString const &a_rStrXmitBody, uint32_t a_fFlags, RTCRKEY a_hKey, RTCString const &a_rStrKeyId);
     753
     754    /**
     755     * Worker for the server URL modifiers.
     756     *
     757     * @returns IPRT status code.
     758     * @param   a_pszServerUrl  The current server URL (for comparing).
     759     * @param   a_offDst        The offset of the component in the current server URL.
     760     * @param   a_cchDst        The current component length.
     761     * @param   a_pszSrc        The new URL component value.
     762     * @param   a_cchSrc        The length of the new component.
     763     */
     764    int setServerUrlPart(const char *a_pszServerUrl, size_t a_offDst, size_t a_cchDst, const char *a_pszSrc, size_t a_cchSrc);
    784765};
    785766
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