On Mon, Feb 15, 2010 at 8:12 AM, Hank Knight <hknight555@gmail.com> wrote:
Thanks, Steve. Your idea works for User-Agent but it doesn't work with
other header values like "Accept-Charset" and "Accept-Language"

Commonly-used headers appear as fields in the header record, but if it's not in a field, then it's stored in the "other" field. You can find code for interpreting the "other" field in wde's previous response in this thread, and use it like this:

out(_) ->
       {status, 200},
       {content, "text/html", ""}.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml">
out(A) ->
    Hdrs = A#arg.headers,
    Other = Hdrs#headers.other,
     [{head, [],
       [{title, [], "Details about the Request"},
        {style, [{type, "text/css"}],
         "span {color: red;} h2{font-size: 12pt;}"}]},
      {body, [],
       [{h1, [], "Details"},
        {h2, [],
         ["Your user agent is: ",
          {span, [], Hdrs#headers.user_agent}]},
        {h2, [],
         ["Host: ",
          {span, [], Hdrs#headers.host}]},
        {h2, [],
         ["Accept-Language: ",
          {span, [],
           find_http_header('Accept-Language', Other)}]},
        {h2, [],
         ["Accept-Charset: ",
          {span, [],
           find_http_header('Accept-Charset', Other)}]}

find_http_header(Key,Headers) when is_list(Headers) ->
    case lists:keysearch(Key,3,Headers) of
        {value,{_,_,_,_,Value}} -> Value;
        false -> "**NONE**"