....................................../////.===Shadow-Here===./////................................................ > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < ------------------------------------------------------------------------------------------------------------------- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// RIFF¤ WEBPVP8 ˜ ðÑ *ôô>‘HŸK¥¤"§£±¨àð enü¹%½_F‘åè¿2ºQú³íªú`N¿­3ÿƒügµJžaÿ¯ÿ°~¼ÎùnúîÞÖô•òíôÁÉß®Sm¥Ü/ ‡ó˜f£Ùà<˜„xëJ¢Ù€SO3x<ªÔ©4¿+ç¶A`q@Ì“Úñè™ÍÿJÌ´ª-˜ÆtÊÛL]Ïq*‘Ý”ì#ŸÌÏãY]@ê`¿ /ªfkØB4·®£ó z—Üw¥Pxù–ÞLШKÇN¾AkÙTf½è'‰g gÆv›Øuh~ a˜Z— ïj*á¥t d£“uÒ ¨`K˜¹ßþ]b>˜]_ÏÔ6W—è2r4x•íÖ…"ƒÖNîä!¦å Ú}ýxGøÌ —@ ;ÆÚŠ=ɾ1ý8lªË¥ô ^yf®Œ¢u&2©nÙÇ›ñÂñŒ³ aPo['½»øFùà­+4ê“$!lövlüÞ=;N®3ð‚õ›DÉKòÞ>ÄÍ ¥ˆuߤ#ˆ$6ù™¥îЇy’ÍB¼ çxÛ;X"WL£R÷͝*ó-¶Zu}º.s¸sšXqù–DþÿvªhüïwyŸ ¯é³lÀ:KCûÄ£Ëá\…­ ~—ýóî ¼ûûÜTÓüÇy…ŽÆvc»¾×U ñ¸žþоP÷¦ó:Ò¨¨5;Ð#&#ÖúñläÿÁœ GxÉ­/ñ‡áQðìYÉtÒw޼GÔ´zàÒò ð*ëzƒ•4~H]Ø‹f ñÓÈñ`NåWçs'ÆÏW^ø¹!XžµmQ5ÃËoLœÎ: ÞËÍ¥J ù…î èo£ßPÎñ¶ž8.Œ]ʵ~5›ÙË-ù*8ÙÖß±~ ©¹rÓê‚j¶d¸{^Q'˜±Crß ÚH—#¥¥QlÀ×ëã‡DÜ«èî þ&Çæžî;ŽÏºò6ÒLÃXy&ZŒ'j‚¢Ù€IßÚù+–MGi‰*jE€‘JcÜ ÓÌ EÏÚj]o˜ Þr <¾U ûŪæÍ/šÝH¥˜b”¼ ÁñßX GP›ï2›4WŠÏà×£…íÓk†¦H·ÅíMh–*nó÷à]ÁjCº€b7<ب‹¨5車bp2:Á[UªM„QŒçiNMa#<5›áËó¸HýÊ"…×Éw¹¦ì2º–x<›»a±¸3Weü®FÝ⑱ö–î–³|LPÈ~çð~Çå‡|º kD¢µÏàÆAI %1À% ¹Ò – ”ϝS¦‰4&¶£°à Öý”û_Ò Áw°A«Å€?mÇÛgHÉ/8)á¾ÛìáöŽP í¨PŸNÙµº¦‡§Ùš"ÿ«>+ªÕ`Ê÷‡‚ß Õû˜þãÇ-PÍ.¾XV‘€ dÜ"þ4¹ ±Oú‘©t¥¦FªÄÃÄ•b‚znýu½—#cDs˜ÃiÑOˆñ×QO=*IAÊ,¶ŽZƒ;‡wøXè%EÐk:F±Ú” .Ѽ+Áu&Ç`."pÈÉw o&¿dE6‘’EqTuK@Ì¥ã™À(Êk(h‰,H}RÀIXÛš3µ1©_OqÚÒJAñ$ÊÙÜ;D3çŒ[þùœh¬Ã³™ö6ç†NY".Ú‰ï[ªŸŒ '²Ð öø_¨ÂÉ9ué¶³ÒŠõTàîMØ#û¯gN‡bÙ놚X„ö …ÉeüÌ^J ‹€.œ$Æ)βÄeæW#óüßĺŸ€ ÀzwV 9oä»f4V*uB «Ë†¹ì¯žR霓æHXa=&“I4K;¯ç‹h×·"UŠ~<•╪Vêª&ÍSÃÆÅ?ÔqÎ*mTM ˜›µwêd#[C¡©§‘D<©àb†–ÁœøvH/,í:¯( ²£|4-„Æövv„Yͼ™^Á$ˆ„¢Û[6yB.åH*V¨æ?$=˜Ñ€•ñ·­(VlŸ‘ nÀt8W÷´Bûba?q9ú¶Xƒl«ÿ\ù¶’þòUÐj/õ¢Ìµ³g$ƒÎR!¸»|Oߍë’BhîÚÑ¢ñåŒJ„®„£2Ð3•ô02Nt…!£Í]Ïc½Qÿ?ˆ<&ÃA¾Ú,JˆijÌ#5yz„‰Î|ÊŽ5QÏ:‹ÐaóVÔxW—CpeÏzÐïíçôÿÅ_[hãsÐ_/ŽTÝ?BîˆííV$<¿i>²F¬_Eß¿ †bÊŒº­ÿ®Z H“C}”¬,Mp ý/Bá£w>˜YV°aƒúh+cŠ- r/[%|üUMHäQ°X»|û/@|°¥Ð !BÔ Ç¢Ä©š+Õì D«7ìN¶ŽðÔ " ƶ’ÖçtA‰Û×}{tþz­¾GÍ›k¹OEJR$ Â׃ «ëÁ"oÉôž$oUK(Ä)Ãz³Ê-‹êN[Ò3Œñbï8P 4ƒ×q¢bo|?<ÛX¬òÄͰL–±›(™ûG?ýË©ÚÄ–ÂDØÐ_Ç¡ô ¾–ÄÏø ×e8Ë©$ÄF¹Å‹ì[©óìl:F¾f´‹‹Xì²ï®\¬ôùƒ ÿat¥óèÒùHß0äe‚;ü×h:ÆWðHž=Ã8骣"kœ'Y?³}Tûè€>?0l›e1Lòñ„aæKÆw…hÖŠùW…ÈÆÄ0ši·›[pcwËþñiêíY/~-Á5˜!¿†A›™Mÿþ(±“t@â“ö2­´TG5yé]çå僳 .·ÍïçÝ7UÚ±Ð/Nè»,_Ï ùdj7\ï Wì4›„»c¸àešg#ÒÊ⥭áØo5‘?ÌdÝô¯ ¹kzsƒ=´#ëÉK›Ø´±-¥eW?‡çßtòTã…$Ý+qÿ±ƒ÷_3Ô¥í÷:æ–ž<·Ö‡‰Å¢ š‡%Ô—utÌÈìðžgÖÀz²À—ï÷Óîäõ{K'´È÷³yaÏÁjƒô}ž§®æÊydÕÈë5¯èˆõvÕ©ã*çD„ “z„Ó‡^^xÂ3M§A´JG‚öï 3W'ˆ.OvXè¡ÊÕª?5º7†˜(˜Ç¶#çê’¶!ÌdZK§æ 0fãaN]òY³RV ™î$®K2R¨`W!1Ôó\;Ý ýB%qæK•&ÓÈe9È0êI±žeŸß -ú@žQr¦ ö4»M¼Áè¹µmw 9 EÆE_°2ó„ŸXKWÁ×Hóì^´²GѝF©óäR†¦‰ç"V»eØ<3ùd3ÿÚ¤Žú“Gi" —‘_ÙËÎ~Üö¯¥½Î»üŸEÚŽåmÞþí ;ÞólËΦMzA"Âf(´òá;Éï(/7½ûñÌ­cïÕçлþÝz¾-ÍvÑ“pH­–ðÓj$¸Äû¤‚‘ãUBË-n“2åPkS5&‹Â|+g^œ®Ì͆d!OïäîU«c;{Û!ÅŽ«ëZ9Ókóˆ]¯ƒ›né `ÇÒ+tÆš (ØKá¾—=3œ®•vuMñg²\ï Ec€ 05±d™‡×iÇ×›UúvÌ¢£Èþ¡ÕØô¶ßÎA"ß±#Ö²ˆÊŸ¦*Ä~ij|àø.-¼'»Ú¥£h ofº¦‡VsR=N½„Î v˜Z*SÌ{=jÑB‹tê…;’HžH¯8–îDù8ñ¢|Q•bÛçš–‹m³“ê¨ åÏ^m¬Žãþ©ïêO‡½6] µÆ„Ooòü ²x}N¦Ë3ïé¿»€›HA˜m%çÞ/¿í7Fø“‹léUk)É°Œµ8Q8›:ÀŠeT*šõ~ôڝG6 ¢}`ùH­–”¡k ‰P1>š†®9z11!X wKfmÁ¦xÑ,N1Q”–æB¶M…ÒÃv6SMˆhU¬ÊPŽï‘öj=·CŒ¯u¹ƒVIЃsx4’ömÛýcå¡¶7ßŠß 57^\wÒÐÆ k§h,Œý î«q^R½3]J¸ÇðN ‚çU¬ôº^Áì} ³f©Õœ§ˆã:FÄÈ‚é(€™?àýÓüè1Gô£¼éj‚OÅñ  #>×—ßtà 0G¥Åa뀐kßhc™À_ÉñÞ#±)GD" YîäË-ÿÙ̪ ¹™a¯´¢E\ÝÒö‚;™„ë]_ p8‰o¡ñ+^÷ 3‘'dT4œŽ ðVë½° :¬víÑ«£tßÚS-3¶“þ2 †üüʨòrš¹M{É_¤`Û¨0ìjœøJ‡:÷ÃáZ˜†@GP&œÑDGÏs¡þ¦þDGú‘1Yá9Ôþ¼ ûø…§÷8&–ÜÑnÄ_m®^üÆ`;ÉVÁJ£?â€-ßê}suÍ2sõA NÌúA磸‘îÿÚ»ƒìö·á¿±tÑÐ"Tÿü˜[@/äj¬€uüªìù¥Ý˜á8Ý´sõj 8@rˆð äþZÇD®ÿUÏ2ùôõrBzÆÏÞž>Ì™xœ“ wiÎ×7_… ¸ \#€MɁV¶¥üÕÿPÔ9Z‡ø§É8#H:ƒ5ÀÝå9ÍIŒ5åKÙŠ÷qÄ>1AÈøžj"µÂд/ªnÀ qªã}"iŸBå˜ÓÛŽ¦…&ݧ;G@—³b¯“•"´4í¨ôM¨åñC‹ïùÉó¯ÓsSH2Ý@ßáM‡ˆKÀªÛUeø/4\gnm¥‹ŸŒ qÄ b9ÞwÒNÏ_4Ég³ú=܆‚´ •â¥õeíþkjz>éÚyU«Íӝ݃6"8/ø{=Ô¢»G¥ äUw°W«,ô—¿ãㆅү¢³xŠUû™yŒ (øSópÐ 9\åTâ»—*oG$/×ÍT†Y¿1¤Þ¢_‡ ¼ „±ÍçèSaÓ 3ÛMÁBkxs‰’R/¡¤ˆÙçª(*õ„üXÌ´ƒ E§´¬EF"Ù”R/ÐNyÆÂ^°?™6¡œïJ·±$§?º>ÖüœcNÌù¯G ‹ñ2ЁBB„^·úìaz¨k:#¨Æ¨8LÎõލ£^§S&cŒÐU€ü(‡F±Š¼&P>8ÙÁ ‰ p5?0ÊÆƒZl¸aô š¼¡}gÿ¶zÆC²¹¬ÎÖG*HB¡O<º2#ñŒAƒ–¡B˜´É$¥›É:FÀÔx¾u?XÜÏÓvN©RS{2ʈãk9rmP¼Qq̳ è¼ÐFׄ^¡Öì fE“F4A…!ì/…¦Lƒ… … $%´¾yã@CI¬ á—3PþBÏNÿ<ý°4Ü ËÃ#ØÍ~âW«rEñw‹eùMMHß²`¬Öó½íf³:‹k˜¯÷}Z!ã¿<¥,\#öµÀ¯aÒNÆIé,Ћ–lŽ#Àæ9ÀÒS·I’½-Ïp Äz¤Š Â* ­íÄ9­< h>׍3ZkËU¹§˜ŒŠ±f­’¤º³Q ÏB?‹#µíÃ¥®@(Gs«†vI¥Mµ‹Á©e~2ú³ÁP4ìÕi‚²Ê^ö@-DþÓàlÜOÍ]n"µã:žpsŽ¢:! Aõ.ç~ÓBûH÷JCÌ]õVƒd «ú´QÙEA–¯¯Œ!.ˆˆëQ±ù œ·Ì!Õâ )ùL„ÅÀlÚè5@B…o´Æ¸XÓ&Û…O«˜”_#‡ƒ„ûÈt!¤ÁÏ›ÎÝŠ?c9 â\>lÓÁVÄÑ™£eØY]:fÝ–—ù+p{™ðè û³”g±OƒÚSù£áÁÊ„ä,ï7š²G ÕÌBk)~ÑiCµ|h#u¤¶îK¨² #²vݯGãeÖ϶ú…¾múÀ¶þÔñ‚Š9'^($¤§ò “š½{éúp÷J›ušS¹áªCÂubÃH9™D™/ZöØÁ‡¦ÝÙŸ·kð*_”.C‹{áXó€‡c¡c€§/šò/&éš÷,àéJþ‰X›fµ“C¨œ®r¬"kL‰Â_q…Z–.ÉL~O µ›zn‚¹À¦Öª7\àHµšÖ %»ÇníV[¥*Õ;ƒ#½¾HK-ÖIÊdÏEÚ#=o÷Óò³´Š: Ç?{¾+9›–‘OEáU·S€˜j"ÄaÜ ŒÛWt› á–c#a»pÔZÞdŽtWê=9éöÊ¢µ~ ë ;Öe‡Œ®:bî3±ýê¢wà¼îpêñ¹¾4 zc¾ðÖÿzdêŒÑÒŝÀ‰s6¤í³ÎÙB¿OZ”+F¤á‡3@Ñëäg©·Ž ˆèª<ù@É{&S„œÕúÀA)‰h:YÀ5^ÂÓŒ°õäU\ ùËÍû#²?Xe¬tu‰^zÒÔãë¼ÛWtEtû …‚g¶Úüâî*moGè¨7%u!]PhÏd™Ý%Îx: VÒ¦ôÊD3ÀŽKÛËãvÆî…N¯ä>Eró–ð`5 Œ%u5XkñÌ*NU%¶áœÊ:Qÿú»“úzyÏ6å-၇¾ ´ ÒÊ]y žO‘w2Äøæ…H’²f±ÎÇ.ª|¥'gîV•Ü .̘¯€šòü¤U~Ù†*¢!?ò wý,}´°ÔÞnïoKq5µb!áÓ3"vAßH¡³¡·G(ÐÎ0Îò¼MG!/ài®@—¬04*`…«é8ªøøló“ˆÊ”èù¤…ßÊoÿé'ËuÌÖ5×È¡§ˆˆfŽë9}hìâ_!!¯  B&Ëö¶‰ÀAÙNVŸ Wh›¸®XÑJì¨ú“¿÷3uj²˜¨ÍÎìë±aúŠÝå¯ð*Ó¨ôJ“yºØ)m°WýOè68†ŸÏ2—‰Ïüꪫٚ¥‹l1 ø ÏÄFjêµvÌbü¦èÝx:X±¢H=MÐß—,ˆÉÇ´(9ú¾^ÅÚ4¿m‡$âX‘å%(AlZo@½¨UOÌÕ”1ø¸jÎÀÃÃ_ µ‘Ü.œº¦Ut: Æï’!=¯uwû#,“pþÇúŒø(é@?³ü¥‘Mo §—s@Œ#)§ŒùkL}NOÆêA›¸~r½¼ÙA—HJ«eˆÖ´*¡ÓpÌŸö.m<-"³ûÈ$¬_6­åf£ïÚâj1y§ÕJ½@dÞÁr&Í\Z%D£Íñ·AZ Û³øüd/ªAi†/Й~  ‡âĮҮÏh§°b—›Û«mJžòG'[ÈYýŒ¦9psl ýÁ ®±f¦x,‰½tN ‚Xª9 ÙÖH.«Lo0×?͹m¡å†Ѽ+›2ƒF ±Ê8 7Hցϓ²Æ–m9…òŸï]Â1äN†VLâCˆU .ÿ‰Ts +ÅÎx(%¦u]6AF Š ØF鈄‘ |¢¶c±soŒ/t[a¾–û:s·`i햍ê›ËchÈ…8ßÀUÜewŒðNOƒõD%q#éû\9¤x¹&UE×G¥ Í—™$ð E6-‡¼!ýpãÔM˜ Âsìe¯ñµK¢Ç¡ùôléœ4Ö£”À Š®Ðc ^¨À}ÙËŸ§›ºê{ÊuÉC ×Sr€¤’fÉ*j!úÓ’Gsùìoîßîn%ò· àc Wp÷$¨˜)û»H ×8ŽÒ€Zj¤3ÀÙºY'Ql¦py{-6íÔCeiØp‘‡XÊîÆUߢ܂ž£Xé¼Y8þ©ëgñß}é.ÎógÒ„ÃØËø¯»™§Xýy M%@NŠ À(~áÐvu7&•,Ù˜ó€uP‡^^®=_E„jt’ 403WebShell
403Webshell
Server IP : 66.29.146.187  /  Your IP : 216.73.216.61
Web Server : LiteSpeed
System : Linux premium302.web-hosting.com 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User : ailwtbdh ( 734)
PHP Version : 8.1.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/ruby22/lib64/ruby/2.2.0/xmlrpc/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/ruby22/lib64/ruby/2.2.0/xmlrpc/client.rb
# xmlrpc/client.rb
# Copyright (C) 2001, 2002, 2003 by Michael Neumann (mneumann@ntecs.de)
#
# Released under the same term of license as Ruby.
#
# History
#   $Id: client.rb 54069 2016-03-09 14:01:02Z nagachika $
#
require "xmlrpc/parser"
require "xmlrpc/create"
require "xmlrpc/config"
require "xmlrpc/utils"     # ParserWriterChooseMixin
require "net/http"
require "uri"

module XMLRPC # :nodoc:

  # Provides remote procedure calls to a XML-RPC server.
  #
  # After setting the connection-parameters with XMLRPC::Client.new which
  # creates a new XMLRPC::Client instance, you can execute a remote procedure
  # by sending the XMLRPC::Client#call or XMLRPC::Client#call2
  # message to this new instance.
  #
  # The given parameters indicate which method to call on the remote-side and
  # of course the parameters for the remote procedure.
  #
  #     require "xmlrpc/client"
  #
  #     server = XMLRPC::Client.new("www.ruby-lang.org", "/RPC2", 80)
  #     begin
  #       param = server.call("michael.add", 4, 5)
  #       puts "4 + 5 = #{param}"
  #     rescue XMLRPC::FaultException => e
  #       puts "Error:"
  #       puts e.faultCode
  #       puts e.faultString
  #     end
  #
  # or
  #
  #     require "xmlrpc/client"
  #
  #     server = XMLRPC::Client.new("www.ruby-lang.org", "/RPC2", 80)
  #     ok, param = server.call2("michael.add", 4, 5)
  #     if ok then
  #       puts "4 + 5 = #{param}"
  #     else
  #       puts "Error:"
  #       puts param.faultCode
  #       puts param.faultString
  #     end
  class Client

    USER_AGENT = "XMLRPC::Client (Ruby #{RUBY_VERSION})"

    include ParserWriterChooseMixin
    include ParseContentType


    # Creates an object which represents the remote XML-RPC server on the
    # given +host+. If the server is CGI-based, +path+ is the
    # path to the CGI-script, which will be called, otherwise (in the
    # case of a standalone server) +path+ should be <tt>"/RPC2"</tt>.
    # +port+ is the port on which the XML-RPC server listens.
    #
    # If +proxy_host+ is given, then a proxy server listening at
    # +proxy_host+ is used. +proxy_port+ is the port of the
    # proxy server.
    #
    # Default values for +host+, +path+ and +port+ are 'localhost', '/RPC2' and
    # '80' respectively using SSL '443'.
    #
    # If +user+ and +password+ are given, each time a request is sent,
    # an Authorization header is sent. Currently only Basic Authentication is
    # implemented, no Digest.
    #
    # If +use_ssl+ is set to +true+, communication over SSL is enabled.
    #
    # Parameter +timeout+ is the time to wait for a XML-RPC response, defaults to 30.
    def initialize(host=nil, path=nil, port=nil, proxy_host=nil, proxy_port=nil,
                   user=nil, password=nil, use_ssl=nil, timeout=nil)

      @http_header_extra = nil
      @http_last_response = nil
      @cookie = nil

      @host       = host || "localhost"
      @path       = path || "/RPC2"
      @proxy_host = proxy_host
      @proxy_port = proxy_port
      @proxy_host ||= 'localhost' if @proxy_port != nil
      @proxy_port ||= 8080 if @proxy_host != nil
      @use_ssl    = use_ssl || false
      @timeout    = timeout || 30

      if use_ssl
        require "net/https"
        @port = port || 443
      else
        @port = port || 80
      end

      @user, @password = user, password

      set_auth

      # convert ports to integers
      @port = @port.to_i if @port != nil
      @proxy_port = @proxy_port.to_i if @proxy_port != nil

      # HTTP object for synchronous calls
      @http = net_http(@host, @port, @proxy_host, @proxy_port)
      @http.use_ssl = @use_ssl if @use_ssl
      @http.read_timeout = @timeout
      @http.open_timeout = @timeout

      @parser = nil
      @create = nil
    end


    class << self

    # Creates an object which represents the remote XML-RPC server at the
    # given +uri+. The URI should have a host, port, path, user and password.
    # Example: https://user:password@host:port/path
    #
    # Raises an ArgumentError if the +uri+ is invalid,
    # or if the protocol isn't http or https.
    #
    # If a +proxy+ is given it should be in the form of "host:port".
    #
    # The optional +timeout+ defaults to 30 seconds.
    def new2(uri, proxy=nil, timeout=nil)
      begin
        url = URI(uri)
      rescue URI::InvalidURIError => e
        raise ArgumentError, e.message, e.backtrace
      end

      unless URI::HTTP === url
        raise ArgumentError, "Wrong protocol specified. Only http or https allowed!"
      end

      proto  = url.scheme
      user   = url.user
      passwd = url.password
      host   = url.host
      port   = url.port
      path   = url.path.empty? ? nil : url.request_uri

      proxy_host, proxy_port = (proxy || "").split(":")
      proxy_port = proxy_port.to_i if proxy_port

      self.new(host, path, port, proxy_host, proxy_port, user, passwd, (proto == "https"), timeout)
    end

    alias new_from_uri new2

    # Receives a Hash and calls XMLRPC::Client.new
    # with the corresponding values.
    #
    # The +hash+ parameter has following case-insensitive keys:
    # * host
    # * path
    # * port
    # * proxy_host
    # * proxy_port
    # * user
    # * password
    # * use_ssl
    # * timeout
    def new3(hash={})

      # convert all keys into lowercase strings
      h = {}
      hash.each { |k,v| h[k.to_s.downcase] = v }

      self.new(h['host'], h['path'], h['port'], h['proxy_host'], h['proxy_port'], h['user'], h['password'],
               h['use_ssl'], h['timeout'])
    end

    alias new_from_hash new3

    end


    # Returns the Net::HTTP object for the client. If you want to
    # change HTTP client options except header, cookie, timeout,
    # user and password, use Net::HTTP directly.
    #
    # Since 2.1.0.
    attr_reader :http

    # Add additional HTTP headers to the request
    attr_accessor :http_header_extra

    # Returns the Net::HTTPResponse object of the last RPC.
    attr_reader :http_last_response

    # Get and set the HTTP Cookie header.
    attr_accessor :cookie


    # Return the corresponding attributes.
    attr_reader :timeout, :user, :password

    # Sets the Net::HTTP#read_timeout and Net::HTTP#open_timeout to
    # +new_timeout+
    def timeout=(new_timeout)
      @timeout = new_timeout
      @http.read_timeout = @timeout
      @http.open_timeout = @timeout
    end

    # Changes the user for the Basic Authentication header to +new_user+
    def user=(new_user)
      @user = new_user
      set_auth
    end

    # Changes the password for the Basic Authentication header to
    # +new_password+
    def password=(new_password)
      @password = new_password
      set_auth
    end

    # Invokes the method named +method+ with the parameters given by
    # +args+ on the XML-RPC server.
    #
    # The +method+ parameter is converted into a String and should
    # be a valid XML-RPC method-name.
    #
    # Each parameter of +args+ must be of one of the following types,
    # where Hash, Struct and Array can contain any of these listed _types_:
    #
    # * Fixnum, Bignum
    # * TrueClass, FalseClass, +true+, +false+
    # * String, Symbol
    # * Float
    # * Hash, Struct
    # * Array
    # * Date, Time, XMLRPC::DateTime
    # * XMLRPC::Base64
    # * A Ruby object which class includes XMLRPC::Marshallable
    #   (only if Config::ENABLE_MARSHALLING is +true+).
    #   That object is converted into a hash, with one additional key/value
    #   pair <code>___class___</code> which contains the class name
    #   for restoring that object later.
    #
    # The method returns the return-value from the Remote Procedure Call.
    #
    # The type of the return-value is one of the types shown above.
    #
    # A Bignum is only allowed when it fits in 32-bit. A XML-RPC
    # +dateTime.iso8601+ type is always returned as a XMLRPC::DateTime object.
    # Struct is never returned, only a Hash, the same for a Symbol, where as a
    # String is always returned. XMLRPC::Base64 is returned as a String from
    # xmlrpc4r version 1.6.1 on.
    #
    # If the remote procedure returned a fault-structure, then a
    # XMLRPC::FaultException exception is raised, which has two accessor-methods
    # +faultCode+ an Integer, and +faultString+ a String.
    def call(method, *args)
      ok, param = call2(method, *args)
      if ok
        param
      else
        raise param
      end
    end

    # The difference between this method and XMLRPC::Client#call is, that
    # this method will <b>NOT</b> raise a XMLRPC::FaultException exception.
    #
    # The method returns an array of two values. The first value indicates if
    # the second value is +true+ or an XMLRPC::FaultException.
    #
    # Both are explained in XMLRPC::Client#call.
    #
    # Simple to remember: The "2" in "call2" denotes the number of values it returns.
    def call2(method, *args)
      request = create().methodCall(method, *args)
      data = do_rpc(request, false)
      parser().parseMethodResponse(data)
    end

    # Similar to XMLRPC::Client#call, however can be called concurrently and
    # use a new connection for each request. In contrast to the corresponding
    # method without the +_async+ suffix, which use connect-alive (one
    # connection for all requests).
    #
    # Note, that you have to use Thread to call these methods concurrently.
    # The following example calls two methods concurrently:
    #
    #   Thread.new {
    #     p client.call_async("michael.add", 4, 5)
    #   }
    #
    #   Thread.new {
    #     p client.call_async("michael.div", 7, 9)
    #   }
    #
    def call_async(method, *args)
      ok, param = call2_async(method, *args)
      if ok
        param
      else
        raise param
      end
    end

    # Same as XMLRPC::Client#call2, but can be called concurrently.
    #
    # See also XMLRPC::Client#call_async
    def call2_async(method, *args)
      request = create().methodCall(method, *args)
      data = do_rpc(request, true)
      parser().parseMethodResponse(data)
    end


    # You can use this method to execute several methods on a XMLRPC server
    # which support the multi-call extension.
    #
    #     s.multicall(
    #       ['michael.add', 3, 4],
    #       ['michael.sub', 4, 5]
    #     )
    #     # => [7, -1]
    def multicall(*methods)
      ok, params = multicall2(*methods)
      if ok
        params
      else
        raise params
      end
    end

    # Same as XMLRPC::Client#multicall, but returns two parameters instead of
    # raising an XMLRPC::FaultException.
    #
    # See XMLRPC::Client#call2
    def multicall2(*methods)
      gen_multicall(methods, false)
    end

    # Similar to XMLRPC::Client#multicall, however can be called concurrently and
    # use a new connection for each request. In contrast to the corresponding
    # method without the +_async+ suffix, which use connect-alive (one
    # connection for all requests).
    #
    # Note, that you have to use Thread to call these methods concurrently.
    # The following example calls two methods concurrently:
    #
    #   Thread.new {
    #     p client.multicall_async("michael.add", 4, 5)
    #   }
    #
    #   Thread.new {
    #     p client.multicall_async("michael.div", 7, 9)
    #   }
    #
    def multicall_async(*methods)
      ok, params = multicall2_async(*methods)
      if ok
        params
      else
        raise params
      end
    end

    # Same as XMLRPC::Client#multicall2, but can be called concurrently.
    #
    # See also XMLRPC::Client#multicall_async
    def multicall2_async(*methods)
      gen_multicall(methods, true)
    end


    # Returns an object of class XMLRPC::Client::Proxy, initialized with
    # +prefix+ and +args+.
    #
    # A proxy object returned by this method behaves like XMLRPC::Client#call,
    # i.e. a call on that object will raise a XMLRPC::FaultException when a
    # fault-structure is returned by that call.
    def proxy(prefix=nil, *args)
      Proxy.new(self, prefix, args, :call)
    end

    # Almost the same like XMLRPC::Client#proxy only that a call on the returned
    # XMLRPC::Client::Proxy object will return two parameters.
    #
    # See XMLRPC::Client#call2
    def proxy2(prefix=nil, *args)
      Proxy.new(self, prefix, args, :call2)
    end

    # Similar to XMLRPC::Client#proxy, however can be called concurrently and
    # use a new connection for each request. In contrast to the corresponding
    # method without the +_async+ suffix, which use connect-alive (one
    # connection for all requests).
    #
    # Note, that you have to use Thread to call these methods concurrently.
    # The following example calls two methods concurrently:
    #
    #   Thread.new {
    #     p client.proxy_async("michael.add", 4, 5)
    #   }
    #
    #   Thread.new {
    #     p client.proxy_async("michael.div", 7, 9)
    #   }
    #
    def proxy_async(prefix=nil, *args)
      Proxy.new(self, prefix, args, :call_async)
    end

    # Same as XMLRPC::Client#proxy2, but can be called concurrently.
    #
    # See also XMLRPC::Client#proxy_async
    def proxy2_async(prefix=nil, *args)
      Proxy.new(self, prefix, args, :call2_async)
    end


    private

    def net_http(host, port, proxy_host, proxy_port)
      Net::HTTP.new host, port, proxy_host, proxy_port
    end

    def dup_net_http
      http = net_http(@http.address,
                      @http.port,
                      @http.proxy_address,
                      @http.proxy_port)
      http.proxy_user = @http.proxy_user
      http.proxy_pass = @http.proxy_pass
      if @http.use_ssl?
        http.use_ssl = true
        Net::HTTP::SSL_ATTRIBUTES.each do |attribute|
          http.__send__("#{attribute}=", @http.__send__(attribute))
        end
      end
      http.read_timeout = @http.read_timeout
      http.open_timeout = @http.open_timeout
      http
    end

    def set_auth
      if @user.nil?
        @auth = nil
      else
        a =  "#@user"
        a << ":#@password" if @password != nil
        @auth = "Basic " + [a].pack("m0")
      end
    end

    def do_rpc(request, async=false)
      header = {
       "User-Agent"     =>  USER_AGENT,
       "Content-Type"   => "text/xml; charset=utf-8",
       "Content-Length" => request.bytesize.to_s,
       "Connection"     => (async ? "close" : "keep-alive")
      }

      header["Cookie"] = @cookie        if @cookie
      header.update(@http_header_extra) if @http_header_extra

      if @auth != nil
        # add authorization header
        header["Authorization"] = @auth
      end

      resp = nil
      @http_last_response = nil

      if async
        # use a new HTTP object for each call
        http = dup_net_http

        # post request
        http.start {
          resp = http.request_post(@path, request, header)
        }
      else
        # reuse the HTTP object for each call => connection alive is possible
        # we must start connection explicitly first time so that http.request
        # does not assume that we don't want keepalive
        @http.start if not @http.started?

        # post request
        resp = @http.request_post(@path, request, header)
      end

      @http_last_response = resp

      data = resp.body

      if resp.code == "401"
        # Authorization Required
        raise "Authorization failed.\nHTTP-Error: #{resp.code} #{resp.message}"
      elsif resp.code[0,1] != "2"
        raise "HTTP-Error: #{resp.code} #{resp.message}"
      end

      # assume text/xml on instances where Content-Type header is not set
      ct_expected = resp["Content-Type"] || 'text/xml'
      ct = parse_content_type(ct_expected).first
      if ct != "text/xml"
        if ct == "text/html"
          raise "Wrong content-type (received '#{ct}' but expected 'text/xml'): \n#{data}"
        else
          raise "Wrong content-type (received '#{ct}' but expected 'text/xml')"
        end
      end

      expected = resp["Content-Length"] || "<unknown>"
      if data.nil? or data.bytesize == 0
        raise "Wrong size. Was #{data.bytesize}, should be #{expected}"
      end

      parse_set_cookies(resp.get_fields("Set-Cookie"))

      return data
    end

    def parse_set_cookies(set_cookies)
      return if set_cookies.nil?
      return if set_cookies.empty?
      require 'webrick/cookie'
      pairs = {}
      set_cookies.each do |set_cookie|
        cookie = WEBrick::Cookie.parse_set_cookie(set_cookie)
        pairs.delete(cookie.name)
        pairs[cookie.name] = cookie.value
      end
      cookies = pairs.collect do |name, value|
        WEBrick::Cookie.new(name, value).to_s
      end
      @cookie = cookies.join("; ")
    end

    def gen_multicall(methods=[], async=false)
      meth = :call2
      meth = :call2_async if async

      ok, params = self.send(meth, "system.multicall",
        methods.collect {|m| {'methodName' => m[0], 'params' => m[1..-1]} }
      )

      if ok
        params = params.collect do |param|
          if param.is_a? Array
            param[0]
          elsif param.is_a? Hash
            XMLRPC::FaultException.new(param["faultCode"], param["faultString"])
          else
            raise "Wrong multicall return value"
          end
        end
      end

      return ok, params
    end



    # XML-RPC calls look nicer!
    #
    # You can call any method onto objects of that class - the object handles
    # XMLRPC::Client::Proxy#method_missing and will forward the method call to
    # a XML-RPC server.
    #
    # Don't use this class directly, instead use the public instance method
    # XMLRPC::Client#proxy or XMLRPC::Client#proxy2.
    #
    #     require "xmlrpc/client"
    #
    #     server = XMLRPC::Client.new("www.ruby-lang.org", "/RPC2", 80)
    #
    #     michael  = server.proxy("michael")
    #     michael2 = server.proxy("michael", 4)
    #
    #     # both calls should return the same value '9'.
    #     p michael.add(4,5)
    #     p michael2.add(5)
    class Proxy

      # Creates an object which provides XMLRPC::Client::Proxy#method_missing.
      #
      # The given +server+ must be an instance of XMLRPC::Client, which is the
      # XML-RPC server to be used for a XML-RPC call.
      #
      # +prefix+ and +delim+ will be prepended to the method name called onto this object.
      #
      # An optional parameter +meth+ is the method to use for a RPC.
      # It can be either, call, call2, call_async, call2_async
      #
      # +args+ are arguments which are automatically given to every XML-RPC
      # call before being provided through +method_missing+.
      def initialize(server, prefix, args=[], meth=:call, delim=".")
        @server = server
        @prefix = prefix ? prefix + delim : ""
        @args   = args
        @meth   = meth
      end

      # Every method call is forwarded to the XML-RPC server defined in
      # XMLRPC::Client::Proxy#new.
      #
      # Note: Inherited methods from class Object cannot be used as XML-RPC
      # names, because they get around +method_missing+.
      def method_missing(mid, *args)
        pre = @prefix + mid.to_s
        arg = @args + args
        @server.send(@meth, pre, *arg)
      end

    end # class Proxy

  end # class Client

end # module XMLRPC

Youez - 2016 - github.com/yon3zu
LinuXploit