Changeset f0e0bf3ddd65ef79563e54f065ca6626deeeea1f in xas


Ignore:
Timestamp:
10/31/14 12:00:08 (5 years ago)
Author:
Kevin L. Esteb <kevin@…>
Branches:
master
Children:
91b017ea5b23ccf691f883c7610d7e7a493633a2
Parents:
df1fbccc60b85dbc061660725dd65744cd97ee5d
git-author:
Kevin L. Esteb <kevin@…> (10/31/14 12:00:08)
git-committer:
Kevin L. Esteb <kevin@…> (10/31/14 12:00:08)
Message:

Moved some files around.

Location:
trunk
Files:
3 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/MANIFEST

    r8213d475cf38cd0be39f65822ab8b85033d43762 rf0e0bf3ddd65ef79563e54f065ca6626deeeea1f  
    3030lib/XAS/Lib/App/Services/Unix.pm 
    3131lib/XAS/Lib/App/Services/Win32.pm 
     32lib/XAS/Lib/Curl/HTTP.pm 
    3233lib/XAS/Lib/Curses/Root.pm 
    3334lib/XAS/Lib/Curses/Toolkit.pm 
     
    6768lib/XAS/Lib/Stomp/POE/Filter.pm 
    6869lib/XAS/Lib/Stomp/Utils.pm 
    69 lib/XAS/Lib/WS/Base.pm 
    7070lib/XAS/Msgs/Base.msg 
    7171lib/XAS/Singleton.pm 
  • trunk/lib/XAS.pm

    rf7b6e195066179a1e8d3603ca88a9f19bb1d1339 rf0e0bf3ddd65ef79563e54f065ca6626deeeea1f  
    4848 
    4949=item L<XAS::Lib::App::Services::Win32|XAS::Lib::App::Services::Win32> 
     50 
     51=item L<XAS::Lib::Curl::HTTP|XAS::Lib::Curl::HTTP> 
    5052 
    5153=item L<XAS::Lib::Curses::Root|XAS::Lib::Curses::Root> 
  • trunk/lib/XAS/Lib/Curl/HTTP.pm

    rdf1fbccc60b85dbc061660725dd65744cd97ee5d rf0e0bf3ddd65ef79563e54f065ca6626deeeea1f  
    1 package XAS::Lib::WS::Base; 
     1package XAS::Lib::Curl::HTTP; 
    22 
    33our $VERSION = '0.01'; 
     
    2020      -ssl_verify_peer => { optional => 1, default => 1 }, 
    2121      -ssl_verify_host => { optional => 1, default => 1 }, 
    22       -timeout         => { optional => 1, default => 30 }, 
     22      -timeout         => { optional => 1, default => 60 }, 
    2323      -connect_timeout => { optional => 1, default => 300 }, 
    2424      -ssl_cacert      => { optional => 1, default => undef }, 
     
    3535    } 
    3636  }, 
    37   messages => { 
    38     curl => 'curl error: %s, reason: %s', 
    39   } 
    4037; 
    4138 
     
    4643sub request { 
    4744    my $self = shift; 
    48     my ($request) = validate_pos(@_, 
     45    my ($request) = $self->validate_params(\@_, [ 
    4946        { isa => 'HTTP::Request' } 
    50     ); 
    51  
    52     my @data; 
     47    ]); 
     48 
     49    my @body 
     50    my @head 
    5351    my $response = undef; 
    5452    my $header   = $request->headers->as_string("\n"); 
     
    6260    # I/O for the request 
    6361 
    64     $self->curl->setopt(CURLOPT_WRITEDATA,     \@data); 
    65     $self->curl->setopt(CURLOPT_READFUNCTION,  \&_read_callback); 
    66     $self->curl->setopt(CURLOPT_WRITEFUNCTION, \&_write_callback); 
     62    $self->curl->setopt(CURLOPT_WRITEDATA,      \@body); 
     63    $self->curl->setopy(CURLOPT_HEADERDATA,     \@head); 
     64    $self->curl->setopt(CURLOPT_READFUNCTION,   \&_read_callback); 
     65    $self->curl->setopt(CURLOPT_WRITEFUNCTION,  \&_write_callback); 
     66    $self->curl->setopt(CURLOPT_HEADERFUNCTION, \&_write_callback); 
    6767 
    6868    # other options depending on request type 
     
    110110        my $content; 
    111111 
    112         # there may have been multiple responses collected, we only 
     112        # there may be multiple responses within head, we only 
    113113        # want the last one. so search backwards until a HTTP header 
    114114        # is found. 
    115115 
    116         while (my $line = pop(@data)) { 
     116        while (my $line = pop(@head)) { 
    117117 
    118118            push(@temp, $line); 
    119             last if ($line =~ /(^HTTP\/|^HTTPS\/)/); 
     119            last if ($line =~ /^HTTP\//); 
    120120 
    121121        } 
    122122 
    123         $content = join('', reverse(@temp)); 
     123        $content = join('', reverse(@temp), @body); 
    124124 
    125125        # now let HTTP::Response figure it all out... 
     
    268268=head1 NAME 
    269269 
    270 XAS::Lib::WS::Base - A class for the XAS environment 
     270XAS::Lib::Curl::HTTP - A class for the XAS environment 
    271271 
    272272=head1 SYNOPSIS 
    273273 
    274  use XAS::Lib::WS::Base; 
     274 use HTTP::Request; 
     275 use XAS::Lib::Curl::HTTP; 
     276 
     277 my $response; 
     278 my $request = HTTP::Request->new(GET => 'http://scm.kesteb.us/trac'); 
     279 my $ua = XAS::Lib::Curl::HTTP->new(); 
     280 
     281 $response = $ua->request($request); 
     282 print $response->content; 
    275283 
    276284=head1 DESCRIPTION 
    277285 
     286This module uses L<http://curl.haxx.se/libcurl/|libcurl> as the HTTP engine  
     287to make requests from a web server.  
     288 
    278289=head1 METHODS 
    279290 
    280 =head2 method1 
     291=head2 new 
     292 
     293This method initializes the module and takes the following parameters: 
     294 
     295=over 4 
     296 
     297=item B<-headers>          
     298 
     299A toggle to tell curl to display headers, defaults to false. 
     300 
     301=item B<-keep_alive>  
     302 
     303A toggle to place a "Connection: close" header into the request, 
     304defaults to yes. 
     305 
     306=item B<-followlocation> 
     307 
     308A toggle to follow redirects, defaults to true. 
     309 
     310=item B<-max_redirects> 
     311 
     312The number of redirects to follow, defaults to 3. 
     313 
     314=item B<-timeout> 
     315 
     316The timeout for the connection, defaults to 60 seconds. 
     317 
     318=item B<-connect_timeout> 
     319 
     320The timeout for the initial connection, defaults to 300 seconds. 
     321 
     322=item B<-ssl_cacert> 
     323 
     324An optional CA cerificate to use. 
     325 
     326=item B<-ssl_keypasswd> 
     327 
     328An optional password for a signed cerificate. 
     329 
     330=item B<-ssl_cert> 
     331 
     332An optional certificate to use. 
     333 
     334=item B<-ssl_key> 
     335 
     336An optional key for a certificate to use. 
     337 
     338=item B<-ssl_verify_host> 
     339 
     340Wither to verify the host certifcate, defaults to true. 
     341 
     342=item B<-ssl_verify_peer> 
     343 
     344Wither to verify the peer certificate, defaults to true. 
     345 
     346=item B<-auth_method> 
     347 
     348The authentication method to use, defaults to 'noauth'. Possible 
     349values are 'any', 'basic', 'digest', 'ntlm', 'negotiate'. If a username 
     350and password are supplied, curl defaults to 'basic'. 
     351 
     352=item B<-password> 
     353 
     354An optional password to use, implies a username. Wither the password is 
     355actually used, depends on -auth_method. 
     356 
     357=item B<-username> 
     358 
     359An optional username to use, implies a password. 
     360 
     361=item B<-proxy_url> 
     362 
     363The url of a proxy that needs to be transversed. 
     364 
     365=item B<-proxy_auth> 
     366 
     367The authentication method to use, defaults to 'noauth'. Possible 
     368values are 'any', 'basic', 'digest', 'ntlm', 'negotiate'. If a proxy 
     369username and a proxy password are supplied, curl defaults to 'basic'. 
     370 
     371=item B<-proxy_password> 
     372 
     373An optional password to use, implies a username. Wither the password is 
     374actually used, depends on -proxy_auth. 
     375 
     376=item B<-proxy_username> 
     377 
     378An optional username to use, implies a password. 
     379 
     380=back 
     381 
     382=head2 request($request) 
     383 
     384This method sends the requset to the web server. The request will return 
     385a L<HTTP::Response|HTTP::Response> object. It takes the following parameters: 
     386 
     387=over 4 
     388 
     389=item B<$request> 
     390 
     391A L<HTTP::Request|HTTP::Request> object. 
     392 
     393=back 
    281394 
    282395=head1 SEE ALSO 
     396 
     397=over 4 
     398 
     399=item L<XAS|XAS> 
     400 
     401=item L<WWW::Curl|WWW::Curl> 
     402 
     403=item L<http://curl.haxx.se/libcurl/|libcurl> 
     404 
     405=back 
    283406 
    284407=head1 AUTHOR 
  • trunk/lib/XAS/Msgs/Base.msg

    rc5596c0d76dbacce5903e2d68a28b383557884c6 rf0e0bf3ddd65ef79563e54f065ca6626deeeea1f  
    6868json_rpc_batch    = the usage of json-rpc batch mode is not supported 
    6969json_rpc_notify   = the usage of json-rpc notifications is not supported 
     70curl              = curl error: %s, reason: %s 
Note: See TracChangeset for help on using the changeset viewer.