static SigV4Status_t appendCanonicalizedHeaders()

in source/sigv4.c [1571:1606]


    static SigV4Status_t appendCanonicalizedHeaders( size_t headerCount,
                                                     uint32_t flags,
                                                     CanonicalContext_t * pCanonicalRequest )
    {
        size_t headerIndex = 0, keyLen = 0, valLen = 0;
        const char * value;
        const char * headerKey;
        SigV4Status_t sigV4Status = SigV4Success;

        assert( pCanonicalRequest != NULL );
        assert( headerCount > 0 );

        for( headerIndex = 0; headerIndex < headerCount; headerIndex++ )
        {
            assert( pCanonicalRequest->pHeadersLoc[ headerIndex ].key.pData != NULL );
            keyLen = pCanonicalRequest->pHeadersLoc[ headerIndex ].key.dataLen;
            valLen = pCanonicalRequest->pHeadersLoc[ headerIndex ].value.dataLen;
            headerKey = pCanonicalRequest->pHeadersLoc[ headerIndex ].key.pData;
            /* ':' is used to separate header key and header value in the canonical request. */
            sigV4Status = copyHeaderStringToCanonicalBuffer( headerKey, keyLen, flags, ':', pCanonicalRequest );

            if( sigV4Status == SigV4Success )
            {
                value = pCanonicalRequest->pHeadersLoc[ headerIndex ].value.pData;
                /* '\n' is used to separate each key-value pair in the canonical request. */
                sigV4Status = copyHeaderStringToCanonicalBuffer( value, valLen, flags, '\n', pCanonicalRequest );
            }

            if( sigV4Status != SigV4Success )
            {
                break;
            }
        }

        return sigV4Status;
    }