connectivity/http/http.c
static status_t build_request(ta_http_request_t *req, const char *data, size_t size) {
  if (req == NULL || data == NULL) {
    ta_log_error("Illegal NULL pointer\n");
    return SC_NULL;
  }
  if (size == 0) {
    ta_log_error("Illegal data size : 0\n");
    return SC_NULL;
  }
  if (size + req->request_len >= MAX_REQUEST_LEN) {
    req->answer_string = strdup(STR_HTTP_REQUEST_SIZE_EXCEED);
    req->answer_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
    return SC_HTTP_INTERNAL_SERVICE_ERROR;
  }
  char *request = malloc(req->request_len + size + 1);
  if (request == NULL) {
    req->answer_string = strdup(STR_HTTP_INTERNAL_SERVICE_ERROR);
    req->answer_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
    return SC_OOM;
  }
  if (req->request != NULL) {
    memcpy(request, req->request, req->request_len);
  }
  memcpy(request + req->request_len, data, size);
  request[req->request_len + size] = 0;
  free(req->request);
  req->request = request;
  req->request_len += size;

  return SC_OK;
}
/*
 * Append data from the end of ta_http_request_t.request
 */
Append data from the end of ta_http_request_t.request
Append data from the end of ta_http_request_t . request
static status_t build_request(ta_http_request_t *req, const char *data, size_t size) {
  if (req == NULL || data == NULL) {
    ta_log_error("Illegal NULL pointer\n");
    return SC_NULL;
  }
  if (size == 0) {
    ta_log_error("Illegal data size : 0\n");
    return SC_NULL;
  }
  if (size + req->request_len >= MAX_REQUEST_LEN) {
    req->answer_string = strdup(STR_HTTP_REQUEST_SIZE_EXCEED);
    req->answer_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
    return SC_HTTP_INTERNAL_SERVICE_ERROR;
  }
  char *request = malloc(req->request_len + size + 1);
  if (request == NULL) {
    req->answer_string = strdup(STR_HTTP_INTERNAL_SERVICE_ERROR);
    req->answer_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
    return SC_OOM;
  }
  if (req->request != NULL) {
    memcpy(request, req->request, req->request_len);
  }
  memcpy(request + req->request_len, data, size);
  request[req->request_len + size] = 0;
  free(req->request);
  req->request = request;
  req->request_len += size;
  return SC_OK;
}
static status_t build_request ( ta_http_request_t * req , const char * data , size_t size ) { if ( req == NULL || data == NULL ) { ta_log_error ( " \n " ) ; return SC_NULL ; } if ( size == 0 ) { ta_log_error ( " \n " ) ; return SC_NULL ; } if ( size + req -> request_len >= MAX_REQUEST_LEN ) { req -> answer_string = strdup ( STR_HTTP_REQUEST_SIZE_EXCEED ) ; req -> answer_code = MHD_HTTP_INTERNAL_SERVER_ERROR ; return SC_HTTP_INTERNAL_SERVICE_ERROR ; } char * request = malloc ( req -> request_len + size + 1 ) ; if ( request == NULL ) { req -> answer_string = strdup ( STR_HTTP_INTERNAL_SERVICE_ERROR ) ; req -> answer_code = MHD_HTTP_INTERNAL_SERVER_ERROR ; return SC_OOM ; } if ( req -> request != NULL ) { memcpy ( request , req -> request , req -> request_len ) ; } memcpy ( request + req -> request_len , data , size ) ; request [ req -> request_len + size ] = 0 ; free ( req -> request ) ; req -> request = request ; req -> request_len += size ; return SC_OK ; }
Append data from the end of ta_http_request_t.request
Append data from the end of ta_http_request_t . request