<commit_before>-module(elli_request).
-include("elli.hrl").

-export([send_chunk/2
         , async_send_chunk/2
         , chunk_ref/1
         , path/1
         , raw_path/1
         , query_str/1
         , get_header/2
         , get_arg/2
         , get_arg/3
         , get_args/1
         , body_qs/1
         , headers/1
         , peer/1
         , method/1
         , body/1
         , get_header/3
         , to_proplist/1
        ]).

%%
%% Helpers for working with a #req{}
%%


%% @doc: Returns path split into binary parts.
path(#req{path = Path})                     -> Path.
raw_path(#req{raw_path = Path})             -> Path.
headers(#req{headers = Headers})            -> Headers.
peer(#req{peer = Peer})                     -> Peer.
method(#req{method = Method})               -> Method.
body(#req{body = Body})                     -> Body.

get_header(Key, #req{headers = Headers}) ->
    proplists:get_value(Key, Headers).

get_header(Key, #req{headers = Headers}, Default) ->
    proplists:get_value(Key, Headers, Default).

get_arg(Key, #req{} = Req) ->
    get_arg(Key, Req, undefined).

get_arg(_Key, #req{args = []}, Default) ->
    Default;
get_arg(Key, #req{args = Args}, Default) ->
    proplists:get_value(Key, Args, Default).

%% @doc Parses application/x-www-form-urlencoded body into a proplist
body_qs(#req{body = Body}) ->
    elli_http:split_args(Body).


-spec get_args(#req{}) -> QueryArgs :: proplists:proplist().
%% @doc Returns a proplist of keys and values of the original query
%%      string.  Both keys and values in the returned proplists will
%%      be binaries or the atom `true` in case no value was supplied
%%      for the query key.
get_args(#req{args = Args}) -> Args.<commit_msg>Documentation build fix. Keywords should be quoted in this patch, edoc halts otherwise.<commit_after>-module(elli_request).
-include("elli.hrl").

-export([send_chunk/2
         , async_send_chunk/2
         , chunk_ref/1
         , path/1
         , raw_path/1
         , query_str/1
         , get_header/2
         , get_arg/2
         , get_arg/3
         , get_args/1
         , body_qs/1
         , headers/1
         , peer/1
         , method/1
         , body/1
         , get_header/3
         , to_proplist/1
        ]).

%%
%% Helpers for working with a #req{}
%%


%% @doc: Returns path split into binary parts.
path(#req{path = Path})                     -> Path.
raw_path(#req{raw_path = Path})             -> Path.
headers(#req{headers = Headers})            -> Headers.
peer(#req{peer = Peer})                     -> Peer.
method(#req{method = Method})               -> Method.
body(#req{body = Body})                     -> Body.

get_header(Key, #req{headers = Headers}) ->
    proplists:get_value(Key, Headers).

get_header(Key, #req{headers = Headers}, Default) ->
    proplists:get_value(Key, Headers, Default).

get_arg(Key, #req{} = Req) ->
    get_arg(Key, Req, undefined).

get_arg(_Key, #req{args = []}, Default) ->
    Default;
get_arg(Key, #req{args = Args}, Default) ->
    proplists:get_value(Key, Args, Default).

%% @doc Parses application/x-www-form-urlencoded body into a proplist
body_qs(#req{body = Body}) ->
    elli_http:split_args(Body).


-spec get_args(#req{}) -> QueryArgs :: proplists:proplist().
%% @doc Returns a proplist of keys and values of the original query
%%      string.  Both keys and values in the returned proplists will
%%      be binaries or the atom `true' in case no value was supplied
%%      for the query key.
get_args(#req{args = Args}) -> Args.
{'fraction_non_alphanumeric': 0.1412859560067682, 'fraction_numerical': 0.009588268471517203, 'mean_word_length': 2.1983769161406674, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3473547', 'n_tokens_mistral': 1186, 'n_tokens_neox': 1147, 'n_words': 279}