How can i access the other header of yaws arg structure,

Håkan Stenholm <>
Thu Jul 21 02:47:53 CEST 2005


MEENA SELVAM wrote:

>Hi,
>
>I have a arg record A passed by the yaws webserver to
>the web application:
>
>
>How can i access the 3rd element of the other header,
>whereas I have the other header itself is available as
>(A#arg.headers)#headers.Other
>  
>

#headers.other appears to be a list, the third element of a list can be accessed in two ways:

%% using pattern matching
[_,_,ThirdElement|_] = List

%% or
 
%% using nth/2 in the lists module
ThirdElement = lists:nth(3, List)


>A= {arg,#Port<16338.534>,
>                        {headers,undefined,
>                                 "image/gif,
>image/x-xbitmap, image/jpeg, image/
>pjpeg, */*",
>                                 "www.msn.com",
>                                 undefined,
>                                 undefined,
>                                 undefined,
>                                 undefined,
>                                 undefined,
>                                 undefined,
>                                 undefined,
>                                 "Mozilla/4.0
>(compatible; MSIE 6.0; Windows NT
>5.1)",
>                                 undefined,
>                                 [],
>                                 undefined,
>                                 undefined,
>                                 undefined,
>                                 undefined,
>                                 undefined,
>                                 undefined,
>                                 undefined,
>                                 [{http_header,
>                                      0,
>                                     
>"X-Yaws-Had-Clicert",
>                                      undefined,
>                                      "false"},
>                                  {http_header,
>                                      49,
>                                     
>'X-Forwarded-For',
>                                      undefined,
>                                      "11.10.1.107"},
>                                  {http_header,
>                                      7,
>                                      'Via',
>                                      undefined,
>                                      "1.1 www.msn.com
>(Alteon iSD-SSL/5.5)"},
>                                  {http_header,
>                                      0,
>                                     
>"X-Forwarded-By",
>                                      undefined,
>                                      "47.80.18.95"},
>                                  {http_header,
>                                      10,
>                                     
>'Accept-Encoding',
>                                      undefined,
>                                      "gzip,
>deflate"},
>                                  {http_header,
>                                      11,
>                                     
>'Accept-Language',
>                                      undefined,
>                                      "en-us"}]},
>                       
>{http_request,'GET',{abs_path,"/"},{1,1}},
>                        undefined,
>                        "/",
>                        [],
>                        undefined,
>                        .... and much more
>
>
>The records arg and header are defined as below:
>
>-record(arg, {
>          clisock,        %% the socket leading to the
>peer client
>          headers,        %% headers
>          req,            %% request
>         
>          .....      some more
>         }).
>
>-record(headers, {
>          connection,
>          accept,
>          host,
>          if_modified_since,
>          if_match,
>          if_none_match,
>          if_range,
>          if_unmodified_since,
>          range,
>          referer,
>          user_agent,
>          accept_ranges,
>          cookie = [],
>          keep_alive,
>          location,
>          content_length,
>          content_type,
>          content_encoding,
>          authorization,
>          transfer_encoding,
>          other = []   %% misc other headers
>   }).
>
>
>
>__________________________________________________
>Do You Yahoo!?
>Tired of spam?  Yahoo! Mail has the best spam protection around 
>http://mail.yahoo.com 
>
>  
>




More information about the erlang-questions mailing list