components/webclient/src/webclient.c
struct webclient_session *webclient_session_create(size_t header_sz)
{
    struct webclient_session *session;

    /* create session */
    session = (struct webclient_session *)web_malloc(sizeof(struct webclient_session));
    memset(session, 0, sizeof(struct webclient_session));
    if (session == NULL)
    {
        // "webclient create failed, no memory for webclient session!"
        return NULL;
    }

    session->content_length = -1;
    session->header = (struct webclient_header *)web_malloc(sizeof(struct webclient_header));
    memset(session->header, 0, sizeof(struct webclient_header));
    if (session->header == NULL)
    {
        // "webclient create failed, no memory for session header!"
        web_free(session);
        session = NULL;
        return NULL;
    }

    session->header->size = header_sz;
    session->header->buffer = (char *)web_malloc(header_sz);
    if (session->header->buffer == NULL)
    {
        // "webclient create failed, no memory for session header buffer!"
        web_free(session->header);
        web_free(session);
        session = NULL;
        return NULL;
    }

    return session;
}
/**
 * create webclient session, set maximum header and response size
 *
 * @param header_sz maximum send header size
 * @param resp_sz maximum response data size
 *
 * @return  webclient session structure
 */
create webclient session, set maximum header and response size
@param header_sz maximum send header size
@param resp_sz maximum response data size

@return  webclient session structure
create webclient session set maximum header and response size @param header_sz maximum send header size @param resp_sz maximum response data size @return webclient session structure
struct webclient_session *webclient_session_create(size_t header_sz)
{
    struct webclient_session *session;
    session = (struct webclient_session *)web_malloc(sizeof(struct webclient_session));
    memset(session, 0, sizeof(struct webclient_session));
    if (session == NULL)
    {
        return NULL;
    }
    session->content_length = -1;
    session->header = (struct webclient_header *)web_malloc(sizeof(struct webclient_header));
    memset(session->header, 0, sizeof(struct webclient_header));
    if (session->header == NULL)
    {
        web_free(session);
        session = NULL;
        return NULL;
    }
    session->header->size = header_sz;
    session->header->buffer = (char *)web_malloc(header_sz);
    if (session->header->buffer == NULL)
    {
        web_free(session->header);
        web_free(session);
        session = NULL;
        return NULL;
    }
    return session;
}
struct webclient_session * webclient_session_create ( size_t header_sz ) { struct webclient_session * session ; session = ( struct webclient_session * ) web_malloc ( sizeof ( struct webclient_session ) ) ; memset ( session , 0 , sizeof ( struct webclient_session ) ) ; if ( session == NULL ) { return NULL ; } session -> content_length = -1 ; session -> header = ( struct webclient_header * ) web_malloc ( sizeof ( struct webclient_header ) ) ; memset ( session -> header , 0 , sizeof ( struct webclient_header ) ) ; if ( session -> header == NULL ) { web_free ( session ) ; session = NULL ; return NULL ; } session -> header -> size = header_sz ; session -> header -> buffer = ( char * ) web_malloc ( header_sz ) ; if ( session -> header -> buffer == NULL ) { web_free ( session -> header ) ; web_free ( session ) ; session = NULL ; return NULL ; } return session ; }
create webclient session, set maximum header and response size
 @param header_sz maximum send header size
 @param resp_sz maximum response data size
create webclient session set maximum header and response size @param header_sz maximum send header size @param resp_sz maximum response data size
/* create session */ // "webclient create failed, no memory for webclient session!" // "webclient create failed, no memory for session header!" // "webclient create failed, no memory for session header buffer!"