/*
static int search_record_data_init(struct search_record_req_data *data)
{
	if((data->full_url = malloc(URL_LEN*sizeof(char))) == NULL)
		return 0;
	if((data->ip = malloc(IP_LEN*sizeof(char))) == NULL)
		return 0;
//	if((data->body = ci_membuf_new()) == NULL)
//		return 0;
	return 1;
}
static void search_record_data_clean(struct search_record_req_data *data)
{
	free(data->full_url);
	free(data->ip);

}
*/
static const char* get_client_ip(ci_request_t* req,char* result)
{
	const char* ip;
	if((ip = ci_http_request_get_header(req,"X-Forwarded-For")) == NULL)
	{
		ip = ci_headers_value(req->request_header,"X-Client-IP");
		if(ip == NULL)
		return NULL;
	}
	strcpy(result,ip);
	return result;
}
示例#2
0
int fmt_http_req_head_o(ci_request_t *req, char *buf,int len, char *param)
{
  char *s = NULL;
  int i;
  if (!len)
     return 0;

  if (!param || param[0] == '\0') {
      s = ci_http_request(req);
  } else {
      s = ci_http_request_get_header(req, param);
  }

  if (s)  {
      for(i=0;i<len && *s!= '\0' && *s != '\r' && *s!='\n'; i++,s++)
          buf[i] = *s;
      return i;
  } else {
     *buf = '-';
     return 1;
  }
}