request(Method,
{Url, Headers, ContentType, TupleBody},
HTTPOptions, Options, Profile)
when ((Method =:= post) orelse (Method =:= patch) orelse (Method =:= put) orelse (Method =:= delete))
andalso (is_atom(Profile) orelse is_pid(Profile)) andalso
is_list(ContentType) andalso is_tuple(TupleBody)->
case check_body_gen(TupleBody) of
ok ->
do_request(Method, {Url, Headers, ContentType, TupleBody}, HTTPOptions, Options, Profile);
Error ->
Error
end;
request(Method,
{Url, Headers, ContentType, Body},
HTTPOptions, Options, Profile)
when ((Method =:= post) orelse (Method =:= patch) orelse (Method =:= put) orelse (Method =:= delete))
andalso (is_atom(Profile) orelse is_pid(Profile)) andalso
is_list(ContentType) andalso (is_list(Body) orelse is_binary(Body)) ->
do_request(Method, {Url, Headers, ContentType, Body}, HTTPOptions, Options, Profile);
request(Method,
{Url, Headers},
HTTPOptions, Options, Profile)
when (Method =:= options) orelse
(Method =:= get) orelse
(Method =:= put) orelse
(Method =:= head) orelse
(Method =:= delete) orelse
(Method =:= trace) andalso
(is_atom(Profile) orelse is_pid(Profile)) ->
case uri_string:parse(uri_string:normalize(Url)) of
{error, Reason, _} ->
{error, Reason};
ParsedUrl ->
case header_parse(Headers) of
{error, Reason} ->
{error, Reason};
_ ->
handle_request(Method, Url, ParsedUrl, Headers, [], [],
HTTPOptions, Options, Profile)
end
end.