Thanks Steve for your reply. I tried using the code snippet you gave me but i am getting this error

yaws code at appmod:0 crashed or ret bad val:{"connection","keep-alive"}
Req: {http_request,'GET',{abs_path,"/context"},{1,1}}

Need Help on this too :-)

On Fri, Feb 27, 2009 at 4:20 AM, Steve Vinoski <> wrote:
On 2/26/09, Saurabh80 <> wrote:
>  Which module and function in yaws does this. basically i want to stream the
>  request parameters to some other port. so that i can keep yaws as a
>  webserver and at the backend do the session management and stuff myself.
>  I am trying to explore possibilities to use yaws in the j2ee world.

J2EE, huh? Better you than me. ;-)

The Arg type that's passed from Yaws to all out/1 functions contains
all the headers -- basically it contains everything that's associated
with the request. If you want to pass all request info along, the Arg
already has it all, so your best bet is to extract what you need from
there and pass it along.

For example, if you want all the headers but don't want to go through
all the trouble of digging through records field-by-field to get them,
here's one way to do that within an out/1 function (beware, only
partially tested):

-define(HEADER_FIELDS, record_info(fields, headers)).

hdr_to_string(Hdr) when is_atom(Hdr) ->
   lists:map(fun($_) -> $-; (C) -> C end, atom_to_list(Hdr));
hdr_to_string(Hdr) when is_list(Hdr) ->

out(A) ->
   [_|Header_vals] = tuple_to_list(A#arg.headers),
   Headers1 = lists:map(fun({Hdr, Val}) ->
                                {hdr_to_string(Hdr), Val}
                        end, lists:zip(?HEADER_FIELDS, Header_vals)),
   Other = lists:map(fun({http_header, _, K, _, V}) ->
                             {hdr_to_string(K), V}
                     end, proplists:get_value("other", Headers1)),
   Headers = lists:append([proplists:delete("other", Headers1), Other]),

At this point, Headers will be a proplist of header name string keys
and their string values. The special record_info call (which is
compile-time only, hence the macro) lets us walk the whole headers
record without having to change our code if that record ever changes.
Comments on improvements to this approach are most welcomed.