components/webclient/src/webclient.c
int webclient_close(struct webclient_session *session)
{
    if (!session)
    {
        return WEBCLIENT_ERROR;
    }

#ifdef WEBCLIENT_USING_TLS
    if (session->tls_session)
    {
        mbedtls_client_close(session->tls_session);
    }
    else
    {
        if (session->socket >= 0)
        {
            closesocket(session->socket);
            session->socket = -1;
        }
    }
#else
    if (session->socket >= 0)
    {
        closesocket(session->socket);
        session->socket = -1;
    }
#endif

    if (session->host)
    {
        web_free(session->host);
    }

    if (session->req_url)
    {
        web_free(session->req_url);
    }

    if (session->header && session->header->buffer)
    {
        web_free(session->header->buffer);
    }

    if (session->header)
    {
        web_free(session->header);
    }

    web_free(session);
    session = NULL;

    return 0;
}
/**
 * close a webclient client session.
 *
 * @param session http client session
 *
 * @return 0: close success
 */
close a webclient client session.
@param session http client session

@return 0: close success
close a webclient client session . @param session http client session @return 0 : close success
int webclient_close(struct webclient_session *session)
{
    if (!session)
    {
        return WEBCLIENT_ERROR;
    }
#ifdef WEBCLIENT_USING_TLS
    if (session->tls_session)
    {
        mbedtls_client_close(session->tls_session);
    }
    else
    {
        if (session->socket >= 0)
        {
            closesocket(session->socket);
            session->socket = -1;
        }
    }
#else
    if (session->socket >= 0)
    {
        closesocket(session->socket);
        session->socket = -1;
    }
#endif
    if (session->host)
    {
        web_free(session->host);
    }
    if (session->req_url)
    {
        web_free(session->req_url);
    }
    if (session->header && session->header->buffer)
    {
        web_free(session->header->buffer);
    }
    if (session->header)
    {
        web_free(session->header);
    }
    web_free(session);
    session = NULL;
    return 0;
}
int webclient_close ( struct webclient_session * session ) { if ( ! session ) { return WEBCLIENT_ERROR ; } #ifdef WEBCLIENT_USING_TLS if ( session -> tls_session ) { mbedtls_client_close ( session -> tls_session ) ; } else { if ( session -> socket >= 0 ) { closesocket ( session -> socket ) ; session -> socket = -1 ; } } #else if ( session -> socket >= 0 ) { closesocket ( session -> socket ) ; session -> socket = -1 ; } #endif if ( session -> host ) { web_free ( session -> host ) ; } if ( session -> req_url ) { web_free ( session -> req_url ) ; } if ( session -> header && session -> header -> buffer ) { web_free ( session -> header -> buffer ) ; } if ( session -> header ) { web_free ( session -> header ) ; } web_free ( session ) ; session = NULL ; return 0 ; }
close a webclient client session.
close a webclient client session .