0
-module(frontend_responder).
0
--include("yaws_api.hrl").
0
+-include("responder_base.erl").
0
resource_fountain:best_pool_for_details_match(details()).
0
- Parameters = [{request, {struct, parse_arg(A, SC)}}],
0
- io:format("Param restructure:~n~p~n", [Parameters]),
0
- Pool = provide_pool(A),
0
- case node_api:safely_send_call_to_pool_no_lookup(handle_request,
0
- error_logger:info_msg("500 Internal Server Error: ~p~n", [R]),
0
- [{status, 500}, {html, "Sumpin fucked."}]
0
-parse_arg(Request, ServerOptions) ->
0
- Headers = Request#arg.headers,
0
- [convert_method(Request),
0
- convert_version(Request),
0
- convert_querypath(Request),
0
- {querydata, prep(Request#arg.querydata)},
0
- {servername, prep(ServerOptions#sconf.servername)},
0
- {headers, {struct, convert_headers(Request#arg.headers)}},
0
- {cookies, {array, lists:map(fun(X) -> prep(X) end, Headers#headers.cookie)}},
0
- {pathinfo, prep(ServerOptions#sconf.docroot)},
0
- {postdata, Request#arg.clidata}].
0
-convert_method(Request) ->
0
- {http_request,Method,{_Type,_Path},_} = R,
0
-convert_querypath(Request) ->
0
- {http_request,_Method,{_Type,Path},_} = R,
0
- {querypath, prep(Path)}.
0
-convert_version(Request) ->
0
- {http_request,_Method,{_Type,_Path},Version} = R,
0
- {http_version, {array, tuple_to_list(Version)}}.
0
- {http_request,Method,{_Type,Path},_} = R,
0
- NormalHeaders = [{connection, prep(A#headers.connection)},
0
- {accept, prep(A#headers.accept)},
0
- {host, prep(A#headers.host)},
0
- {if_modified_since, prep(A#headers.if_modified_since)},
0
- {if_match, prep(A#headers.if_match)},
0
- {if_none_match, prep(A#headers.if_none_match)},
0
- {if_range, prep(A#headers.if_range)},
0
- {if_unmodified_since, prep(A#headers.if_unmodified_since)},
0
- {range, prep(A#headers.range)},
0
- {referer, prep(A#headers.referer)},
0
- {user_agent, prep(A#headers.user_agent)},
0
- {accept_ranges, prep(A#headers.accept_ranges)},
0
- {keep_alive, prep(A#headers.keep_alive)},
0
- {location, prep(A#headers.location)},
0
- {content_length, prep(A#headers.content_length)},
0
- {content_type, prep(A#headers.content_type)},
0
- {content_encoding, prep(A#headers.content_encoding)},
0
- {authorization, prep(A#headers.authorization)},
0
- {transfer_encoding, prep(A#headers.transfer_encoding)}],
0
- lists:map(fun({http_header, _Len, Name, _, Value}) -> {prep(Name), prep(Value)} end,
0
- [{Name, Res} || {Name, Res} <- NormalHeaders, Res /= undefined] ++ SpecialHeaders.
0
-convert_response({response, EhtmlTuple}) ->
0
- {Status, AllHeaders, Html} = EhtmlTuple,
0
- {allheaders, HeaderList} = AllHeaders,
0
- ProcessedHeaderList = lists:map(fun({header, Name, Value}) -> {header, [binary_to_list(Name) ++ ":", binary_to_list(Value)]} end,
0
- tuple_to_list(HeaderList)),
0
- {html, RawResult} = Html,
0
- [Status, {allheaders, ProcessedHeaderList}, {html, binary_to_list(RawResult)}].
0
-prep(A) when is_list(A) -> list_to_binary(A);
0
- application:get_env(fuzed_frontend, details),