various fixes for http_uri.erl
Igor Goryachev
goryachev@REDACTED
Mon Jul 3 11:53:30 CEST 2006
Hello.
Here are several improvements for URI parsing in http_uri.erl. First is
for handling data not only in US ASCII charset:
*** Before:
> http_uri:parse("http://www.google.com/search?hl=en&q=a%D1%85%D1%83%D0%B9&btnG=Google+Search").
{error,no_query}
*** After:
> http_uri:parse("http://www.google.com/search?hl=en&q=a%D1%85%D1%83%D0%B9&btnG=Google+Search").
{http,"www.google.com",
80,
"/search",
"?hl=en&q=a%d1%85%d1%83%d0%b9&btnG=Google+Search"}
Second allows to handle arbitary data:
*** Before:
> http_uri:parse("http://www.google.com/search?hl=en&q=%25%25").
=ERROR REPORT==== 3-Jul-2006::13:19:49 ===
Error in process <0.32.0> with exit value: {function_clause,[{http_uri,hex2dec,"%"},{http_uri,scan_query,2},{http_uri,scan_pathquery,1},{http_uri,parse_http,2},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]}
** exited: {function_clause,[{http_uri,hex2dec,"%"},
{http_uri,scan_query,2},
{http_uri,scan_pathquery,1},
{http_uri,parse_http,2},
{erl_eval,do_apply,5},
{shell,exprs,6},
{shell,eval_loop,3}]} **
> http_uri:parse("http://www.google.com/search?hl=en&q=%foo").
=ERROR REPORT==== 3-Jul-2006::13:28:33 ===
Error in process <0.39.0> with exit value: {function_clause,[{http_uri,hex2dec,"o"},{http_uri,scan_query,2},{http_uri,scan_pathquery,1},{http_uri,parse_http,2},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]}
** exited: {function_clause,[{http_uri,hex2dec,"o"},
{http_uri,scan_query,2},
{http_uri,scan_pathquery,1},
{http_uri,parse_http,2},
{erl_eval,do_apply,5},
{shell,exprs,6},
{shell,eval_loop,3}]} **
*** After:
> http_uri:parse("http://www.google.com/search?hl=en&q=%25%25").
{http,"www.google.com",80,"/search","?hl=en&q=%25%25"}
> http_uri:parse("http://www.google.com/search?hl=en&q=%foo").
{http,"www.google.com",80,"/search","?hl=en&q=%25foo"}
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: http_uri_fixes.diff
URL: <http://erlang.org/pipermail/erlang-patches/attachments/20060703/84654666/attachment.ksh>
-------------- next part --------------
--
Igor Goryachev
Yandex development team.
More information about the erlang-patches
mailing list