testuri.pp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2003 by the Free Pascal development team
  4. Test uriparser unit
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. {$MODE objfpc}
  12. {$H+}
  13. program Testuri;
  14. uses URIParser;
  15. var
  16. URI: TURI;
  17. s: String;
  18. begin
  19. with URI do
  20. begin
  21. Protocol := 'http';
  22. Username := 'user';
  23. Password := 'pass';
  24. Host := 'localhost';
  25. Port := 8080;
  26. Path := '/test/dir';
  27. Document := 'some index.html';
  28. Params := 'param1=value1&param2=value2';
  29. Bookmark := 'bookmark';
  30. end;
  31. s := EncodeURI(URI);
  32. WriteLn(s);
  33. FillChar(URI, SizeOf(URI), #0);
  34. // URI := ParseURI(s, 'defaultprotocol', 1234);
  35. URI:=ParseURI('http://www.lazarus.freepascal.org/main.php');
  36. with URI do
  37. begin
  38. WriteLn('Protocol: ', Protocol);
  39. WriteLn('Username: ', Username);
  40. WriteLn('Password: ', Password);
  41. WriteLn('Host: ', Host);
  42. WriteLn('Port: ', Port);
  43. WriteLn('Path: ', Path);
  44. WriteLn('Document: ', Document);
  45. WriteLn('Params: ', Params);
  46. WriteLn('Bookmark: ', Bookmark);
  47. end;
  48. end.