Ejemplo n.º 1
0
/**
 @brief	get next parameter value in the request
 */ 
unsigned char* get_http_param_value(char* uri, char* param_name)
{

  char * name=0; 
  uint8 *ret=BUFPUB;
  if(!uri || !param_name) return 0;
  if((name = strstr(uri,param_name)))
  {
    name += strlen(param_name) + 1; 
    char* pos2=strstr(name,"&");
    if(!pos2) 
    {
      pos2=name+strlen(name);
    }
    uint16 len=0;
    len = pos2-name;
 
    if(len)
    {
      ret[len]=0;
      strncpy((char*)ret,name,len);
      unescape_http_url((char*)ret);
      replacetochar((char*)ret,'+',' ');
      //ret[len]=0;
      //ret[strlen((int8*)ret)]=0;
    }
    else
      ret[0]=0;
  }
  else
    return 0;
  return ret;		
}
Ejemplo n.º 2
0
/**
 @brief	get next parameter value in the request
 */ 
char* get_http_param_value(
	char* uri, 
	char* param_name
	)
{
	char tempURI[MAX_URI_SIZE];
	u_char * name=0;
	

	if(!uri || !param_name) return 0;
	
	strcpy((char*)tempURI,uri);
	if((name = strstr(tempURI,param_name)))
	{
		name += strlen(param_name) + 1; // strlen(para_name) + strlen("=")
		if((name = strtok((char *)name,"& \r\n\t\0")))
		{
			unescape_http_url((char *)name);
			replacetochar((char *)name,'+',' ');
		}
	}
#ifdef HTTPD_DEBUG
	PRINTLN2("%s=%s",param_name,name);
#endif	
	return name;		
}
/**
 @brief	get next parameter value in the request
 */
uint8_t * get_http_param_value(char* uri, char* param_name)
{

	uint8_t * name;
	uint8_t * ret = BUFPUB;
	uint8_t * pos2;
	uint16_t len = 0, content_len = 0;
	uint8_t tmp_buf[10]={0x00, };

	if(!uri || !param_name) return 0;

	/***************/
	mid(uri, "Content-Length: ", "\r\n", (char *)tmp_buf);
	content_len = ATOI(tmp_buf, 10);
	//printf("content len=%d\r\n",content_len);
	uri = strstr(uri, "\r\n\r\n");
	uri+=4;
	//printf("uri=%s\r\n",uri);
	uri[content_len] = 0;
	/***************/
	
	name = (uint8_t *)strstr(uri, param_name);
	if(name != NULL)
	{
		name += strlen(param_name) + 1;
		pos2 = (uint8_t*)strstr((char*)name, "&");
		if(!pos2)
		{
			pos2 = name + strlen((char*)name);
		}
		len = pos2 - name;

		if(len)
		{
			ret[len] = 0;
			strncpy((char*)ret,(char*)name, len);
			unescape_http_url((char *)ret);
			replacetochar(ret, '+' ,' ');
			//ret[len] = 0;
			//ret[strlen((int8*)ret)] = 0;
			//printf("len=%d\r\n",len);
		}
		else
		{
			ret[0] = 0;
		}
	}
	else
	{
		return 0;
	}
#ifdef _HTTPPARSER_DEBUG_
	printf("  %s=%s\r\n", param_name, ret);
#endif
	return ret;
}
Ejemplo n.º 4
0
/**
 @brief	get next parameter value in the request
 */ 
unsigned char* get_http_param_value(char* uri, char* param_name)
{

  u_char * name=0; 
  uint8 *ret=BUFPUB;
  uint16 content_len=0;
  int8 tmp_buf[10]={0x00,};
  if(!uri || !param_name) return 0;
  /***************/
  mid(uri,"Content-Length: ","\r\n",tmp_buf);
  content_len=ATOI(tmp_buf,10);
  //printf("content len=%d\r\n",content_len);
  uri = (int8*)strstr(uri,"\r\n\r\n");
  uri+=4;
  //printf("uri=%s\r\n",uri);
  uri[content_len]=0;
  /***************/
  if((name = (uint8*)strstr(uri,param_name)))
  {
    name += strlen(param_name) + 1; 
    uint8* pos2=(uint8*)strstr((char*)name,"&");
    if(!pos2) 
    {
      pos2=name+strlen((char*)name);
    }
    uint16 len=0;
    len = pos2-name;
 
    if(len)
    {
      ret[len]=0;
      strncpy((char*)ret,(char*)name,len);
      unescape_http_url((char *)ret);
      replacetochar((char *)ret,'+',' ');
      //ret[len]=0;
      //ret[strlen((int8*)ret)]=0;
      //printf("len=%d\r\n",len);
    }
    else
      ret[0]=0;
  }
  else
    return 0;
  return ret;		
}
Ejemplo n.º 5
0
/**
 @brief	get next parameter value in the request
 */
uint8_t* get_http_param_value(
	uint8_t* uri,
	uint8_t* param_name
	)
{
	uint8_t tempURI[MAX_URI_SIZE];
	uint8_t* name=0;
	if(!uri || !param_name) return 0;

	strncpy((char *)tempURI, (const char *)uri, MAX_URI_SIZE);
	if((name=(uint8_t*)strstr((const char *)tempURI, (const char *)param_name)))
	{
		name += strlen((const char *)param_name) + 1; // strlen(para_name) + strlen("=")
		if((name = (uint8_t*)strtok((char *)name,"& \r\n\t\0")))
		{
			unescape_http_url((uint8_t*)name);
			replacetochar((uint8_t*)name,'+',' ');
		}
	}
#ifdef HTTP_DEBUG
	xSerialPrintf_P(PSTR("\n%s=%s "),param_name,name);
#endif
	return (uint8_t*)name;
}