home *** CD-ROM | disk | FTP | other *** search
/ Netrunner 2004 October / NETRUNNER0410.ISO / regular / ActivePerl-5.8.4.810-MSWin32-x86.msi / _4d3fc075fae902597e9999ab52aee4f8 < prev    next >
Encoding:
Text File  |  2004-06-01  |  6.1 KB  |  196 lines

  1. # ======================================================================
  2. #
  3. # Copyright (C) 2000-2001 Paul Kulchenko (paulclinger@yahoo.com)
  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: HTTP.pm,v 1.5 2001/10/14 18:11:27 paulk Exp $
  8. #
  9. # ======================================================================
  10.  
  11. package XMLRPC::Transport::HTTP;
  12.  
  13. use strict;
  14. use vars qw($VERSION);
  15. $VERSION = sprintf("%d.%s", map {s/_//g; $_} q$Name: release-0_55-public $ =~ /-(\d+)_([\d_]+)/);
  16.  
  17. use XMLRPC::Lite;
  18. use SOAP::Transport::HTTP;
  19.  
  20. # ======================================================================
  21.  
  22. package XMLRPC::Transport::HTTP::CGI;
  23.  
  24. @XMLRPC::Transport::HTTP::CGI::ISA = qw(SOAP::Transport::HTTP::CGI);
  25.  
  26. sub initialize; *initialize = \&XMLRPC::Server::initialize;
  27.  
  28. sub make_fault { 
  29.   local $SOAP::Constants::HTTP_ON_FAULT_CODE = 200;
  30.   shift->SUPER::make_fault(@_);
  31. }
  32.  
  33. sub make_response { 
  34.   local $SOAP::Constants::DO_NOT_USE_CHARSET = 1;
  35.   shift->SUPER::make_response(@_);
  36. }
  37.  
  38. # ======================================================================
  39.  
  40. package XMLRPC::Transport::HTTP::Daemon;
  41.  
  42. @XMLRPC::Transport::HTTP::Daemon::ISA = qw(SOAP::Transport::HTTP::Daemon);
  43.  
  44. sub initialize; *initialize = \&XMLRPC::Server::initialize;
  45. sub make_fault; *make_fault = \&XMLRPC::Transport::HTTP::CGI::make_fault;
  46. sub make_response; *make_response = \&XMLRPC::Transport::HTTP::CGI::make_response; 
  47.  
  48. # ======================================================================
  49.  
  50. package XMLRPC::Transport::HTTP::Apache;
  51.  
  52. @XMLRPC::Transport::HTTP::Apache::ISA = qw(SOAP::Transport::HTTP::Apache);
  53.  
  54. sub initialize; *initialize = \&XMLRPC::Server::initialize;
  55. sub make_fault; *make_fault = \&XMLRPC::Transport::HTTP::CGI::make_fault;
  56. sub make_response; *make_response = \&XMLRPC::Transport::HTTP::CGI::make_response; 
  57.  
  58. # ======================================================================
  59.  
  60. 1;
  61.  
  62. __END__
  63.  
  64. =head1 NAME
  65.  
  66. XMLRPC::Transport::HTTP - Server/Client side HTTP support for XMLRPC::Lite
  67.  
  68. =head1 SYNOPSIS
  69.  
  70. =over 4
  71.  
  72. =item Client
  73.  
  74.   use XMLRPC::Lite 
  75.     proxy => 'http://localhost/', 
  76.   # proxy => 'http://localhost/cgi-bin/xmlrpc.cgi', # local CGI server
  77.   # proxy => 'http://localhost/',                   # local daemon server
  78.   # proxy => 'http://login:password@localhost/cgi-bin/xmlrpc.cgi', # local CGI server with authentication
  79.   ;
  80.  
  81.   print getStateName(1);
  82.  
  83. =item CGI server
  84.  
  85.   use XMLRPC::Transport::HTTP;
  86.  
  87.   my $server = XMLRPC::Transport::HTTP::CGI
  88.     -> dispatch_to('methodName')
  89.     -> handle
  90.   ;
  91.  
  92. =item Daemon server
  93.  
  94.   use XMLRPC::Transport::HTTP;
  95.  
  96.   my $daemon = XMLRPC::Transport::HTTP::Daemon
  97.     -> new (LocalPort => 80)
  98.     -> dispatch_to('methodName')
  99.   ;
  100.   print "Contact to XMLRPC server at ", $daemon->url, "\n";
  101.   $daemon->handle;
  102.  
  103. =back
  104.  
  105. =head1 DESCRIPTION
  106.  
  107. This class encapsulates all HTTP related logic for a XMLRPC server,
  108. independent of what web server it's attached to. 
  109. If you want to use this class you should follow simple guideline
  110. mentioned above. 
  111.  
  112. =head2 PROXY SETTINGS
  113.  
  114. You can use any proxy setting you use with LWP::UserAgent modules:
  115.  
  116.  XMLRPC::Lite->proxy('http://endpoint.server/', 
  117.                      proxy => ['http' => 'http://my.proxy.server']);
  118.  
  119. or
  120.  
  121.  $xmlrpc->transport->proxy('http' => 'http://my.proxy.server');
  122.  
  123. should specify proxy server for you. And if you use C<HTTP_proxy_user> 
  124. and C<HTTP_proxy_pass> for proxy authorization SOAP::Lite should know 
  125. how to handle it properly. 
  126.  
  127. =head2 COOKIE-BASED AUTHENTICATION
  128.  
  129.   use HTTP::Cookies;
  130.  
  131.   my $cookies = HTTP::Cookies->new(ignore_discard => 1);
  132.     # you may also add 'file' if you want to keep them between sessions
  133.  
  134.   my $xmlrpc = XMLRPC::Lite->proxy('http://localhost/');
  135.   $xmlrpc->transport->cookie_jar($cookies);
  136.  
  137. Cookies will be taken from response and provided for request. You may
  138. always add another cookie (or extract what you need after response)
  139. with HTTP::Cookies interface.
  140.  
  141. You may also do it in one line:
  142.  
  143.   $xmlrpc->proxy('http://localhost/', 
  144.                  cookie_jar => HTTP::Cookies->new(ignore_discard => 1));
  145.  
  146. =head2 COMPRESSION
  147.  
  148. XMLRPC::Lite provides you option for enabling compression on wire (for HTTP 
  149. transport only). Both server and client should support this capability, 
  150. but this logic should be absolutely transparent for your application. 
  151. Server will respond with encoded message only if client can accept it 
  152. (client sends Accept-Encoding with 'deflate' or '*' values) and client 
  153. has fallback logic, so if server doesn't understand specified encoding 
  154. (Content-Encoding: deflate) and returns proper error code 
  155. (415 NOT ACCEPTABLE) client will repeat the same request not encoded and 
  156. will store this server in per-session cache, so all other requests will 
  157. go there without encoding.
  158.  
  159. Having options on client and server side that let you specify threshold
  160. for compression you can safely enable this feature on both client and 
  161. server side.
  162.  
  163. Compression will be enabled on client side IF: threshold is specified AND
  164. size of current message is bigger than threshold AND module Compress::Zlib
  165. is available. Client will send header 'Accept-Encoding' with value 'deflate'
  166. if threshold is specified AND module Compress::Zlib is available.
  167.  
  168. Server will accept compressed message if module Compress::Zlib is available,
  169. and will respond with compressed message ONLY IF: threshold is specified AND
  170. size of current message is bigger than threshold AND module Compress::Zlib
  171. is available AND header 'Accept-Encoding' is presented in request.
  172.  
  173. =head1 DEPENDENCIES
  174.  
  175.  Crypt::SSLeay             for HTTPS/SSL
  176.  HTTP::Daemon              for XMLRPC::Transport::HTTP::Daemon
  177.  Apache, Apache::Constants for XMLRPC::Transport::HTTP::Apache
  178.  
  179. =head1 SEE ALSO
  180.  
  181.  See ::CGI, ::Daemon and ::Apache for implementation details.
  182.  See examples/XMLRPC/* for examples.
  183.  
  184. =head1 COPYRIGHT
  185.  
  186. Copyright (C) 2000-2001 Paul Kulchenko. All rights reserved.
  187.  
  188. This library is free software; you can redistribute it and/or modify
  189. it under the same terms as Perl itself.
  190.  
  191. =head1 AUTHOR
  192.  
  193. Paul Kulchenko (paulclinger@yahoo.com)
  194.  
  195. =cut
  196.