components/webclient/src/webclient.c
int webclient_header_fields_add(struct webclient_session *session, const char *fmt, ...)
{
    int32_t length;
    va_list args;

    if (!session || !session->header->buffer)
    {
        return WEBCLIENT_ERROR;
    }

    va_start(args, fmt);
    length = vsnprintf(session->header->buffer + session->header->length,
                       session->header->size - session->header->length, fmt, args);
    if (length < 0)
    {
        // "add fields header data failed, return length(%d) error.", length
        return -WEBCLIENT_ERROR;
    }
    va_end(args);

    session->header->length += length;
    /* check header size */
    if (session->header->length >= session->header->size)
    {
        // "not enough header buffer size(%d)!", session->header->size
        return -WEBCLIENT_ERROR;
    }
    return length;
}
/**
 * add fields data to request header data.
 *
 * @param session webclient session
 * @param fmt fields format
 *
 * @return >0: data length of successfully added
 *         <0: not enough header buffer size
 */
add fields data to request header data.
@param session webclient session
@param fmt fields format

@return >0: data length of successfully added
<0: not enough header buffer size
add fields data to request header data . @param session webclient session @param fmt fields format @return > 0 : data length of successfully added <0 : not enough header buffer size
int webclient_header_fields_add(struct webclient_session *session, const char *fmt, ...)
{
    int32_t length;
    va_list args;
    if (!session || !session->header->buffer)
    {
        return WEBCLIENT_ERROR;
    }
    va_start(args, fmt);
    length = vsnprintf(session->header->buffer + session->header->length,
                       session->header->size - session->header->length, fmt, args);
    if (length < 0)
    {
        return -WEBCLIENT_ERROR;
    }
    va_end(args);
    session->header->length += length;
    if (session->header->length >= session->header->size)
    {
        return -WEBCLIENT_ERROR;
    }
    return length;
}
int webclient_header_fields_add ( struct webclient_session * session , const char * fmt , ... ) { int32_t length ; va_list args ; if ( ! session || ! session -> header -> buffer ) { return WEBCLIENT_ERROR ; } va_start ( args , fmt ) ; length = vsnprintf ( session -> header -> buffer + session -> header -> length , session -> header -> size - session -> header -> length , fmt , args ) ; if ( length < 0 ) { return - WEBCLIENT_ERROR ; } va_end ( args ) ; session -> header -> length += length ; if ( session -> header -> length >= session -> header -> size ) { return - WEBCLIENT_ERROR ; } return length ; }
add fields data to request header data.
add fields data to request header data .
// "add fields header data failed, return length(%d) error.", length /* check header size */ // "not enough header buffer size(%d)!", session->header->size