help with POST in "freescale_http.c"

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

help with POST in "freescale_http.c"

1,903件の閲覧回数
NT
Contributor I

According to the description of “freescale_http.c”, the web server supports ‘GET’,’POST’,’EMG’.

But  void freescale_process_header(int session, char *buffer, int bytesread) only supports GET and EMG. I am not able to add code that supports POST. Can anyone help me to add the code that supports POST too.

Thanks

NT

ラベル(1)
0 件の賞賛
返信
4 返答(返信)

697件の閲覧回数
NT
Contributor I

Change  RECV_BUFFER_SIZE and MAX_HEADER_READS as required. You can find the size by looking at the contents that webpage sends during post method. You can do this using wireshark.

The function to process “POST”method is as follows.

                if( freescale_http_sessions[session].headertype == TYPE_POST )

                {

                                collect_sensor_data( );

                                if( filename[0] )

                                                pre_process_post_filename( filename );

                                 if(passwd_flag ==1)

                                {  

                                    emg_web_open( session, filename );               

                                }

                                else

                                emg_web_open(session,"pwd_incorrect.htm");

                               

                                freescale_http_sessions[session].state = EMG_HTTP_STATE_SEND_FILE;                                           

                } // end of if TYPE_POST

?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:smileysurprised:ffice:smileysurprised:ffice" /> 

0 件の賞賛
返信

697件の閲覧回数
NT
Contributor I

void pre_process_post_filename( char *buffer )

{

                int                           i, start, stop, j, k, index, next;

                for( i=0, start=0; i<RECV_BUFFER_SIZE; i++ )

                {

                                if( buffer[i] == '=' )

                                {

                                                start = i;

                                 }

                }

                if( !start )

                {

                                printf ("in !start");

                                return; 

                }

                                                               

                // From start to buffer[i] == 0 is the full form string, it may contain multiple forms

                for( i=start, stop=0, start=0; i<RECV_BUFFER_SIZE; i++ )

                {

                                if(buffer[i] == '=')

                                {

                                                buffer[i] = 0;

                                                if( !start )

                                                                start = i+1;

                                                else

                                                {

                                                                stop = i;

                                                                next = i+1;

                                                }

                                               

                                                continue;            

                                }

                                if( buffer[i] == 0 )

                                {

                                                stop  = i;

                                                next  = 0;

                                }

                                if( stop )

                                {                                             

                                                process_post_form( &buffer[start]);

                                                if( !next )

                                                                break;

                                                else

                                                {

                                                                start = 0;

                                                                stop  = 0;

                                                                i++;

                                                }

                                }

                }

               

}

 

void process_post_form( char *form_string )

{

                int                           i, j, index;

                int                           num_ands, cur_and, and_count;

                int                           start, end;

                int                           is_next;

                char       *this_temp_form_string, *next_temp_form_string;

               

                next_temp_form_string = form_string;

                this_temp_form_string = next_temp_form_string;

  

      if ((char)(*(next_temp_form_string-2))=='d')  //Passwd

    {

(forms[9].func)(this_temp_form_string);            /* 9 because index of Passwd is 9 in freescale_static_ffs_utils.c*/

    }

   

    If ((char)(*(next_temp_form_string-2))=='o')  //chgpwo

    {

(forms[10].func)(this_temp_form_string);          /* 10 because index of chgpwo is 10 in freescale_static_ffs_utils.c*/

    }

   

                if((char)(*(next_temp_form_string-2))=='n')  //chgpwn

    {

(forms[11].func)(this_temp_form_string);          /* 11 because index of chgpwn is 11 in freescale_static_ffs_utils.c*/

    }

               

}

 

Note: Passwd, chgpwd and chgpwn are the name of variables in html page.Ignore?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /> .It showed up during preview post.Replace the other two icons by ).

 

0 件の賞賛
返信

697件の閲覧回数
NT
Contributor I
I was able to solve this problem.
 
NT
0 件の賞賛
返信

697件の閲覧回数
alager
Contributor II
how?
0 件の賞賛
返信