components/webclient/src/webclient.c
int webclient_post(struct webclient_session *session, const char *URI, const char *post_data)
{
    int rc = WEBCLIENT_OK;
    int resp_status = 0;

    if (!session || !URI)
    {
        return WEBCLIENT_ERROR;
    }

    rc = webclient_connect(session, URI);
    if (rc != WEBCLIENT_OK)
    {
        /* connect to webclient server failed. */
        return rc;
    }

    rc = webclient_send_header(session, WEBCLIENT_POST);
    if (rc != WEBCLIENT_OK)
    {
        /* send header to webclient server failed. */
        return rc;
    }

    if (post_data)
    {
        webclient_write(session, (unsigned char *)post_data, strlen(post_data));

        /* resolve response data, get http status code */
        resp_status = webclient_handle_response(session);
        if (resp_status != 200)
        {
            // "post failed, handle response(%d) error.", resp_status
            return resp_status;
        }
    }

    return resp_status;
}
/**
 * send POST request to server and get response header data.
 *
 * @param session webclient session
 * @param URI input server URI address
 * @param header POST request header, can't be empty
 * @param post_data data sent to the server
 *                = NULL: just connect server and send header
 *               != NULL: send header and body data, resolve response data
 *
 * @return <0: send POST request failed
 *         =0: send POST header success
 *         >0: response http status code
 */
send POST request to server and get response header data.
@param session webclient session
@param URI input server URI address
@param header POST request header, can't be empty
@param post_data data sent to the server
= NULL: just connect server and send header
!= NULL: send header and body data, resolve response data

@return <0: send POST request failed
=0: send POST header success
>0: response http status code
send POST request to server and get response header data . @param session webclient session @param URI input server URI address @param header POST request header can ' t be empty @param post_data data sent to the server = NULL : just connect server and send header ! = NULL : send header and body data resolve response data @return <0 : send POST request failed = 0 : send POST header success > 0 : response http status code
int webclient_post(struct webclient_session *session, const char *URI, const char *post_data)
{
    int rc = WEBCLIENT_OK;
    int resp_status = 0;
    if (!session || !URI)
    {
        return WEBCLIENT_ERROR;
    }
    rc = webclient_connect(session, URI);
    if (rc != WEBCLIENT_OK)
    {
        return rc;
    }
    rc = webclient_send_header(session, WEBCLIENT_POST);
    if (rc != WEBCLIENT_OK)
    {
        return rc;
    }
    if (post_data)
    {
        webclient_write(session, (unsigned char *)post_data, strlen(post_data));
        resp_status = webclient_handle_response(session);
        if (resp_status != 200)
        {
            return resp_status;
        }
    }
    return resp_status;
}
int webclient_post ( struct webclient_session * session , const char * URI , const char * post_data ) { int rc = WEBCLIENT_OK ; int resp_status = 0 ; if ( ! session || ! URI ) { return WEBCLIENT_ERROR ; } rc = webclient_connect ( session , URI ) ; if ( rc != WEBCLIENT_OK ) { return rc ; } rc = webclient_send_header ( session , WEBCLIENT_POST ) ; if ( rc != WEBCLIENT_OK ) { return rc ; } if ( post_data ) { webclient_write ( session , ( unsigned char * ) post_data , strlen ( post_data ) ) ; resp_status = webclient_handle_response ( session ) ; if ( resp_status != 200 ) { return resp_status ; } } return resp_status ; }
send POST request to server and get response header data.
send POST request to server and get response header data .
/* connect to webclient server failed. */ /* send header to webclient server failed. */ /* resolve response data, get http status code */ // "post failed, handle response(%d) error.", resp_status