Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

181 lines
5.5 KiB

  1. # ======================================================================
  2. #
  3. # Copyright (C) 2000-2001 Paul Kulchenko ([email protected])
  4. # SOAP::Lite is free software; you can redistribute it
  5. # and/or modify it under the same terms as Perl itself.
  6. #
  7. # $Id: XMLRPC::Transport::HTTP.pm,v 0.51 2001/07/18 15:15:14 $
  8. #
  9. # ======================================================================
  10. package XMLRPC::Transport::HTTP;
  11. use strict;
  12. use vars qw($VERSION);
  13. $VERSION = '0.51';
  14. use XMLRPC::Lite;
  15. use SOAP::Transport::HTTP;
  16. # ======================================================================
  17. package XMLRPC::Transport::HTTP::CGI;
  18. @XMLRPC::Transport::HTTP::CGI::ISA = qw(SOAP::Transport::HTTP::CGI);
  19. sub initialize; *initialize = \&XMLRPC::Server::initialize;
  20. # ======================================================================
  21. package XMLRPC::Transport::HTTP::Daemon;
  22. @XMLRPC::Transport::HTTP::Daemon::ISA = qw(SOAP::Transport::HTTP::Daemon);
  23. sub initialize; *initialize = \&XMLRPC::Server::initialize;
  24. # ======================================================================
  25. package XMLRPC::Transport::HTTP::Apache;
  26. @XMLRPC::Transport::HTTP::Apache::ISA = qw(SOAP::Transport::HTTP::Apache);
  27. sub initialize; *initialize = \&XMLRPC::Server::initialize;
  28. # ======================================================================
  29. 1;
  30. __END__
  31. =head1 NAME
  32. XMLRPC::Transport::HTTP - Server/Client side HTTP support for XMLRPC::Lite
  33. =head1 SYNOPSIS
  34. =over 4
  35. =item Client
  36. use XMLRPC::Lite
  37. proxy => 'http://localhost/',
  38. # proxy => 'http://localhost/cgi-bin/xmlrpc.cgi', # local CGI server
  39. # proxy => 'http://localhost/', # local daemon server
  40. # proxy => 'http://login:password@localhost/cgi-bin/xmlrpc.cgi', # local CGI server with authentication
  41. ;
  42. print getStateName(1);
  43. =item CGI server
  44. use XMLRPC::Transport::HTTP;
  45. my $server = XMLRPC::Transport::HTTP::CGI
  46. -> dispatch_to('methodName')
  47. -> handle
  48. ;
  49. =item Daemon server
  50. use XMLRPC::Transport::HTTP;
  51. my $daemon = XMLRPC::Transport::HTTP::Daemon
  52. -> new (LocalPort => 80)
  53. -> dispatch_to('methodName')
  54. ;
  55. print "Contact to XMLRPC server at ", $daemon->url, "\n";
  56. $daemon->handle;
  57. =back
  58. =head1 DESCRIPTION
  59. This class encapsulates all HTTP related logic for a XMLRPC server,
  60. independent of what web server it's attached to.
  61. If you want to use this class you should follow simple guideline
  62. mentioned above.
  63. =head2 PROXY SETTINGS
  64. You can use any proxy setting you use with LWP::UserAgent modules:
  65. XMLRPC::Lite->proxy('http://endpoint.server/',
  66. proxy => ['http' => 'http://my.proxy.server']);
  67. or
  68. $xmlrpc->transport->proxy('http' => 'http://my.proxy.server');
  69. should specify proxy server for you. And if you use C<HTTP_proxy_user>
  70. and C<HTTP_proxy_pass> for proxy authorization SOAP::Lite should know
  71. how to handle it properly.
  72. =head2 COOKIE-BASED AUTHENTICATION
  73. use HTTP::Cookies;
  74. my $cookies = HTTP::Cookies->new(ignore_discard => 1);
  75. # you may also add 'file' if you want to keep them between sessions
  76. my $xmlrpc = XMLRPC::Lite->proxy('http://localhost/');
  77. $xmlrpc->transport->cookie_jar($cookies);
  78. Cookies will be taken from response and provided for request. You may
  79. always add another cookie (or extract what you need after response)
  80. with HTTP::Cookies interface.
  81. You may also do it in one line:
  82. $xmlrpc->proxy('http://localhost/',
  83. cookie_jar => HTTP::Cookies->new(ignore_discard => 1));
  84. =head2 COMPRESSION
  85. XMLRPC::Lite provides you option for enabling compression on wire (for HTTP
  86. transport only). Both server and client should support this capability,
  87. but this logic should be absolutely transparent for your application.
  88. Server will respond with encoded message only if client can accept it
  89. (client sends Accept-Encoding with 'deflate' or '*' values) and client
  90. has fallback logic, so if server doesn't understand specified encoding
  91. (Content-Encoding: deflate) and returns proper error code
  92. (415 NOT ACCEPTABLE) client will repeat the same request not encoded and
  93. will store this server in per-session cache, so all other requests will
  94. go there without encoding.
  95. Having options on client and server side that let you specify threshold
  96. for compression you can safely enable this feature on both client and
  97. server side.
  98. Compression will be enabled on client side IF: threshold is specified AND
  99. size of current message is bigger than threshold AND module Compress::Zlib
  100. is available. Client will send header 'Accept-Encoding' with value 'deflate'
  101. if threshold is specified AND module Compress::Zlib is available.
  102. Server will accept compressed message if module Compress::Zlib is available,
  103. and will respond with compressed message ONLY IF: threshold is specified AND
  104. size of current message is bigger than threshold AND module Compress::Zlib
  105. is available AND header 'Accept-Encoding' is presented in request.
  106. =head1 DEPENDENCIES
  107. Crypt::SSLeay for HTTPS/SSL
  108. HTTP::Daemon for XMLRPC::Transport::HTTP::Daemon
  109. Apache, Apache::Constants for XMLRPC::Transport::HTTP::Apache
  110. =head1 SEE ALSO
  111. See ::CGI, ::Daemon and ::Apache for implementation details.
  112. See examples/XMLRPC/* for examples.
  113. =head1 COPYRIGHT
  114. Copyright (C) 2000-2001 Paul Kulchenko. All rights reserved.
  115. This library is free software; you can redistribute it and/or modify
  116. it under the same terms as Perl itself.
  117. =head1 AUTHOR
  118. Paul Kulchenko (paulclinger@yahoo.com)
  119. =cut