VirtualBox

Changeset 74071 in vbox for trunk/src/VBox/Runtime/tools


Ignore:
Timestamp:
Sep 4, 2018 3:32:56 PM (6 years ago)
Author:
vboxsync
Message:

IPRT/http: Fixed bug in rtHttpAddHeaderWorker where it failed to detected the frist header and tell cURL about it. bugref:9167

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/tools/RTHttp.cpp

    r73334 r74071  
    3232
    3333#include <iprt/assert.h>
     34#include <iprt/ctype.h>
    3435#include <iprt/err.h>
    3536#include <iprt/getopt.h>
     
    6869        { "--quiet",        'q', RTGETOPT_REQ_NOTHING },
    6970        { "--verbose",      'v', RTGETOPT_REQ_NOTHING },
     71        { "--set-header",   's', RTGETOPT_REQ_STRING },
    7072    };
    7173
     
    111113                RTPrintf("$Revision$\n");
    112114                return RTEXITCODE_SUCCESS;
     115
     116            case 's':
     117            {
     118                char *pszColon = (char *)strchr(ValueUnion.psz, ':');
     119                if (!pszColon)
     120                    return RTMsgErrorExit(RTEXITCODE_FAILURE, "No colon in --set-header value: %s", ValueUnion.psz);
     121                *pszColon = '\0'; /* evil */
     122                const char *pszValue = pszColon + 1;
     123                if (RT_C_IS_BLANK(*pszValue))
     124                    pszValue++;
     125                int rc = RTHttpAddHeader(hHttp, ValueUnion.psz, pszValue, RTSTR_MAX, RTHTTPADDHDR_F_BACK);
     126                *pszColon = ':';
     127                if (RT_FAILURE(rc))
     128                    return RTMsgErrorExit(RTEXITCODE_FAILURE, "RTHttpAddHeader failed: %Rrc (on %s)", rc, ValueUnion.psz);
     129                break;
     130            }
    113131
    114132            case VINF_GETOPT_NOT_OPTION:
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