@@ -323,17 +323,17 @@ execute_callback(#req{callback = {Mod, Args}} = Req) ->
323
323
catch
324
324
throw :{ResponseCode , Headers , Body } when is_integer (ResponseCode ) ->
325
325
{response , ResponseCode , Headers , Body };
326
- ? WITH_STACKTRACE ( throw , Exc , Stacktrace )
326
+ throw : Exc : Stacktrace ->
327
327
handle_event (Mod , request_throw ,
328
328
[Req , Exc , Stacktrace ],
329
329
Args ),
330
330
{response , 500 , [], <<" Internal server error" >>};
331
- ? WITH_STACKTRACE ( error , Error , Stacktrace )
331
+ error : Error : Stacktrace ->
332
332
handle_event (Mod , request_error ,
333
333
[Req , Error , Stacktrace ],
334
334
Args ),
335
335
{response , 500 , [], <<" Internal server error" >>};
336
- ? WITH_STACKTRACE ( exit , Exit , Stacktrace )
336
+ exit : Exit : Stacktrace ->
337
337
handle_event (Mod , request_exit ,
338
338
[Req , Exit , Stacktrace ],
339
339
Args ),
@@ -708,7 +708,6 @@ is_header_defined(Key, Headers) ->
708
708
get_header (Key , Headers ) ->
709
709
get_header (Key , Headers , undefined ).
710
710
711
- -ifdef (OTP_RELEASE ).
712
711
get_header (Key , Headers , Default ) ->
713
712
CaseFoldedKey = string :casefold (Key ),
714
713
case lists :search (fun ({N , _ }) -> string :equal (CaseFoldedKey , N , true ) end , Headers ) of
@@ -717,68 +716,23 @@ get_header(Key, Headers, Default) ->
717
716
false ->
718
717
Default
719
718
end .
720
- -else .
721
- get_header (Key , Headers , Default ) ->
722
- CaseFoldedKey = string :casefold (Key ),
723
- case search (fun ({N , _ }) -> string :equal (CaseFoldedKey , N , true ) end , Headers ) of
724
- {value , {_ , Value }} ->
725
- Value ;
726
- false ->
727
- Default
728
- end .
729
-
730
- search (Pred , [Hd |Tail ]) ->
731
- case Pred (Hd ) of
732
- true -> {value , Hd };
733
- false -> search (Pred , Tail )
734
- end ;
735
- search (Pred , []) when is_function (Pred , 1 ) ->
736
- false .
737
- -endif .
738
719
739
720
% %
740
721
% % PATH HELPERS
741
722
% %
742
723
743
- -ifdef (OTP_RELEASE ).
744
- -if (? OTP_RELEASE >= 22 ).
745
- parse_path ({abs_path , FullPath }) ->
746
- URIMap = uri_string :parse (FullPath ),
747
- Host = maps :get (host , URIMap , undefined ),
748
- Scheme = maps :get (scheme , URIMap , undefined ),
749
- Path = maps :get (path , URIMap , <<>>),
750
- Query = maps :get (query , URIMap , <<>>),
751
- Port = maps :get (port , URIMap , case Scheme of http -> 80 ; https -> 443 ; _ -> undefined end ),
752
- {ok , {Scheme , Host , Port }, {Path , split_path (Path ), uri_string :dissect_query (Query )}};
753
- parse_path ({absoluteURI , Scheme , Host , Port , Path }) ->
754
- setelement (2 , parse_path ({abs_path , Path }), {Scheme , Host , Port });
755
- parse_path (_ ) ->
756
- {error , unsupported_uri }.
757
- -else .
758
- parse_path ({abs_path , FullPath }) ->
759
- Parsed = case binary :split (FullPath , [<<" ?" >>]) of
760
- [URL ] -> {FullPath , split_path (URL ), []};
761
- [URL , Args ] -> {FullPath , split_path (URL ), split_args (Args )}
762
- end ,
763
- {ok , {undefined , undefined , undefined }, Parsed };
764
- parse_path ({absoluteURI , Scheme , Host , Port , Path }) ->
765
- setelement (2 , parse_path ({abs_path , Path }), {Scheme , Host , Port });
766
- parse_path (_ ) ->
767
- {error , unsupported_uri }.
768
- -endif .
769
- -else .
770
- % % same as else branch above. can drop this when only OTP 21+ is supported
771
- parse_path ({abs_path , FullPath }) ->
772
- Parsed = case binary :split (FullPath , [<<" ?" >>]) of
773
- [URL ] -> {FullPath , split_path (URL ), []};
774
- [URL , Args ] -> {FullPath , split_path (URL ), split_args (Args )}
775
- end ,
776
- {ok , {undefined , undefined , undefined }, Parsed };
777
- parse_path ({absoluteURI , Scheme , Host , Port , Path }) ->
778
- setelement (2 , parse_path ({abs_path , Path }), {Scheme , Host , Port });
779
- parse_path (_ ) ->
780
- {error , unsupported_uri }.
781
- -endif .
724
+ parse_path ({abs_path , FullPath }) ->
725
+ URIMap = uri_string :parse (FullPath ),
726
+ Host = maps :get (host , URIMap , undefined ),
727
+ Scheme = maps :get (scheme , URIMap , undefined ),
728
+ Path = maps :get (path , URIMap , <<>>),
729
+ Query = maps :get (query , URIMap , <<>>),
730
+ Port = maps :get (port , URIMap , case Scheme of http -> 80 ; https -> 443 ; _ -> undefined end ),
731
+ {ok , {Scheme , Host , Port }, {Path , split_path (Path ), uri_string :dissect_query (Query )}};
732
+ parse_path ({absoluteURI , Scheme , Host , Port , Path }) ->
733
+ setelement (2 , parse_path ({abs_path , Path }), {Scheme , Host , Port });
734
+ parse_path (_ ) ->
735
+ {error , unsupported_uri }.
782
736
783
737
split_path (Path ) ->
784
738
[P || P <- binary :split (Path , [<<" /" >>], [global ]),
@@ -813,7 +767,7 @@ handle_event(Mod, Name, EventArgs, ElliArgs) ->
813
767
try
814
768
Mod :handle_event (Name , EventArgs , ElliArgs )
815
769
catch
816
- ? WITH_STACKTRACE ( EvClass , EvError , Stacktrace )
770
+ EvClass : EvError : Stacktrace ->
817
771
? LOG_ERROR (" ~p :handle_event/3 crashed ~p :~p~n~p " ,
818
772
[Mod , EvClass , EvError , Stacktrace ])
819
773
end .
0 commit comments