Nektria_ReCS - Version 1.0.9

Version Notes

Bug fixes.

Download this release

Release Info

Developer Mikael Baron
Extension Nektria_ReCS
Version 1.0.9
Comparing to
See all releases


Code changes from version 1.0.8 to 1.0.9

Files changed (201) hide show
  1. app/code/community/Nektria/ReCS/etc/config.xml +1 -1
  2. app/code/community/Nektria/ReCS/lib/composer.lock +463 -0
  3. app/code/community/Nektria/ReCS/lib/vendor/autoload.php +7 -0
  4. app/code/community/Nektria/ReCS/lib/vendor/composer/ClassLoader.php +413 -0
  5. app/code/community/Nektria/ReCS/lib/vendor/composer/LICENSE +21 -0
  6. app/code/community/Nektria/ReCS/lib/vendor/composer/autoload_classmap.php +9 -0
  7. app/code/community/Nektria/ReCS/lib/vendor/composer/autoload_files.php +10 -0
  8. app/code/community/Nektria/ReCS/lib/vendor/composer/autoload_namespaces.php +10 -0
  9. app/code/community/Nektria/ReCS/lib/vendor/composer/autoload_psr4.php +17 -0
  10. app/code/community/Nektria/ReCS/lib/vendor/composer/autoload_real.php +70 -0
  11. app/code/community/Nektria/ReCS/lib/vendor/composer/autoload_static.php +87 -0
  12. app/code/community/Nektria/ReCS/lib/vendor/composer/installed.json +462 -0
  13. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/command/LICENSE +19 -0
  14. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/command/composer.json +29 -0
  15. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/command/src/AbstractClient.php +285 -0
  16. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/command/src/Command.php +74 -0
  17. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/command/src/CommandInterface.php +54 -0
  18. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/command/src/CommandToRequestIterator.php +148 -0
  19. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/command/src/CommandTransaction.php +100 -0
  20. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/command/src/CommandUtils.php +57 -0
  21. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/command/src/Event/CommandEvent.php +69 -0
  22. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/command/src/Event/InitEvent.php +9 -0
  23. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/command/src/Event/PreparedEvent.php +68 -0
  24. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/command/src/Event/ProcessEvent.php +74 -0
  25. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/command/src/Exception/CommandClientException.php +7 -0
  26. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/command/src/Exception/CommandException.php +84 -0
  27. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/command/src/Exception/CommandServerException.php +7 -0
  28. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/command/src/ServiceClientInterface.php +135 -0
  29. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/command/src/Subscriber/Debug.php +427 -0
  30. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/command/src/Subscriber/ResultMock.php +107 -0
  31. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/.gitignore +6 -0
  32. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/.travis.yml +13 -0
  33. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/LICENSE +19 -0
  34. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/Makefile +15 -0
  35. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/README.rst +63 -0
  36. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/composer.json +35 -0
  37. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/phpunit.xml.dist +14 -0
  38. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/Description.php +261 -0
  39. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/DescriptionInterface.php +107 -0
  40. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/GuzzleClient.php +176 -0
  41. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/Operation.php +299 -0
  42. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/Parameter.php +596 -0
  43. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/RequestLocation/AbstractLocation.php +87 -0
  44. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/RequestLocation/BodyLocation.php +23 -0
  45. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/RequestLocation/HeaderLocation.php +39 -0
  46. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/RequestLocation/JsonLocation.php +70 -0
  47. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/RequestLocation/PostFieldLocation.php +56 -0
  48. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/RequestLocation/PostFileLocation.php +34 -0
  49. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/RequestLocation/QueryLocation.php +44 -0
  50. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/RequestLocation/RequestLocationInterface.php +46 -0
  51. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/RequestLocation/XmlLocation.php +300 -0
  52. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/ResponseLocation/AbstractLocation.php +46 -0
  53. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/ResponseLocation/BodyLocation.php +22 -0
  54. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/ResponseLocation/HeaderLocation.php +26 -0
  55. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/ResponseLocation/JsonLocation.php +140 -0
  56. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/ResponseLocation/ReasonPhraseLocation.php +24 -0
  57. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/ResponseLocation/ResponseLocationInterface.php +70 -0
  58. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/ResponseLocation/StatusCodeLocation.php +22 -0
  59. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/ResponseLocation/XmlLocation.php +269 -0
  60. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/SchemaFormatter.php +141 -0
  61. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/SchemaValidator.php +296 -0
  62. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/Serializer.php +171 -0
  63. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/Subscriber/ProcessResponse.php +211 -0
  64. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/Subscriber/ValidateInput.php +76 -0
  65. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/DescriptionTest.php +175 -0
  66. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/GuzzleClientTest.php +149 -0
  67. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/OperationTest.php +224 -0
  68. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/ParameterTest.php +342 -0
  69. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/RequestLocation/BodyLocationTest.php +23 -0
  70. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/RequestLocation/HeaderLocationTest.php +41 -0
  71. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/RequestLocation/JsonLocationTest.php +83 -0
  72. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/RequestLocation/PostFieldLocationTest.php +70 -0
  73. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/RequestLocation/PostFileLocationTest.php +39 -0
  74. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/RequestLocation/QueryLocationTest.php +41 -0
  75. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/RequestLocation/XmlLocationTest.php +433 -0
  76. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/ResponseLocation/BodyLocationTest.php +29 -0
  77. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/ResponseLocation/HeaderLocationTest.php +29 -0
  78. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/ResponseLocation/JsonLocationTest.php +293 -0
  79. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/ResponseLocation/ReasonPhraseLocationTest.php +28 -0
  80. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/ResponseLocation/StatusCodeLocationTest.php +25 -0
  81. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/ResponseLocation/XmlLocationTest.php +764 -0
  82. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/SchemaFormatterTest.php +60 -0
  83. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/SchemaValidatorTest.php +313 -0
  84. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/SerializerTest.php +40 -0
  85. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/Subscriber/ProcessResponseTest.php +45 -0
  86. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/Subscriber/ValidateInputTest.php +102 -0
  87. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/.editorconfig +11 -0
  88. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/.gitignore +11 -0
  89. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/.travis.yml +41 -0
  90. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/CHANGELOG.md +1053 -0
  91. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/LICENSE +19 -0
  92. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/Makefile +50 -0
  93. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/README.md +70 -0
  94. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/UPGRADING.md +1050 -0
  95. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/build/packager.php +21 -0
  96. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/composer.json +39 -0
  97. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/docs/Makefile +153 -0
  98. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/docs/_static/guzzle-icon.png +0 -0
  99. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/docs/_static/logo.png +0 -0
  100. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/docs/_templates/nav_links.html +3 -0
  101. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/docs/clients.rst +1326 -0
  102. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/docs/conf.py +28 -0
  103. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/docs/events.rst +516 -0
  104. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/docs/faq.rst +199 -0
  105. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/docs/handlers.rst +43 -0
  106. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/docs/http-messages.rst +483 -0
  107. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/docs/index.rst +98 -0
  108. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/docs/overview.rst +150 -0
  109. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/docs/quickstart.rst +448 -0
  110. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/docs/requirements.txt +2 -0
  111. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/docs/streams.rst +213 -0
  112. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/docs/testing.rst +232 -0
  113. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/phpunit.xml.dist +17 -0
  114. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/BatchResults.php +148 -0
  115. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Client.php +352 -0
  116. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/ClientInterface.php +150 -0
  117. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Collection.php +236 -0
  118. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php +248 -0
  119. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php +75 -0
  120. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php +86 -0
  121. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php +66 -0
  122. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php +373 -0
  123. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Event/AbstractEvent.php +20 -0
  124. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Event/AbstractRequestEvent.php +61 -0
  125. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Event/AbstractRetryableEvent.php +40 -0
  126. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Event/AbstractTransferEvent.php +63 -0
  127. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Event/BeforeEvent.php +26 -0
  128. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Event/CompleteEvent.php +14 -0
  129. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Event/Emitter.php +146 -0
  130. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Event/EmitterInterface.php +96 -0
  131. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Event/EndEvent.php +28 -0
  132. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Event/ErrorEvent.php +27 -0
  133. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Event/EventInterface.php +23 -0
  134. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Event/HasEmitterInterface.php +15 -0
  135. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Event/HasEmitterTrait.php +20 -0
  136. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Event/ListenerAttacherTrait.php +88 -0
  137. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Event/ProgressEvent.php +51 -0
  138. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Event/RequestEvents.php +56 -0
  139. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Event/SubscriberInterface.php +34 -0
  140. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Exception/BadResponseException.php +7 -0
  141. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Exception/ClientException.php +7 -0
  142. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Exception/ConnectException.php +4 -0
  143. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Exception/CouldNotRewindStreamException.php +4 -0
  144. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Exception/ParseException.php +31 -0
  145. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php +121 -0
  146. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Exception/ServerException.php +7 -0
  147. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Exception/StateException.php +4 -0
  148. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Exception/TooManyRedirectsException.php +4 -0
  149. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Exception/TransferException.php +4 -0
  150. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Exception/XmlParseException.php +34 -0
  151. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/HasDataTrait.php +75 -0
  152. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Message/AbstractMessage.php +253 -0
  153. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Message/AppliesHeadersInterface.php +24 -0
  154. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Message/FutureResponse.php +158 -0
  155. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Message/MessageFactory.php +364 -0
  156. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Message/MessageFactoryInterface.php +71 -0
  157. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Message/MessageInterface.php +136 -0
  158. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Message/MessageParser.php +171 -0
  159. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Message/Request.php +195 -0
  160. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Message/RequestInterface.php +136 -0
  161. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Message/Response.php +208 -0
  162. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Message/ResponseInterface.php +111 -0
  163. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Mimetypes.php +963 -0
  164. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Pool.php +333 -0
  165. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Post/MultipartBody.php +109 -0
  166. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Post/PostBody.php +287 -0
  167. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Post/PostBodyInterface.php +109 -0
  168. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Post/PostFile.php +135 -0
  169. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Post/PostFileInterface.php +41 -0
  170. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Query.php +204 -0
  171. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/QueryParser.php +163 -0
  172. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/RequestFsm.php +153 -0
  173. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/RingBridge.php +165 -0
  174. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Subscriber/Cookie.php +58 -0
  175. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Subscriber/History.php +172 -0
  176. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Subscriber/HttpError.php +36 -0
  177. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Subscriber/Mock.php +147 -0
  178. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Subscriber/Prepare.php +130 -0
  179. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Subscriber/Redirect.php +176 -0
  180. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/ToArrayInterface.php +15 -0
  181. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Transaction.php +103 -0
  182. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/UriTemplate.php +241 -0
  183. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Url.php +595 -0
  184. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Utils.php +211 -0
  185. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/tests/BatchResultsTest.php +58 -0
  186. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/tests/ClientTest.php +647 -0
  187. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/tests/CollectionTest.php +416 -0
  188. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/tests/Cookie/CookieJarTest.php +339 -0
  189. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/tests/Cookie/FileCookieJarTest.php +71 -0
  190. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/tests/Cookie/SessionCookieJarTest.php +76 -0
  191. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/tests/Cookie/SetCookieTest.php +364 -0
  192. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/tests/Event/AbstractEventTest.php +14 -0
  193. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/tests/Event/AbstractRequestEventTest.php +33 -0
  194. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/tests/Event/AbstractRetryableEventTest.php +37 -0
  195. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/tests/Event/AbstractTransferEventTest.php +59 -0
  196. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/tests/Event/BeforeEventTest.php +26 -0
  197. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/tests/Event/EmitterTest.php +363 -0
  198. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/tests/Event/ErrorEventTest.php +23 -0
  199. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/tests/Event/HasEmitterTraitTest.php +27 -0
  200. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/tests/Event/ListenerAttacherTraitTest.php +92 -0
  201. app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/tests/Event/ProgressEventTest.php +16 -0
app/code/community/Nektria/ReCS/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Nektria_ReCS>
5
- <version>1.0.8</version>
6
  </Nektria_ReCS>
7
  </modules>
8
 
2
  <config>
3
  <modules>
4
  <Nektria_ReCS>
5
+ <version>1.0.9</version>
6
  </Nektria_ReCS>
7
  </modules>
8
 
app/code/community/Nektria/ReCS/lib/composer.lock ADDED
@@ -0,0 +1,463 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_readme": [
3
+ "This file locks the dependencies of your project to a known state",
4
+ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
5
+ "This file is @generated automatically"
6
+ ],
7
+ "hash": "f9db464d3e44e342662218817fcb0179",
8
+ "content-hash": "3baffd9be295ff81d937fc0b6963825a",
9
+ "packages": [
10
+ {
11
+ "name": "guzzlehttp/command",
12
+ "version": "0.7.1",
13
+ "source": {
14
+ "type": "git",
15
+ "url": "https://github.com/guzzle/command.git",
16
+ "reference": "2e8286ff81f75f97b00f7dcc2f51e2efafb373bd"
17
+ },
18
+ "dist": {
19
+ "type": "zip",
20
+ "url": "https://api.github.com/repos/guzzle/command/zipball/2e8286ff81f75f97b00f7dcc2f51e2efafb373bd",
21
+ "reference": "2e8286ff81f75f97b00f7dcc2f51e2efafb373bd",
22
+ "shasum": ""
23
+ },
24
+ "require": {
25
+ "guzzlehttp/guzzle": "~5.0",
26
+ "php": ">=5.4.0"
27
+ },
28
+ "require-dev": {
29
+ "phpunit/phpunit": "~4.0"
30
+ },
31
+ "type": "library",
32
+ "extra": {
33
+ "branch-alias": {
34
+ "dev-master": "0.7-dev"
35
+ }
36
+ },
37
+ "autoload": {
38
+ "psr-4": {
39
+ "GuzzleHttp\\Command\\": "src/"
40
+ }
41
+ },
42
+ "notification-url": "https://packagist.org/downloads/",
43
+ "license": [
44
+ "MIT"
45
+ ],
46
+ "authors": [
47
+ {
48
+ "name": "Michael Dowling",
49
+ "email": "mtdowling@gmail.com",
50
+ "homepage": "https://github.com/mtdowling"
51
+ }
52
+ ],
53
+ "description": "Provides the foundation for building command based web service clients",
54
+ "time": "2015-01-14 18:54:57"
55
+ },
56
+ {
57
+ "name": "guzzlehttp/guzzle",
58
+ "version": "5.3.0",
59
+ "source": {
60
+ "type": "git",
61
+ "url": "https://github.com/guzzle/guzzle.git",
62
+ "reference": "f3c8c22471cb55475105c14769644a49c3262b93"
63
+ },
64
+ "dist": {
65
+ "type": "zip",
66
+ "url": "https://api.github.com/repos/guzzle/guzzle/zipball/f3c8c22471cb55475105c14769644a49c3262b93",
67
+ "reference": "f3c8c22471cb55475105c14769644a49c3262b93",
68
+ "shasum": ""
69
+ },
70
+ "require": {
71
+ "guzzlehttp/ringphp": "^1.1",
72
+ "php": ">=5.4.0"
73
+ },
74
+ "require-dev": {
75
+ "ext-curl": "*",
76
+ "phpunit/phpunit": "^4.0",
77
+ "psr/log": "^1.0"
78
+ },
79
+ "type": "library",
80
+ "extra": {
81
+ "branch-alias": {
82
+ "dev-master": "5.0-dev"
83
+ }
84
+ },
85
+ "autoload": {
86
+ "psr-4": {
87
+ "GuzzleHttp\\": "src/"
88
+ }
89
+ },
90
+ "notification-url": "https://packagist.org/downloads/",
91
+ "license": [
92
+ "MIT"
93
+ ],
94
+ "authors": [
95
+ {
96
+ "name": "Michael Dowling",
97
+ "email": "mtdowling@gmail.com",
98
+ "homepage": "https://github.com/mtdowling"
99
+ }
100
+ ],
101
+ "description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients",
102
+ "homepage": "http://guzzlephp.org/",
103
+ "keywords": [
104
+ "client",
105
+ "curl",
106
+ "framework",
107
+ "http",
108
+ "http client",
109
+ "rest",
110
+ "web service"
111
+ ],
112
+ "time": "2015-05-20 03:47:55"
113
+ },
114
+ {
115
+ "name": "guzzlehttp/guzzle-services",
116
+ "version": "0.5.0",
117
+ "source": {
118
+ "type": "git",
119
+ "url": "https://github.com/guzzle/guzzle-services.git",
120
+ "reference": "5402867628d266748db88f05c90ede54fd1d884c"
121
+ },
122
+ "dist": {
123
+ "type": "zip",
124
+ "url": "https://api.github.com/repos/guzzle/guzzle-services/zipball/5402867628d266748db88f05c90ede54fd1d884c",
125
+ "reference": "5402867628d266748db88f05c90ede54fd1d884c",
126
+ "shasum": ""
127
+ },
128
+ "require": {
129
+ "guzzlehttp/command": "0.7.*",
130
+ "php": ">=5.4.0"
131
+ },
132
+ "require-dev": {
133
+ "phpunit/phpunit": "~4.0"
134
+ },
135
+ "type": "library",
136
+ "extra": {
137
+ "branch-alias": {
138
+ "dev-master": "0.4-dev"
139
+ }
140
+ },
141
+ "autoload": {
142
+ "psr-4": {
143
+ "GuzzleHttp\\Command\\Guzzle\\": "src/"
144
+ }
145
+ },
146
+ "notification-url": "https://packagist.org/downloads/",
147
+ "license": [
148
+ "MIT"
149
+ ],
150
+ "authors": [
151
+ {
152
+ "name": "Michael Dowling",
153
+ "email": "mtdowling@gmail.com",
154
+ "homepage": "https://github.com/mtdowling"
155
+ }
156
+ ],
157
+ "description": "Provides an implementation of the Guzzle Command library that uses Guzzle service descriptions to describe web services, serialize requests, and parse responses into easy to use model structures.",
158
+ "time": "2014-12-23 19:13:18"
159
+ },
160
+ {
161
+ "name": "guzzlehttp/log-subscriber",
162
+ "version": "1.0.1",
163
+ "source": {
164
+ "type": "git",
165
+ "url": "https://github.com/guzzle/log-subscriber.git",
166
+ "reference": "99c3c0004165db721d8ef7bbef60c996210e538a"
167
+ },
168
+ "dist": {
169
+ "type": "zip",
170
+ "url": "https://api.github.com/repos/guzzle/log-subscriber/zipball/99c3c0004165db721d8ef7bbef60c996210e538a",
171
+ "reference": "99c3c0004165db721d8ef7bbef60c996210e538a",
172
+ "shasum": ""
173
+ },
174
+ "require": {
175
+ "guzzlehttp/guzzle": "~4.0 | ~5.0",
176
+ "php": ">=5.4.0",
177
+ "psr/log": "~1.0"
178
+ },
179
+ "require-dev": {
180
+ "phpunit/phpunit": "~4.0"
181
+ },
182
+ "type": "library",
183
+ "extra": {
184
+ "branch-alias": {
185
+ "dev-master": "1.0-dev"
186
+ }
187
+ },
188
+ "autoload": {
189
+ "psr-4": {
190
+ "GuzzleHttp\\Subscriber\\Log\\": "src/"
191
+ }
192
+ },
193
+ "notification-url": "https://packagist.org/downloads/",
194
+ "license": [
195
+ "MIT"
196
+ ],
197
+ "authors": [
198
+ {
199
+ "name": "Michael Dowling",
200
+ "email": "mtdowling@gmail.com",
201
+ "homepage": "https://github.com/mtdowling"
202
+ }
203
+ ],
204
+ "description": "Logs HTTP requests and responses as they are sent over the wire (Guzzle 4+)",
205
+ "homepage": "http://guzzlephp.org/",
206
+ "keywords": [
207
+ "Guzzle",
208
+ "log",
209
+ "plugin"
210
+ ],
211
+ "time": "2014-10-13 03:31:43"
212
+ },
213
+ {
214
+ "name": "guzzlehttp/ringphp",
215
+ "version": "1.1.0",
216
+ "source": {
217
+ "type": "git",
218
+ "url": "https://github.com/guzzle/RingPHP.git",
219
+ "reference": "dbbb91d7f6c191e5e405e900e3102ac7f261bc0b"
220
+ },
221
+ "dist": {
222
+ "type": "zip",
223
+ "url": "https://api.github.com/repos/guzzle/RingPHP/zipball/dbbb91d7f6c191e5e405e900e3102ac7f261bc0b",
224
+ "reference": "dbbb91d7f6c191e5e405e900e3102ac7f261bc0b",
225
+ "shasum": ""
226
+ },
227
+ "require": {
228
+ "guzzlehttp/streams": "~3.0",
229
+ "php": ">=5.4.0",
230
+ "react/promise": "~2.0"
231
+ },
232
+ "require-dev": {
233
+ "ext-curl": "*",
234
+ "phpunit/phpunit": "~4.0"
235
+ },
236
+ "suggest": {
237
+ "ext-curl": "Guzzle will use specific adapters if cURL is present"
238
+ },
239
+ "type": "library",
240
+ "extra": {
241
+ "branch-alias": {
242
+ "dev-master": "1.1-dev"
243
+ }
244
+ },
245
+ "autoload": {
246
+ "psr-4": {
247
+ "GuzzleHttp\\Ring\\": "src/"
248
+ }
249
+ },
250
+ "notification-url": "https://packagist.org/downloads/",
251
+ "license": [
252
+ "MIT"
253
+ ],
254
+ "authors": [
255
+ {
256
+ "name": "Michael Dowling",
257
+ "email": "mtdowling@gmail.com",
258
+ "homepage": "https://github.com/mtdowling"
259
+ }
260
+ ],
261
+ "description": "Provides a simple API and specification that abstracts away the details of HTTP into a single PHP function.",
262
+ "time": "2015-05-20 03:37:09"
263
+ },
264
+ {
265
+ "name": "guzzlehttp/streams",
266
+ "version": "3.0.0",
267
+ "source": {
268
+ "type": "git",
269
+ "url": "https://github.com/guzzle/streams.git",
270
+ "reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5"
271
+ },
272
+ "dist": {
273
+ "type": "zip",
274
+ "url": "https://api.github.com/repos/guzzle/streams/zipball/47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5",
275
+ "reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5",
276
+ "shasum": ""
277
+ },
278
+ "require": {
279
+ "php": ">=5.4.0"
280
+ },
281
+ "require-dev": {
282
+ "phpunit/phpunit": "~4.0"
283
+ },
284
+ "type": "library",
285
+ "extra": {
286
+ "branch-alias": {
287
+ "dev-master": "3.0-dev"
288
+ }
289
+ },
290
+ "autoload": {
291
+ "psr-4": {
292
+ "GuzzleHttp\\Stream\\": "src/"
293
+ }
294
+ },
295
+ "notification-url": "https://packagist.org/downloads/",
296
+ "license": [
297
+ "MIT"
298
+ ],
299
+ "authors": [
300
+ {
301
+ "name": "Michael Dowling",
302
+ "email": "mtdowling@gmail.com",
303
+ "homepage": "https://github.com/mtdowling"
304
+ }
305
+ ],
306
+ "description": "Provides a simple abstraction over streams of data",
307
+ "homepage": "http://guzzlephp.org/",
308
+ "keywords": [
309
+ "Guzzle",
310
+ "stream"
311
+ ],
312
+ "time": "2014-10-12 19:18:40"
313
+ },
314
+ {
315
+ "name": "nektria/recs-sdk-php",
316
+ "version": "v1.2.4",
317
+ "source": {
318
+ "type": "git",
319
+ "url": "https://bitbucket.org/nektria/merchant-api-client.git",
320
+ "reference": "e0998f03bf347b40c70ba28aaa4a1708c8b50777"
321
+ },
322
+ "dist": {
323
+ "type": "zip",
324
+ "url": "https://bitbucket.org/nektria/merchant-api-client/get/e0998f03bf347b40c70ba28aaa4a1708c8b50777.zip",
325
+ "reference": "e0998f03bf347b40c70ba28aaa4a1708c8b50777",
326
+ "shasum": ""
327
+ },
328
+ "require": {
329
+ "guzzlehttp/guzzle": "5.3",
330
+ "guzzlehttp/guzzle-services": "0.5.*",
331
+ "guzzlehttp/log-subscriber": "~1.0",
332
+ "php": ">=5.4"
333
+ },
334
+ "require-dev": {
335
+ "phpunit/phpunit": "4.*"
336
+ },
337
+ "suggest": {
338
+ "ext-curl": "To send requests using cURL"
339
+ },
340
+ "type": "library",
341
+ "autoload": {
342
+ "psr-4": {
343
+ "Nektria\\Recs\\MerchantApi\\": "src/"
344
+ }
345
+ },
346
+ "notification-url": "https://packagist.org/downloads/",
347
+ "license": [
348
+ "Apache-2.0"
349
+ ],
350
+ "authors": [
351
+ {
352
+ "name": "Nektria",
353
+ "homepage": "http://www.nektria.com/"
354
+ }
355
+ ],
356
+ "description": "Nektria Responsive eCommerce Shipping (ReCS) SDK for PHP",
357
+ "homepage": "http://www.recshipping.com",
358
+ "keywords": [
359
+ "carrier",
360
+ "ecommerce",
361
+ "lastmile",
362
+ "magento",
363
+ "nektria",
364
+ "recs",
365
+ "sdk",
366
+ "shipping"
367
+ ],
368
+ "time": "2016-05-06 18:05:42"
369
+ },
370
+ {
371
+ "name": "psr/log",
372
+ "version": "1.0.0",
373
+ "source": {
374
+ "type": "git",
375
+ "url": "https://github.com/php-fig/log.git",
376
+ "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b"
377
+ },
378
+ "dist": {
379
+ "type": "zip",
380
+ "url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b",
381
+ "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b",
382
+ "shasum": ""
383
+ },
384
+ "type": "library",
385
+ "autoload": {
386
+ "psr-0": {
387
+ "Psr\\Log\\": ""
388
+ }
389
+ },
390
+ "notification-url": "https://packagist.org/downloads/",
391
+ "license": [
392
+ "MIT"
393
+ ],
394
+ "authors": [
395
+ {
396
+ "name": "PHP-FIG",
397
+ "homepage": "http://www.php-fig.org/"
398
+ }
399
+ ],
400
+ "description": "Common interface for logging libraries",
401
+ "keywords": [
402
+ "log",
403
+ "psr",
404
+ "psr-3"
405
+ ],
406
+ "time": "2012-12-21 11:40:51"
407
+ },
408
+ {
409
+ "name": "react/promise",
410
+ "version": "v2.4.1",
411
+ "source": {
412
+ "type": "git",
413
+ "url": "https://github.com/reactphp/promise.git",
414
+ "reference": "8025426794f1944de806618671d4fa476dc7626f"
415
+ },
416
+ "dist": {
417
+ "type": "zip",
418
+ "url": "https://api.github.com/repos/reactphp/promise/zipball/8025426794f1944de806618671d4fa476dc7626f",
419
+ "reference": "8025426794f1944de806618671d4fa476dc7626f",
420
+ "shasum": ""
421
+ },
422
+ "require": {
423
+ "php": ">=5.4.0"
424
+ },
425
+ "type": "library",
426
+ "extra": {
427
+ "branch-alias": {
428
+ "dev-master": "2.0-dev"
429
+ }
430
+ },
431
+ "autoload": {
432
+ "psr-4": {
433
+ "React\\Promise\\": "src/"
434
+ },
435
+ "files": [
436
+ "src/functions_include.php"
437
+ ]
438
+ },
439
+ "notification-url": "https://packagist.org/downloads/",
440
+ "license": [
441
+ "MIT"
442
+ ],
443
+ "authors": [
444
+ {
445
+ "name": "Jan Sorgalla",
446
+ "email": "jsorgalla@gmail.com"
447
+ }
448
+ ],
449
+ "description": "A lightweight implementation of CommonJS Promises/A for PHP",
450
+ "time": "2016-05-03 17:50:52"
451
+ }
452
+ ],
453
+ "packages-dev": [],
454
+ "aliases": [],
455
+ "minimum-stability": "stable",
456
+ "stability-flags": [],
457
+ "prefer-stable": false,
458
+ "prefer-lowest": false,
459
+ "platform": {
460
+ "php": ">=5.4"
461
+ },
462
+ "platform-dev": []
463
+ }
app/code/community/Nektria/ReCS/lib/vendor/autoload.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload.php @generated by Composer
4
+
5
+ require_once __DIR__ . '/composer' . '/autoload_real.php';
6
+
7
+ return ComposerAutoloaderInit77dbd97a77d94a0f0aa3f5bd04cec806::getLoader();
app/code/community/Nektria/ReCS/lib/vendor/composer/ClassLoader.php ADDED
@@ -0,0 +1,413 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Composer.
5
+ *
6
+ * (c) Nils Adermann <naderman@naderman.de>
7
+ * Jordi Boggiano <j.boggiano@seld.be>
8
+ *
9
+ * For the full copyright and license information, please view the LICENSE
10
+ * file that was distributed with this source code.
11
+ */
12
+
13
+ namespace Composer\Autoload;
14
+
15
+ /**
16
+ * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
17
+ *
18
+ * $loader = new \Composer\Autoload\ClassLoader();
19
+ *
20
+ * // register classes with namespaces
21
+ * $loader->add('Symfony\Component', __DIR__.'/component');
22
+ * $loader->add('Symfony', __DIR__.'/framework');
23
+ *
24
+ * // activate the autoloader
25
+ * $loader->register();
26
+ *
27
+ * // to enable searching the include path (eg. for PEAR packages)
28
+ * $loader->setUseIncludePath(true);
29
+ *
30
+ * In this example, if you try to use a class in the Symfony\Component
31
+ * namespace or one of its children (Symfony\Component\Console for instance),
32
+ * the autoloader will first look for the class under the component/
33
+ * directory, and it will then fallback to the framework/ directory if not
34
+ * found before giving up.
35
+ *
36
+ * This class is loosely based on the Symfony UniversalClassLoader.
37
+ *
38
+ * @author Fabien Potencier <fabien@symfony.com>
39
+ * @author Jordi Boggiano <j.boggiano@seld.be>
40
+ * @see http://www.php-fig.org/psr/psr-0/
41
+ * @see http://www.php-fig.org/psr/psr-4/
42
+ */
43
+ class ClassLoader
44
+ {
45
+ // PSR-4
46
+ private $prefixLengthsPsr4 = array();
47
+ private $prefixDirsPsr4 = array();
48
+ private $fallbackDirsPsr4 = array();
49
+
50
+ // PSR-0
51
+ private $prefixesPsr0 = array();
52
+ private $fallbackDirsPsr0 = array();
53
+
54
+ private $useIncludePath = false;
55
+ private $classMap = array();
56
+
57
+ private $classMapAuthoritative = false;
58
+
59
+ public function getPrefixes()
60
+ {
61
+ if (!empty($this->prefixesPsr0)) {
62
+ return call_user_func_array('array_merge', $this->prefixesPsr0);
63
+ }
64
+
65
+ return array();
66
+ }
67
+
68
+ public function getPrefixesPsr4()
69
+ {
70
+ return $this->prefixDirsPsr4;
71
+ }
72
+
73
+ public function getFallbackDirs()
74
+ {
75
+ return $this->fallbackDirsPsr0;
76
+ }
77
+
78
+ public function getFallbackDirsPsr4()
79
+ {
80
+ return $this->fallbackDirsPsr4;
81
+ }
82
+
83
+ public function getClassMap()
84
+ {
85
+ return $this->classMap;
86
+ }
87
+
88
+ /**
89
+ * @param array $classMap Class to filename map
90
+ */
91
+ public function addClassMap(array $classMap)
92
+ {
93
+ if ($this->classMap) {
94
+ $this->classMap = array_merge($this->classMap, $classMap);
95
+ } else {
96
+ $this->classMap = $classMap;
97
+ }
98
+ }
99
+
100
+ /**
101
+ * Registers a set of PSR-0 directories for a given prefix, either
102
+ * appending or prepending to the ones previously set for this prefix.
103
+ *
104
+ * @param string $prefix The prefix
105
+ * @param array|string $paths The PSR-0 root directories
106
+ * @param bool $prepend Whether to prepend the directories
107
+ */
108
+ public function add($prefix, $paths, $prepend = false)
109
+ {
110
+ if (!$prefix) {
111
+ if ($prepend) {
112
+ $this->fallbackDirsPsr0 = array_merge(
113
+ (array) $paths,
114
+ $this->fallbackDirsPsr0
115
+ );
116
+ } else {
117
+ $this->fallbackDirsPsr0 = array_merge(
118
+ $this->fallbackDirsPsr0,
119
+ (array) $paths
120
+ );
121
+ }
122
+
123
+ return;
124
+ }
125
+
126
+ $first = $prefix[0];
127
+ if (!isset($this->prefixesPsr0[$first][$prefix])) {
128
+ $this->prefixesPsr0[$first][$prefix] = (array) $paths;
129
+
130
+ return;
131
+ }
132
+ if ($prepend) {
133
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
134
+ (array) $paths,
135
+ $this->prefixesPsr0[$first][$prefix]
136
+ );
137
+ } else {
138
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
139
+ $this->prefixesPsr0[$first][$prefix],
140
+ (array) $paths
141
+ );
142
+ }
143
+ }
144
+
145
+ /**
146
+ * Registers a set of PSR-4 directories for a given namespace, either
147
+ * appending or prepending to the ones previously set for this namespace.
148
+ *
149
+ * @param string $prefix The prefix/namespace, with trailing '\\'
150
+ * @param array|string $paths The PSR-4 base directories
151
+ * @param bool $prepend Whether to prepend the directories
152
+ *
153
+ * @throws \InvalidArgumentException
154
+ */
155
+ public function addPsr4($prefix, $paths, $prepend = false)
156
+ {
157
+ if (!$prefix) {
158
+ // Register directories for the root namespace.
159
+ if ($prepend) {
160
+ $this->fallbackDirsPsr4 = array_merge(
161
+ (array) $paths,
162
+ $this->fallbackDirsPsr4
163
+ );
164
+ } else {
165
+ $this->fallbackDirsPsr4 = array_merge(
166
+ $this->fallbackDirsPsr4,
167
+ (array) $paths
168
+ );
169
+ }
170
+ } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
171
+ // Register directories for a new namespace.
172
+ $length = strlen($prefix);
173
+ if ('\\' !== $prefix[$length - 1]) {
174
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
175
+ }
176
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
177
+ $this->prefixDirsPsr4[$prefix] = (array) $paths;
178
+ } elseif ($prepend) {
179
+ // Prepend directories for an already registered namespace.
180
+ $this->prefixDirsPsr4[$prefix] = array_merge(
181
+ (array) $paths,
182
+ $this->prefixDirsPsr4[$prefix]
183
+ );
184
+ } else {
185
+ // Append directories for an already registered namespace.
186
+ $this->prefixDirsPsr4[$prefix] = array_merge(
187
+ $this->prefixDirsPsr4[$prefix],
188
+ (array) $paths
189
+ );
190
+ }
191
+ }
192
+
193
+ /**
194
+ * Registers a set of PSR-0 directories for a given prefix,
195
+ * replacing any others previously set for this prefix.
196
+ *
197
+ * @param string $prefix The prefix
198
+ * @param array|string $paths The PSR-0 base directories
199
+ */
200
+ public function set($prefix, $paths)
201
+ {
202
+ if (!$prefix) {
203
+ $this->fallbackDirsPsr0 = (array) $paths;
204
+ } else {
205
+ $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
206
+ }
207
+ }
208
+
209
+ /**
210
+ * Registers a set of PSR-4 directories for a given namespace,
211
+ * replacing any others previously set for this namespace.
212
+ *
213
+ * @param string $prefix The prefix/namespace, with trailing '\\'
214
+ * @param array|string $paths The PSR-4 base directories
215
+ *
216
+ * @throws \InvalidArgumentException
217
+ */
218
+ public function setPsr4($prefix, $paths)
219
+ {
220
+ if (!$prefix) {
221
+ $this->fallbackDirsPsr4 = (array) $paths;
222
+ } else {
223
+ $length = strlen($prefix);
224
+ if ('\\' !== $prefix[$length - 1]) {
225
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
226
+ }
227
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
228
+ $this->prefixDirsPsr4[$prefix] = (array) $paths;
229
+ }
230
+ }
231
+
232
+ /**
233
+ * Turns on searching the include path for class files.
234
+ *
235
+ * @param bool $useIncludePath
236
+ */
237
+ public function setUseIncludePath($useIncludePath)
238
+ {
239
+ $this->useIncludePath = $useIncludePath;
240
+ }
241
+
242
+ /**
243
+ * Can be used to check if the autoloader uses the include path to check
244
+ * for classes.
245
+ *
246
+ * @return bool
247
+ */
248
+ public function getUseIncludePath()
249
+ {
250
+ return $this->useIncludePath;
251
+ }
252
+
253
+ /**
254
+ * Turns off searching the prefix and fallback directories for classes
255
+ * that have not been registered with the class map.
256
+ *
257
+ * @param bool $classMapAuthoritative
258
+ */
259
+ public function setClassMapAuthoritative($classMapAuthoritative)
260
+ {
261
+ $this->classMapAuthoritative = $classMapAuthoritative;
262
+ }
263
+
264
+ /**
265
+ * Should class lookup fail if not found in the current class map?
266
+ *
267
+ * @return bool
268
+ */
269
+ public function isClassMapAuthoritative()
270
+ {
271
+ return $this->classMapAuthoritative;
272
+ }
273
+
274
+ /**
275
+ * Registers this instance as an autoloader.
276
+ *
277
+ * @param bool $prepend Whether to prepend the autoloader or not
278
+ */
279
+ public function register($prepend = false)
280
+ {
281
+ spl_autoload_register(array($this, 'loadClass'), true, $prepend);
282
+ }
283
+
284
+ /**
285
+ * Unregisters this instance as an autoloader.
286
+ */
287
+ public function unregister()
288
+ {
289
+ spl_autoload_unregister(array($this, 'loadClass'));
290
+ }
291
+
292
+ /**
293
+ * Loads the given class or interface.
294
+ *
295
+ * @param string $class The name of the class
296
+ * @return bool|null True if loaded, null otherwise
297
+ */
298
+ public function loadClass($class)
299
+ {
300
+ if ($file = $this->findFile($class)) {
301
+ includeFile($file);
302
+
303
+ return true;
304
+ }
305
+ }
306
+
307
+ /**
308
+ * Finds the path to the file where the class is defined.
309
+ *
310
+ * @param string $class The name of the class
311
+ *
312
+ * @return string|false The path if found, false otherwise
313
+ */
314
+ public function findFile($class)
315
+ {
316
+ // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731
317
+ if ('\\' == $class[0]) {
318
+ $class = substr($class, 1);
319
+ }
320
+
321
+ // class map lookup
322
+ if (isset($this->classMap[$class])) {
323
+ return $this->classMap[$class];
324
+ }
325
+ if ($this->classMapAuthoritative) {
326
+ return false;
327
+ }
328
+
329
+ $file = $this->findFileWithExtension($class, '.php');
330
+
331
+ // Search for Hack files if we are running on HHVM
332
+ if ($file === null && defined('HHVM_VERSION')) {
333
+ $file = $this->findFileWithExtension($class, '.hh');
334
+ }
335
+
336
+ if ($file === null) {
337
+ // Remember that this class does not exist.
338
+ return $this->classMap[$class] = false;
339
+ }
340
+
341
+ return $file;
342
+ }
343
+
344
+ private function findFileWithExtension($class, $ext)
345
+ {
346
+ // PSR-4 lookup
347
+ $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
348
+
349
+ $first = $class[0];
350
+ if (isset($this->prefixLengthsPsr4[$first])) {
351
+ foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) {
352
+ if (0 === strpos($class, $prefix)) {
353
+ foreach ($this->prefixDirsPsr4[$prefix] as $dir) {
354
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
355
+ return $file;
356
+ }
357
+ }
358
+ }
359
+ }
360
+ }
361
+
362
+ // PSR-4 fallback dirs
363
+ foreach ($this->fallbackDirsPsr4 as $dir) {
364
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
365
+ return $file;
366
+ }
367
+ }
368
+
369
+ // PSR-0 lookup
370
+ if (false !== $pos = strrpos($class, '\\')) {
371
+ // namespaced class name
372
+ $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
373
+ . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
374
+ } else {
375
+ // PEAR-like class name
376
+ $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
377
+ }
378
+
379
+ if (isset($this->prefixesPsr0[$first])) {
380
+ foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
381
+ if (0 === strpos($class, $prefix)) {
382
+ foreach ($dirs as $dir) {
383
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
384
+ return $file;
385
+ }
386
+ }
387
+ }
388
+ }
389
+ }
390
+
391
+ // PSR-0 fallback dirs
392
+ foreach ($this->fallbackDirsPsr0 as $dir) {
393
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
394
+ return $file;
395
+ }
396
+ }
397
+
398
+ // PSR-0 include paths.
399
+ if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
400
+ return $file;
401
+ }
402
+ }
403
+ }
404
+
405
+ /**
406
+ * Scope isolated include.
407
+ *
408
+ * Prevents access to $this/self from included files.
409
+ */
410
+ function includeFile($file)
411
+ {
412
+ include $file;
413
+ }
app/code/community/Nektria/ReCS/lib/vendor/composer/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Copyright (c) 2016 Nils Adermann, Jordi Boggiano
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is furnished
9
+ to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ THE SOFTWARE.
21
+
app/code/community/Nektria/ReCS/lib/vendor/composer/autoload_classmap.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_classmap.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ );
app/code/community/Nektria/ReCS/lib/vendor/composer/autoload_files.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_files.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ 'ad155f8f1cf0d418fe49e248db8c661b' => $vendorDir . '/react/promise/src/functions_include.php',
10
+ );
app/code/community/Nektria/ReCS/lib/vendor/composer/autoload_namespaces.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_namespaces.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ 'Psr\\Log\\' => array($vendorDir . '/psr/log'),
10
+ );
app/code/community/Nektria/ReCS/lib/vendor/composer/autoload_psr4.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_psr4.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ 'React\\Promise\\' => array($vendorDir . '/react/promise/src'),
10
+ 'Nektria\\Recs\\MerchantApi\\' => array($vendorDir . '/nektria/recs-sdk-php/src'),
11
+ 'GuzzleHttp\\Subscriber\\Log\\' => array($vendorDir . '/guzzlehttp/log-subscriber/src'),
12
+ 'GuzzleHttp\\Stream\\' => array($vendorDir . '/guzzlehttp/streams/src'),
13
+ 'GuzzleHttp\\Ring\\' => array($vendorDir . '/guzzlehttp/ringphp/src'),
14
+ 'GuzzleHttp\\Command\\Guzzle\\' => array($vendorDir . '/guzzlehttp/guzzle-services/src'),
15
+ 'GuzzleHttp\\Command\\' => array($vendorDir . '/guzzlehttp/command/src'),
16
+ 'GuzzleHttp\\' => array($vendorDir . '/guzzlehttp/guzzle/src'),
17
+ );
app/code/community/Nektria/ReCS/lib/vendor/composer/autoload_real.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_real.php @generated by Composer
4
+
5
+ class ComposerAutoloaderInit77dbd97a77d94a0f0aa3f5bd04cec806
6
+ {
7
+ private static $loader;
8
+
9
+ public static function loadClassLoader($class)
10
+ {
11
+ if ('Composer\Autoload\ClassLoader' === $class) {
12
+ require __DIR__ . '/ClassLoader.php';
13
+ }
14
+ }
15
+
16
+ public static function getLoader()
17
+ {
18
+ if (null !== self::$loader) {
19
+ return self::$loader;
20
+ }
21
+
22
+ spl_autoload_register(array('ComposerAutoloaderInit77dbd97a77d94a0f0aa3f5bd04cec806', 'loadClassLoader'), true, true);
23
+ self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit77dbd97a77d94a0f0aa3f5bd04cec806', 'loadClassLoader'));
25
+
26
+ $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION');
27
+ if ($useStaticLoader) {
28
+ require_once __DIR__ . '/autoload_static.php';
29
+
30
+ call_user_func(\Composer\Autoload\ComposerStaticInit77dbd97a77d94a0f0aa3f5bd04cec806::getInitializer($loader));
31
+ } else {
32
+ $map = require __DIR__ . '/autoload_namespaces.php';
33
+ foreach ($map as $namespace => $path) {
34
+ $loader->set($namespace, $path);
35
+ }
36
+
37
+ $map = require __DIR__ . '/autoload_psr4.php';
38
+ foreach ($map as $namespace => $path) {
39
+ $loader->setPsr4($namespace, $path);
40
+ }
41
+
42
+ $classMap = require __DIR__ . '/autoload_classmap.php';
43
+ if ($classMap) {
44
+ $loader->addClassMap($classMap);
45
+ }
46
+ }
47
+
48
+ $loader->register(true);
49
+
50
+ if ($useStaticLoader) {
51
+ $includeFiles = Composer\Autoload\ComposerStaticInit77dbd97a77d94a0f0aa3f5bd04cec806::$files;
52
+ } else {
53
+ $includeFiles = require __DIR__ . '/autoload_files.php';
54
+ }
55
+ foreach ($includeFiles as $fileIdentifier => $file) {
56
+ composerRequire77dbd97a77d94a0f0aa3f5bd04cec806($fileIdentifier, $file);
57
+ }
58
+
59
+ return $loader;
60
+ }
61
+ }
62
+
63
+ function composerRequire77dbd97a77d94a0f0aa3f5bd04cec806($fileIdentifier, $file)
64
+ {
65
+ if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
66
+ require $file;
67
+
68
+ $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
69
+ }
70
+ }
app/code/community/Nektria/ReCS/lib/vendor/composer/autoload_static.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_static.php @generated by Composer
4
+
5
+ namespace Composer\Autoload;
6
+
7
+ class ComposerStaticInit77dbd97a77d94a0f0aa3f5bd04cec806
8
+ {
9
+ public static $files = array (
10
+ 'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
11
+ );
12
+
13
+ public static $prefixLengthsPsr4 = array (
14
+ 'R' =>
15
+ array (
16
+ 'React\\Promise\\' => 14,
17
+ ),
18
+ 'N' =>
19
+ array (
20
+ 'Nektria\\Recs\\MerchantApi\\' => 25,
21
+ ),
22
+ 'G' =>
23
+ array (
24
+ 'GuzzleHttp\\Subscriber\\Log\\' => 26,
25
+ 'GuzzleHttp\\Stream\\' => 18,
26
+ 'GuzzleHttp\\Ring\\' => 16,
27
+ 'GuzzleHttp\\Command\\Guzzle\\' => 26,
28
+ 'GuzzleHttp\\Command\\' => 19,
29
+ 'GuzzleHttp\\' => 11,
30
+ ),
31
+ );
32
+
33
+ public static $prefixDirsPsr4 = array (
34
+ 'React\\Promise\\' =>
35
+ array (
36
+ 0 => __DIR__ . '/..' . '/react/promise/src',
37
+ ),
38
+ 'Nektria\\Recs\\MerchantApi\\' =>
39
+ array (
40
+ 0 => __DIR__ . '/..' . '/nektria/recs-sdk-php/src',
41
+ ),
42
+ 'GuzzleHttp\\Subscriber\\Log\\' =>
43
+ array (
44
+ 0 => __DIR__ . '/..' . '/guzzlehttp/log-subscriber/src',
45
+ ),
46
+ 'GuzzleHttp\\Stream\\' =>
47
+ array (
48
+ 0 => __DIR__ . '/..' . '/guzzlehttp/streams/src',
49
+ ),
50
+ 'GuzzleHttp\\Ring\\' =>
51
+ array (
52
+ 0 => __DIR__ . '/..' . '/guzzlehttp/ringphp/src',
53
+ ),
54
+ 'GuzzleHttp\\Command\\Guzzle\\' =>
55
+ array (
56
+ 0 => __DIR__ . '/..' . '/guzzlehttp/guzzle-services/src',
57
+ ),
58
+ 'GuzzleHttp\\Command\\' =>
59
+ array (
60
+ 0 => __DIR__ . '/..' . '/guzzlehttp/command/src',
61
+ ),
62
+ 'GuzzleHttp\\' =>
63
+ array (
64
+ 0 => __DIR__ . '/..' . '/guzzlehttp/guzzle/src',
65
+ ),
66
+ );
67
+
68
+ public static $prefixesPsr0 = array (
69
+ 'P' =>
70
+ array (
71
+ 'Psr\\Log\\' =>
72
+ array (
73
+ 0 => __DIR__ . '/..' . '/psr/log',
74
+ ),
75
+ ),
76
+ );
77
+
78
+ public static function getInitializer(ClassLoader $loader)
79
+ {
80
+ return \Closure::bind(function () use ($loader) {
81
+ $loader->prefixLengthsPsr4 = ComposerStaticInit77dbd97a77d94a0f0aa3f5bd04cec806::$prefixLengthsPsr4;
82
+ $loader->prefixDirsPsr4 = ComposerStaticInit77dbd97a77d94a0f0aa3f5bd04cec806::$prefixDirsPsr4;
83
+ $loader->prefixesPsr0 = ComposerStaticInit77dbd97a77d94a0f0aa3f5bd04cec806::$prefixesPsr0;
84
+
85
+ }, null, ClassLoader::class);
86
+ }
87
+ }
app/code/community/Nektria/ReCS/lib/vendor/composer/installed.json ADDED
@@ -0,0 +1,462 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "name": "psr/log",
4
+ "version": "1.0.0",
5
+ "version_normalized": "1.0.0.0",
6
+ "source": {
7
+ "type": "git",
8
+ "url": "https://github.com/php-fig/log.git",
9
+ "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b"
10
+ },
11
+ "dist": {
12
+ "type": "zip",
13
+ "url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b",
14
+ "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b",
15
+ "shasum": ""
16
+ },
17
+ "time": "2012-12-21 11:40:51",
18
+ "type": "library",
19
+ "installation-source": "dist",
20
+ "autoload": {
21
+ "psr-0": {
22
+ "Psr\\Log\\": ""
23
+ }
24
+ },
25
+ "notification-url": "https://packagist.org/downloads/",
26
+ "license": [
27
+ "MIT"
28
+ ],
29
+ "authors": [
30
+ {
31
+ "name": "PHP-FIG",
32
+ "homepage": "http://www.php-fig.org/"
33
+ }
34
+ ],
35
+ "description": "Common interface for logging libraries",
36
+ "keywords": [
37
+ "log",
38
+ "psr",
39
+ "psr-3"
40
+ ]
41
+ },
42
+ {
43
+ "name": "react/promise",
44
+ "version": "v2.4.1",
45
+ "version_normalized": "2.4.1.0",
46
+ "source": {
47
+ "type": "git",
48
+ "url": "https://github.com/reactphp/promise.git",
49
+ "reference": "8025426794f1944de806618671d4fa476dc7626f"
50
+ },
51
+ "dist": {
52
+ "type": "zip",
53
+ "url": "https://api.github.com/repos/reactphp/promise/zipball/8025426794f1944de806618671d4fa476dc7626f",
54
+ "reference": "8025426794f1944de806618671d4fa476dc7626f",
55
+ "shasum": ""
56
+ },
57
+ "require": {
58
+ "php": ">=5.4.0"
59
+ },
60
+ "time": "2016-05-03 17:50:52",
61
+ "type": "library",
62
+ "extra": {
63
+ "branch-alias": {
64
+ "dev-master": "2.0-dev"
65
+ }
66
+ },
67
+ "installation-source": "dist",
68
+ "autoload": {
69
+ "psr-4": {
70
+ "React\\Promise\\": "src/"
71
+ },
72
+ "files": [
73
+ "src/functions_include.php"
74
+ ]
75
+ },
76
+ "notification-url": "https://packagist.org/downloads/",
77
+ "license": [
78
+ "MIT"
79
+ ],
80
+ "authors": [
81
+ {
82
+ "name": "Jan Sorgalla",
83
+ "email": "jsorgalla@gmail.com"
84
+ }
85
+ ],
86
+ "description": "A lightweight implementation of CommonJS Promises/A for PHP"
87
+ },
88
+ {
89
+ "name": "guzzlehttp/streams",
90
+ "version": "3.0.0",
91
+ "version_normalized": "3.0.0.0",
92
+ "source": {
93
+ "type": "git",
94
+ "url": "https://github.com/guzzle/streams.git",
95
+ "reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5"
96
+ },
97
+ "dist": {
98
+ "type": "zip",
99
+ "url": "https://api.github.com/repos/guzzle/streams/zipball/47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5",
100
+ "reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5",
101
+ "shasum": ""
102
+ },
103
+ "require": {
104
+ "php": ">=5.4.0"
105
+ },
106
+ "require-dev": {
107
+ "phpunit/phpunit": "~4.0"
108
+ },
109
+ "time": "2014-10-12 19:18:40",
110
+ "type": "library",
111
+ "extra": {
112
+ "branch-alias": {
113
+ "dev-master": "3.0-dev"
114
+ }
115
+ },
116
+ "installation-source": "dist",
117
+ "autoload": {
118
+ "psr-4": {
119
+ "GuzzleHttp\\Stream\\": "src/"
120
+ }
121
+ },
122
+ "notification-url": "https://packagist.org/downloads/",
123
+ "license": [
124
+ "MIT"
125
+ ],
126
+ "authors": [
127
+ {
128
+ "name": "Michael Dowling",
129
+ "email": "mtdowling@gmail.com",
130
+ "homepage": "https://github.com/mtdowling"
131
+ }
132
+ ],
133
+ "description": "Provides a simple abstraction over streams of data",
134
+ "homepage": "http://guzzlephp.org/",
135
+ "keywords": [
136
+ "Guzzle",
137
+ "stream"
138
+ ]
139
+ },
140
+ {
141
+ "name": "guzzlehttp/ringphp",
142
+ "version": "1.1.0",
143
+ "version_normalized": "1.1.0.0",
144
+ "source": {
145
+ "type": "git",
146
+ "url": "https://github.com/guzzle/RingPHP.git",
147
+ "reference": "dbbb91d7f6c191e5e405e900e3102ac7f261bc0b"
148
+ },
149
+ "dist": {
150
+ "type": "zip",
151
+ "url": "https://api.github.com/repos/guzzle/RingPHP/zipball/dbbb91d7f6c191e5e405e900e3102ac7f261bc0b",
152
+ "reference": "dbbb91d7f6c191e5e405e900e3102ac7f261bc0b",
153
+ "shasum": ""
154
+ },
155
+ "require": {
156
+ "guzzlehttp/streams": "~3.0",
157
+ "php": ">=5.4.0",
158
+ "react/promise": "~2.0"
159
+ },
160
+ "require-dev": {
161
+ "ext-curl": "*",
162
+ "phpunit/phpunit": "~4.0"
163
+ },
164
+ "suggest": {
165
+ "ext-curl": "Guzzle will use specific adapters if cURL is present"
166
+ },
167
+ "time": "2015-05-20 03:37:09",
168
+ "type": "library",
169
+ "extra": {
170
+ "branch-alias": {
171
+ "dev-master": "1.1-dev"
172
+ }
173
+ },
174
+ "installation-source": "dist",
175
+ "autoload": {
176
+ "psr-4": {
177
+ "GuzzleHttp\\Ring\\": "src/"
178
+ }
179
+ },
180
+ "notification-url": "https://packagist.org/downloads/",
181
+ "license": [
182
+ "MIT"
183
+ ],
184
+ "authors": [
185
+ {
186
+ "name": "Michael Dowling",
187
+ "email": "mtdowling@gmail.com",
188
+ "homepage": "https://github.com/mtdowling"
189
+ }
190
+ ],
191
+ "description": "Provides a simple API and specification that abstracts away the details of HTTP into a single PHP function."
192
+ },
193
+ {
194
+ "name": "guzzlehttp/guzzle",
195
+ "version": "5.3.0",
196
+ "version_normalized": "5.3.0.0",
197
+ "source": {
198
+ "type": "git",
199
+ "url": "https://github.com/guzzle/guzzle.git",
200
+ "reference": "f3c8c22471cb55475105c14769644a49c3262b93"
201
+ },
202
+ "dist": {
203
+ "type": "zip",
204
+ "url": "https://api.github.com/repos/guzzle/guzzle/zipball/f3c8c22471cb55475105c14769644a49c3262b93",
205
+ "reference": "f3c8c22471cb55475105c14769644a49c3262b93",
206
+ "shasum": ""
207
+ },
208
+ "require": {
209
+ "guzzlehttp/ringphp": "^1.1",
210
+ "php": ">=5.4.0"
211
+ },
212
+ "require-dev": {
213
+ "ext-curl": "*",
214
+ "phpunit/phpunit": "^4.0",
215
+ "psr/log": "^1.0"
216
+ },
217
+ "time": "2015-05-20 03:47:55",
218
+ "type": "library",
219
+ "extra": {
220
+ "branch-alias": {
221
+ "dev-master": "5.0-dev"
222
+ }
223
+ },
224
+ "installation-source": "dist",
225
+ "autoload": {
226
+ "psr-4": {
227
+ "GuzzleHttp\\": "src/"
228
+ }
229
+ },
230
+ "notification-url": "https://packagist.org/downloads/",
231
+ "license": [
232
+ "MIT"
233
+ ],
234
+ "authors": [
235
+ {
236
+ "name": "Michael Dowling",
237
+ "email": "mtdowling@gmail.com",
238
+ "homepage": "https://github.com/mtdowling"
239
+ }
240
+ ],
241
+ "description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients",
242
+ "homepage": "http://guzzlephp.org/",
243
+ "keywords": [
244
+ "client",
245
+ "curl",
246
+ "framework",
247
+ "http",
248
+ "http client",
249
+ "rest",
250
+ "web service"
251
+ ]
252
+ },
253
+ {
254
+ "name": "guzzlehttp/log-subscriber",
255
+ "version": "1.0.1",
256
+ "version_normalized": "1.0.1.0",
257
+ "source": {
258
+ "type": "git",
259
+ "url": "https://github.com/guzzle/log-subscriber.git",
260
+ "reference": "99c3c0004165db721d8ef7bbef60c996210e538a"
261
+ },
262
+ "dist": {
263
+ "type": "zip",
264
+ "url": "https://api.github.com/repos/guzzle/log-subscriber/zipball/99c3c0004165db721d8ef7bbef60c996210e538a",
265
+ "reference": "99c3c0004165db721d8ef7bbef60c996210e538a",
266
+ "shasum": ""
267
+ },
268
+ "require": {
269
+ "guzzlehttp/guzzle": "~4.0 | ~5.0",
270
+ "php": ">=5.4.0",
271
+ "psr/log": "~1.0"
272
+ },
273
+ "require-dev": {
274
+ "phpunit/phpunit": "~4.0"
275
+ },
276
+ "time": "2014-10-13 03:31:43",
277
+ "type": "library",
278
+ "extra": {
279
+ "branch-alias": {
280
+ "dev-master": "1.0-dev"
281
+ }
282
+ },
283
+ "installation-source": "dist",
284
+ "autoload": {
285
+ "psr-4": {
286
+ "GuzzleHttp\\Subscriber\\Log\\": "src/"
287
+ }
288
+ },
289
+ "notification-url": "https://packagist.org/downloads/",
290
+ "license": [
291
+ "MIT"
292
+ ],
293
+ "authors": [
294
+ {
295
+ "name": "Michael Dowling",
296
+ "email": "mtdowling@gmail.com",
297
+ "homepage": "https://github.com/mtdowling"
298
+ }
299
+ ],
300
+ "description": "Logs HTTP requests and responses as they are sent over the wire (Guzzle 4+)",
301
+ "homepage": "http://guzzlephp.org/",
302
+ "keywords": [
303
+ "Guzzle",
304
+ "log",
305
+ "plugin"
306
+ ]
307
+ },
308
+ {
309
+ "name": "guzzlehttp/command",
310
+ "version": "0.7.1",
311
+ "version_normalized": "0.7.1.0",
312
+ "source": {
313
+ "type": "git",
314
+ "url": "https://github.com/guzzle/command.git",
315
+ "reference": "2e8286ff81f75f97b00f7dcc2f51e2efafb373bd"
316
+ },
317
+ "dist": {
318
+ "type": "zip",
319
+ "url": "https://api.github.com/repos/guzzle/command/zipball/2e8286ff81f75f97b00f7dcc2f51e2efafb373bd",
320
+ "reference": "2e8286ff81f75f97b00f7dcc2f51e2efafb373bd",
321
+ "shasum": ""
322
+ },
323
+ "require": {
324
+ "guzzlehttp/guzzle": "~5.0",
325
+ "php": ">=5.4.0"
326
+ },
327
+ "require-dev": {
328
+ "phpunit/phpunit": "~4.0"
329
+ },
330
+ "time": "2015-01-14 18:54:57",
331
+ "type": "library",
332
+ "extra": {
333
+ "branch-alias": {
334
+ "dev-master": "0.7-dev"
335
+ }
336
+ },
337
+ "installation-source": "dist",
338
+ "autoload": {
339
+ "psr-4": {
340
+ "GuzzleHttp\\Command\\": "src/"
341
+ }
342
+ },
343
+ "notification-url": "https://packagist.org/downloads/",
344
+ "license": [
345
+ "MIT"
346
+ ],
347
+ "authors": [
348
+ {
349
+ "name": "Michael Dowling",
350
+ "email": "mtdowling@gmail.com",
351
+ "homepage": "https://github.com/mtdowling"
352
+ }
353
+ ],
354
+ "description": "Provides the foundation for building command based web service clients"
355
+ },
356
+ {
357
+ "name": "guzzlehttp/guzzle-services",
358
+ "version": "0.5.0",
359
+ "version_normalized": "0.5.0.0",
360
+ "source": {
361
+ "type": "git",
362
+ "url": "https://github.com/guzzle/guzzle-services.git",
363
+ "reference": "5402867628d266748db88f05c90ede54fd1d884c"
364
+ },
365
+ "dist": {
366
+ "type": "zip",
367
+ "url": "https://api.github.com/repos/guzzle/guzzle-services/zipball/5402867628d266748db88f05c90ede54fd1d884c",
368
+ "reference": "5402867628d266748db88f05c90ede54fd1d884c",
369
+ "shasum": ""
370
+ },
371
+ "require": {
372
+ "guzzlehttp/command": "0.7.*",
373
+ "php": ">=5.4.0"
374
+ },
375
+ "require-dev": {
376
+ "phpunit/phpunit": "~4.0"
377
+ },
378
+ "time": "2014-12-23 19:13:18",
379
+ "type": "library",
380
+ "extra": {
381
+ "branch-alias": {
382
+ "dev-master": "0.4-dev"
383
+ }
384
+ },
385
+ "installation-source": "dist",
386
+ "autoload": {
387
+ "psr-4": {
388
+ "GuzzleHttp\\Command\\Guzzle\\": "src/"
389
+ }
390
+ },
391
+ "notification-url": "https://packagist.org/downloads/",
392
+ "license": [
393
+ "MIT"
394
+ ],
395
+ "authors": [
396
+ {
397
+ "name": "Michael Dowling",
398
+ "email": "mtdowling@gmail.com",
399
+ "homepage": "https://github.com/mtdowling"
400
+ }
401
+ ],
402
+ "description": "Provides an implementation of the Guzzle Command library that uses Guzzle service descriptions to describe web services, serialize requests, and parse responses into easy to use model structures."
403
+ },
404
+ {
405
+ "name": "nektria/recs-sdk-php",
406
+ "version": "v1.2.4",
407
+ "version_normalized": "1.2.4.0",
408
+ "source": {
409
+ "type": "git",
410
+ "url": "https://bitbucket.org/nektria/merchant-api-client.git",
411
+ "reference": "e0998f03bf347b40c70ba28aaa4a1708c8b50777"
412
+ },
413
+ "dist": {
414
+ "type": "zip",
415
+ "url": "https://bitbucket.org/nektria/merchant-api-client/get/e0998f03bf347b40c70ba28aaa4a1708c8b50777.zip",
416
+ "reference": "e0998f03bf347b40c70ba28aaa4a1708c8b50777",
417
+ "shasum": ""
418
+ },
419
+ "require": {
420
+ "guzzlehttp/guzzle": "5.3",
421
+ "guzzlehttp/guzzle-services": "0.5.*",
422
+ "guzzlehttp/log-subscriber": "~1.0",
423
+ "php": ">=5.4"
424
+ },
425
+ "require-dev": {
426
+ "phpunit/phpunit": "4.*"
427
+ },
428
+ "suggest": {
429
+ "ext-curl": "To send requests using cURL"
430
+ },
431
+ "time": "2016-05-06 18:05:42",
432
+ "type": "library",
433
+ "installation-source": "dist",
434
+ "autoload": {
435
+ "psr-4": {
436
+ "Nektria\\Recs\\MerchantApi\\": "src/"
437
+ }
438
+ },
439
+ "notification-url": "https://packagist.org/downloads/",
440
+ "license": [
441
+ "Apache-2.0"
442
+ ],
443
+ "authors": [
444
+ {
445
+ "name": "Nektria",
446
+ "homepage": "http://www.nektria.com/"
447
+ }
448
+ ],
449
+ "description": "Nektria Responsive eCommerce Shipping (ReCS) SDK for PHP",
450
+ "homepage": "http://www.recshipping.com",
451
+ "keywords": [
452
+ "carrier",
453
+ "ecommerce",
454
+ "lastmile",
455
+ "magento",
456
+ "nektria",
457
+ "recs",
458
+ "sdk",
459
+ "shipping"
460
+ ]
461
+ }
462
+ ]
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/command/LICENSE ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright (c) 2015 Michael Dowling, https://github.com/mtdowling <mtdowling@gmail.com>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/command/composer.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "guzzlehttp/command",
3
+ "description": "Provides the foundation for building command based web service clients",
4
+ "license": "MIT",
5
+ "authors": [
6
+ {
7
+ "name": "Michael Dowling",
8
+ "email": "mtdowling@gmail.com",
9
+ "homepage": "https://github.com/mtdowling"
10
+ }
11
+ ],
12
+ "require": {
13
+ "php": ">=5.4.0",
14
+ "guzzlehttp/guzzle": "~5.0"
15
+ },
16
+ "require-dev": {
17
+ "phpunit/phpunit": "~4.0"
18
+ },
19
+ "autoload": {
20
+ "psr-4": {
21
+ "GuzzleHttp\\Command\\": "src/"
22
+ }
23
+ },
24
+ "extra": {
25
+ "branch-alias": {
26
+ "dev-master": "0.7-dev"
27
+ }
28
+ }
29
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/command/src/AbstractClient.php ADDED
@@ -0,0 +1,285 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command;
3
+
4
+ use GuzzleHttp\ClientInterface;
5
+ use GuzzleHttp\Collection;
6
+ use GuzzleHttp\Command\Event\InitEvent;
7
+ use GuzzleHttp\Command\Event\PreparedEvent;
8
+ use GuzzleHttp\Command\Event\ProcessEvent;
9
+ use GuzzleHttp\Command\Exception\CommandException;
10
+ use GuzzleHttp\Event\EndEvent;
11
+ use GuzzleHttp\Event\HasEmitterTrait;
12
+ use GuzzleHttp\Pool;
13
+ use GuzzleHttp\Ring\Future\FutureInterface;
14
+ use GuzzleHttp\Ring\Future\FutureValue;
15
+ use GuzzleHttp\Event\RequestEvents;
16
+ use GuzzleHttp\Message\RequestInterface;
17
+
18
+ /**
19
+ * Abstract client implementation that provides a basic implementation of
20
+ * several methods. Concrete implementations may choose to extend this class
21
+ * or to completely implement all of the methods of ServiceClientInterface.
22
+ */
23
+ abstract class AbstractClient implements ServiceClientInterface
24
+ {
25
+ use HasEmitterTrait;
26
+
27
+ /** @var ClientInterface HTTP client used to send requests */
28
+ private $client;
29
+
30
+ /** @var Collection Service client configuration data */
31
+ private $config;
32
+
33
+ /**
34
+ * The default client constructor is responsible for setting private
35
+ * properties on the client and accepts an associative array of
36
+ * configuration parameters:
37
+ *
38
+ * - defaults: Associative array of default command parameters to add to
39
+ * each command created by the client.
40
+ * - emitter: (internal only) A custom event emitter to use with the client.
41
+ *
42
+ * Concrete implementations may choose to support additional configuration
43
+ * settings as needed.
44
+ *
45
+ * @param ClientInterface $client Client used to send HTTP requests
46
+ * @param array $config Client configuration options
47
+ *
48
+ * @throws \InvalidArgumentException
49
+ */
50
+ public function __construct(
51
+ ClientInterface $client,
52
+ array $config = []
53
+ ) {
54
+ $this->client = $client;
55
+
56
+ // Ensure the defaults key is an array so we can easily merge later.
57
+ if (!isset($config['defaults'])) {
58
+ $config['defaults'] = [];
59
+ }
60
+
61
+ if (isset($config['emitter'])) {
62
+ $this->emitter = $config['emitter'];
63
+ unset($config['emitter']);
64
+ }
65
+
66
+ $this->config = new Collection($config);
67
+ }
68
+
69
+ public function __call($name, array $arguments)
70
+ {
71
+ return $this->execute(
72
+ $this->getCommand(
73
+ $name,
74
+ isset($arguments[0]) ? $arguments[0] : []
75
+ )
76
+ );
77
+ }
78
+
79
+ public function execute(CommandInterface $command)
80
+ {
81
+ $trans = $this->initTransaction($command);
82
+
83
+ if ($trans->result !== null) {
84
+ return $trans->result;
85
+ }
86
+
87
+ try {
88
+ $trans->response = $this->client->send($trans->request);
89
+ return $trans->response instanceof FutureInterface
90
+ ? $this->createFutureResult($trans)
91
+ : $trans->result;
92
+ } catch (CommandException $e) {
93
+ // Command exceptions are thrown in the command layer, so throw 'em.
94
+ throw $e;
95
+ } catch (\Exception $e) {
96
+ // Handle when a command result is set after a terminal request
97
+ // error was encountered.
98
+ if ($trans->result !== null) {
99
+ return $trans->result;
100
+ }
101
+ $trans->exception = $e;
102
+ throw $this->createCommandException($trans);
103
+ }
104
+ }
105
+
106
+ public function executeAll($commands, array $options = [])
107
+ {
108
+ $this->createPool($commands, $options)->wait();
109
+ }
110
+
111
+ public function createPool($commands, array $options = [])
112
+ {
113
+ return new Pool(
114
+ $this->client,
115
+ new CommandToRequestIterator(
116
+ function (CommandInterface $command) {
117
+ $trans = $this->initTransaction($command);
118
+ return [
119
+ 'request' => $trans->request,
120
+ 'result' => $trans->result
121
+ ];
122
+ },
123
+ $commands,
124
+ $options
125
+ ),
126
+ isset($options['pool_size']) ? ['pool_size' => $options['pool_size']] : []
127
+ );
128
+ }
129
+
130
+ public function getHttpClient()
131
+ {
132
+ return $this->client;
133
+ }
134
+
135
+ public function getConfig($keyOrPath = null)
136
+ {
137
+ if ($keyOrPath === null) {
138
+ return $this->config->toArray();
139
+ }
140
+
141
+ if (strpos($keyOrPath, '/') === false) {
142
+ return $this->config[$keyOrPath];
143
+ }
144
+
145
+ return $this->config->getPath($keyOrPath);
146
+ }
147
+
148
+ public function setConfig($keyOrPath, $value)
149
+ {
150
+ $this->config->setPath($keyOrPath, $value);
151
+ }
152
+
153
+ public function createCommandException(CommandTransaction $transaction)
154
+ {
155
+ $cn = 'GuzzleHttp\\Command\\Exception\\CommandException';
156
+
157
+ // Don't continuously wrap the same exceptions.
158
+ if ($transaction->exception instanceof CommandException) {
159
+ return $transaction->exception;
160
+ }
161
+
162
+ if ($transaction->response) {
163
+ $statusCode = (string) $transaction->response->getStatusCode();
164
+ if ($statusCode[0] == '4') {
165
+ $cn = 'GuzzleHttp\\Command\\Exception\\CommandClientException';
166
+ } elseif ($statusCode[0] == '5') {
167
+ $cn = 'GuzzleHttp\\Command\\Exception\\CommandServerException';
168
+ }
169
+ }
170
+
171
+ return new $cn(
172
+ "Error executing command: " . $transaction->exception->getMessage(),
173
+ $transaction,
174
+ $transaction->exception
175
+ );
176
+ }
177
+
178
+ /**
179
+ * Prepares a request for the command.
180
+ *
181
+ * @param CommandTransaction $trans Command and context to serialize.
182
+ *
183
+ * @return RequestInterface
184
+ */
185
+ abstract protected function serializeRequest(CommandTransaction $trans);
186
+
187
+ /**
188
+ * Creates a future result for a given command transaction.
189
+ *
190
+ * This method really should beoverridden in subclasses to implement custom
191
+ * future response results.
192
+ *
193
+ * @param CommandTransaction $transaction
194
+ *
195
+ * @return FutureInterface
196
+ */
197
+ protected function createFutureResult(CommandTransaction $transaction)
198
+ {
199
+ return new FutureValue(
200
+ $transaction->response->then(function () use ($transaction) {
201
+ return $transaction->result;
202
+ }),
203
+ // Wait function derefs the response which populates the result.
204
+ [$transaction->response, 'wait'],
205
+ [$transaction->response, 'cancel']
206
+ );
207
+ }
208
+
209
+ /**
210
+ * Initialize a transaction for a command and send the prepare event.
211
+ *
212
+ * @param CommandInterface $command Command to associate with the trans.
213
+ *
214
+ * @return CommandTransaction
215
+ */
216
+ protected function initTransaction(CommandInterface $command)
217
+ {
218
+ $trans = new CommandTransaction($this, $command);
219
+ // Throwing in the init event WILL NOT emit an error event.
220
+ $command->getEmitter()->emit('init', new InitEvent($trans));
221
+ $trans->request = $this->serializeRequest($trans);
222
+
223
+ if ($future = $command->getFuture()) {
224
+ $trans->request->getConfig()->set('future', $future);
225
+ }
226
+
227
+ $trans->state = 'prepared';
228
+ $prep = new PreparedEvent($trans);
229
+
230
+ try {
231
+ $command->getEmitter()->emit('prepared', $prep);
232
+ } catch (\Exception $e) {
233
+ $trans->exception = $e;
234
+ $trans->exception = $this->createCommandException($trans);
235
+ }
236
+
237
+ // If the command failed in the prepare event or was intercepted, then
238
+ // emit the process event now and skip hooking up the request.
239
+ if ($trans->exception || $prep->isPropagationStopped()) {
240
+ $this->emitProcess($trans);
241
+ return $trans;
242
+ }
243
+
244
+ $trans->state = 'executing';
245
+
246
+ // When a request completes, process the request at the command
247
+ // layer.
248
+ $trans->request->getEmitter()->on(
249
+ 'end',
250
+ function (EndEvent $e) use ($trans) {
251
+ $trans->response = $e->getResponse();
252
+ if ($trans->exception = $e->getException()) {
253
+ $trans->exception = $this->createCommandException($trans);
254
+ }
255
+ $this->emitProcess($trans);
256
+ }, RequestEvents::LATE
257
+ );
258
+
259
+ return $trans;
260
+ }
261
+
262
+ /**
263
+ * Finishes the process event for the command.
264
+ */
265
+ private function emitProcess(CommandTransaction $trans)
266
+ {
267
+ $trans->state = 'process';
268
+
269
+ try {
270
+ // Emit the final "process" event for the command.
271
+ $trans->command->getEmitter()->emit('process', new ProcessEvent($trans));
272
+ } catch (\Exception $ex) {
273
+ // Override any previous exception with the most recent exception.
274
+ $trans->exception = $ex;
275
+ $trans->exception = $this->createCommandException($trans);
276
+ }
277
+
278
+ $trans->state = 'end';
279
+
280
+ // If the transaction still has the exception, then throw it.
281
+ if ($trans->exception) {
282
+ throw $trans->exception;
283
+ }
284
+ }
285
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/command/src/Command.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command;
3
+
4
+ use GuzzleHttp\HasDataTrait;
5
+ use GuzzleHttp\Event\HasEmitterTrait;
6
+
7
+ /**
8
+ * Default command implementation.
9
+ */
10
+ class Command implements CommandInterface
11
+ {
12
+ use HasDataTrait, HasEmitterTrait;
13
+
14
+ /** @var string */
15
+ private $name;
16
+
17
+ /** @var bool */
18
+ private $future = false;
19
+
20
+ /**
21
+ * @param string $name Name of the command
22
+ * @param array $args Arguments to pass to the command
23
+ * @param array $options Array of command options.
24
+ * - emitter: Event emitter to use.
25
+ * - future: Set to true to create a future async
26
+ * command.
27
+ */
28
+ public function __construct(
29
+ $name,
30
+ array $args = [],
31
+ array $options = []
32
+ ) {
33
+ $this->name = $name;
34
+ $this->data = $args;
35
+
36
+ if (isset($options['emitter'])) {
37
+ $this->emitter = $options['emitter'];
38
+ }
39
+
40
+ if (isset($options['future'])) {
41
+ $this->future = $options['future'];
42
+ }
43
+ }
44
+
45
+ /**
46
+ * Ensure that the emitter is cloned.
47
+ */
48
+ public function __clone()
49
+ {
50
+ if ($this->emitter) {
51
+ $this->emitter = clone $this->emitter;
52
+ }
53
+ }
54
+
55
+ public function getName()
56
+ {
57
+ return $this->name;
58
+ }
59
+
60
+ public function hasParam($name)
61
+ {
62
+ return array_key_exists($name, $this->data);
63
+ }
64
+
65
+ public function setFuture($useFuture)
66
+ {
67
+ $this->future = $useFuture;
68
+ }
69
+
70
+ public function getFuture()
71
+ {
72
+ return $this->future;
73
+ }
74
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/command/src/CommandInterface.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command;
3
+
4
+ use GuzzleHttp\Event\HasEmitterInterface;
5
+ use GuzzleHttp\ToArrayInterface;
6
+
7
+ /**
8
+ * A command object encapsulates the input parameters used to control the
9
+ * creation of a HTTP request and processing of a HTTP response.
10
+ *
11
+ * Using the toArray() method will return the input parameters of the command
12
+ * as an associative array.
13
+ *
14
+ * A command emits the following events:
15
+ * - prepare: Emitted when the command is converting a command into a request
16
+ * - process: Emitted when the command is processing a response
17
+ * - error: Emitted after an error occurs for a command.
18
+ */
19
+ interface CommandInterface extends
20
+ \ArrayAccess,
21
+ ToArrayInterface,
22
+ HasEmitterInterface
23
+ {
24
+ /**
25
+ * Get the name of the command
26
+ *
27
+ * @return string
28
+ */
29
+ public function getName();
30
+
31
+ /**
32
+ * Check if the command has a parameter by name.
33
+ *
34
+ * @param string $name Name of the parameter to check
35
+ *
36
+ * @return bool
37
+ */
38
+ public function hasParam($name);
39
+
40
+ /**
41
+ * Specify whether or not the command will return a future result if the
42
+ * underlying adapter supports it.
43
+ *
44
+ * @param bool|string $useFuture Set to true or false or a future string.
45
+ */
46
+ public function setFuture($useFuture);
47
+
48
+ /**
49
+ * Gets the future setting of the command.
50
+ *
51
+ * @return bool|string
52
+ */
53
+ public function getFuture();
54
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/command/src/CommandToRequestIterator.php ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command;
3
+
4
+ use GuzzleHttp\Command\Event\ProcessEvent;
5
+ use GuzzleHttp\Event\RequestEvents;
6
+ use GuzzleHttp\Message\RequestInterface;
7
+ use GuzzleHttp\Event\ListenerAttacherTrait;
8
+ use GuzzleHttp\Ring\Core;
9
+
10
+ /**
11
+ * Iterator used for easily creating request objects from an iterator or array
12
+ * that contains commands.
13
+ *
14
+ * This iterator is useful when implementing the
15
+ * {@see ServiceClientInterface::executeAll()} method.
16
+ */
17
+ class CommandToRequestIterator implements \Iterator
18
+ {
19
+ use ListenerAttacherTrait;
20
+
21
+ /** @var \Iterator */
22
+ private $commands;
23
+
24
+ /** @var callable request builder function */
25
+ private $requestBuilder;
26
+
27
+ /** @var RequestInterface|null Current request */
28
+ private $currentRequest;
29
+
30
+ /** @var array Listeners to attach to each command */
31
+ private $eventListeners = [];
32
+
33
+ /**
34
+ * @param callable $requestBuilder A function that accepts a command and
35
+ * returns a hash containing a request key mapping to a request that
36
+ * has emitted it's prepare event, and a result key mapping to the
37
+ * result if one was injected in the prepare event.
38
+ * @param array|\Iterator $commands Collection of command objects
39
+ * @param array $options Hash of options:
40
+ * - prepare: Callable to invoke for the "prepare" event. This event is
41
+ * called only once per execution.
42
+ * - before: Callable to invoke when the "process" event is fired. This
43
+ * event is fired one or more times.
44
+ * - process: Callable to invoke when the "process" event is fired. This
45
+ * event can be fired one or more times.
46
+ * - error: Callable to invoke when the "error" event of a command is
47
+ * emitted. This event can be fired one or more times.
48
+ * - end: Callable to invoke when the terminal "end" event of a command
49
+ * is emitted. This event is fired once per command execution.
50
+ *
51
+ * @throws \InvalidArgumentException If the source is invalid
52
+ */
53
+ public function __construct(
54
+ callable $requestBuilder,
55
+ $commands,
56
+ array $options = []
57
+ ) {
58
+ $this->requestBuilder = $requestBuilder;
59
+ $this->eventListeners = $this->prepareListeners(
60
+ $options,
61
+ ['init', 'prepared', 'process']
62
+ );
63
+
64
+ if ($commands instanceof \Iterator) {
65
+ $this->commands = $commands;
66
+ } elseif (is_array($commands)) {
67
+ $this->commands = new \ArrayIterator($commands);
68
+ } else {
69
+ throw new \InvalidArgumentException('Command iterators must be '
70
+ . 'created using an \\Iterator or array or commands');
71
+ }
72
+ }
73
+
74
+ public function current()
75
+ {
76
+ return $this->currentRequest;
77
+ }
78
+
79
+ public function next()
80
+ {
81
+ $this->currentRequest = null;
82
+ $this->commands->next();
83
+ }
84
+
85
+ public function key()
86
+ {
87
+ return $this->commands->key();
88
+ }
89
+
90
+ public function valid()
91
+ {
92
+ get_next:
93
+
94
+ // Return true if this function has already been called for iteration.
95
+ if ($this->currentRequest) {
96
+ return true;
97
+ }
98
+
99
+ // Return false if we are at the end of the provided commands iterator.
100
+ if (!$this->commands->valid()) {
101
+ return false;
102
+ }
103
+
104
+ $command = $this->commands->current();
105
+
106
+ if (!($command instanceof CommandInterface)) {
107
+ throw new \RuntimeException('All commands provided to the ' . __CLASS__
108
+ . ' must implement GuzzleHttp\\Command\\CommandInterface.'
109
+ . ' Encountered a ' . Core::describeType($command) . ' value.');
110
+ }
111
+
112
+ $command->setFuture('lazy');
113
+ $this->attachListeners($command, $this->eventListeners);
114
+
115
+ // Prevent transfer exceptions from throwing.
116
+ $command->getEmitter()->on(
117
+ 'process',
118
+ function (ProcessEvent $e) {
119
+ if ($e->getException()) {
120
+ $e->setResult(null);
121
+ }
122
+ },
123
+ RequestEvents::LATE
124
+ );
125
+
126
+ $builder = $this->requestBuilder;
127
+ $result = $builder($command);
128
+
129
+ // Skip commands that were intercepted with a result.
130
+ if (isset($result['result'])) {
131
+ $this->commands->next();
132
+ goto get_next;
133
+ }
134
+
135
+ $this->currentRequest = $result['request'];
136
+
137
+ return true;
138
+ }
139
+
140
+ public function rewind()
141
+ {
142
+ $this->currentRequest = null;
143
+
144
+ if (!($this->commands instanceof \Generator)) {
145
+ $this->commands->rewind();
146
+ }
147
+ }
148
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/command/src/CommandTransaction.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command;
3
+
4
+ use GuzzleHttp\Collection;
5
+ use GuzzleHttp\Command\Exception\CommandException;
6
+ use GuzzleHttp\Message\RequestInterface;
7
+ use GuzzleHttp\Message\ResponseInterface;
8
+ use GuzzleHttp\ClientInterface;
9
+
10
+ /**
11
+ * Represents a command transaction as it is sent over the wire and inspected
12
+ * by event listeners.
13
+ */
14
+ class CommandTransaction
15
+ {
16
+ /**
17
+ * Web service client used in the transaction
18
+ *
19
+ * @var ServiceClientInterface
20
+ */
21
+ public $serviceClient;
22
+
23
+ /**
24
+ * The command being executed.
25
+ *
26
+ * @var CommandInterface
27
+ */
28
+ public $command;
29
+
30
+ /**
31
+ * The result of the command (if available)
32
+ *
33
+ * @var mixed|null
34
+ */
35
+ public $result;
36
+
37
+ /**
38
+ * The exception that was received while transferring (if any).
39
+ *
40
+ * @var CommandException
41
+ */
42
+ public $exception;
43
+
44
+ /**
45
+ * Contains contextual information about the transaction.
46
+ *
47
+ * The information added to this collection can be anything required to
48
+ * implement a command abstraction.
49
+ *
50
+ * @var Collection
51
+ */
52
+ public $context;
53
+
54
+ /**
55
+ * HTTP client used to transfer the request.
56
+ *
57
+ * @var ClientInterface
58
+ */
59
+ public $client;
60
+
61
+ /**
62
+ * The request that is being sent.
63
+ *
64
+ * @var RequestInterface
65
+ */
66
+ public $request;
67
+
68
+ /**
69
+ * The response associated with the transaction. A response will not be
70
+ * present when a networking error occurs or an error occurs before sending
71
+ * the request.
72
+ *
73
+ * @var ResponseInterface|null
74
+ */
75
+ public $response;
76
+
77
+ /**
78
+ * The transaction's state.
79
+ *
80
+ * @var string
81
+ */
82
+ public $state;
83
+
84
+ /**
85
+ * @param ServiceClientInterface $client Client that executes commands.
86
+ * @param CommandInterface $command Command being executed.
87
+ * @param array $context Command context array of data.
88
+ */
89
+ public function __construct(
90
+ ServiceClientInterface $client,
91
+ CommandInterface $command,
92
+ array $context = []
93
+ ) {
94
+ $this->serviceClient = $client;
95
+ $this->client = $client->getHttpClient();
96
+ $this->command = $command;
97
+ $this->context = new Collection($context);
98
+ $this->state = 'init';
99
+ }
100
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/command/src/CommandUtils.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command;
3
+
4
+ use GuzzleHttp\Event\RequestEvents;
5
+ use GuzzleHttp\Command\Event\ProcessEvent;
6
+ use GuzzleHttp\BatchResults;
7
+
8
+ /**
9
+ * Provides useful functions for interacting with web service clients.
10
+ */
11
+ class CommandUtils
12
+ {
13
+ /**
14
+ * Sends multiple commands concurrently and returns a hash map of commands
15
+ * mapped to their corresponding result or exception.
16
+ *
17
+ * Note: This method keeps every command and command and result in memory,
18
+ * and as such is NOT recommended when sending a large number or an
19
+ * indeterminable number of commands concurrently. Instead, you should use
20
+ * executeAll() and utilize the event system to work with results.
21
+ *
22
+ * @param ServiceClientInterface $client
23
+ * @param array|\Iterator $commands Commands to send.
24
+ * @param array $options Passes through the options available
25
+ * in {@see ServiceClientInterface::createPool()}
26
+ *
27
+ * @return BatchResults
28
+ * @throws \InvalidArgumentException if the event format is incorrect.
29
+ */
30
+ public static function batch(
31
+ ServiceClientInterface $client,
32
+ $commands,
33
+ array $options = []
34
+ ) {
35
+ $hash = new \SplObjectStorage();
36
+ foreach ($commands as $command) {
37
+ $hash->attach($command);
38
+ }
39
+
40
+ $client->executeAll($commands, RequestEvents::convertEventArray(
41
+ $options,
42
+ ['process'],
43
+ [
44
+ 'priority' => RequestEvents::LATE,
45
+ 'fn' => function (ProcessEvent $e) use ($hash) {
46
+ if ($e->getException()) {
47
+ $hash[$e->getCommand()] = $e->getException();
48
+ } else {
49
+ $hash[$e->getCommand()] = $e->getResult();
50
+ }
51
+ }
52
+ ]
53
+ ));
54
+
55
+ return new BatchResults($hash);
56
+ }
57
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/command/src/Event/CommandEvent.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command\Event;
3
+
4
+ use GuzzleHttp\Event\AbstractEvent;
5
+ use GuzzleHttp\Command\CommandInterface;
6
+ use GuzzleHttp\Command\ServiceClientInterface;
7
+ use GuzzleHttp\Command\CommandTransaction;
8
+ use GuzzleHttp\Collection;
9
+
10
+ /**
11
+ * Base command event that is emitted.
12
+ */
13
+ class CommandEvent extends AbstractEvent
14
+ {
15
+ /** @var CommandTransaction */
16
+ protected $trans;
17
+
18
+ /**
19
+ * @param CommandTransaction $trans Command transaction
20
+ */
21
+ public function __construct(CommandTransaction $trans)
22
+ {
23
+ $this->trans = $trans;
24
+ }
25
+
26
+ /**
27
+ * Get the command associated with the event
28
+ *
29
+ * @return CommandInterface
30
+ */
31
+ public function getCommand()
32
+ {
33
+ return $this->trans->command;
34
+ }
35
+
36
+ /**
37
+ * Get the service client associated with the command transfer.
38
+ *
39
+ * @return ServiceClientInterface
40
+ */
41
+ public function getClient()
42
+ {
43
+ return $this->trans->serviceClient;
44
+ }
45
+
46
+ /**
47
+ * Get context associated with the command transfer.
48
+ *
49
+ * The return value is a Guzzle collection object which can be accessed and
50
+ * mutated like a PHP associative array. You can add arbitrary data to the
51
+ * context for application specific purposes.
52
+ *
53
+ * @return Collection
54
+ */
55
+ public function getContext()
56
+ {
57
+ return $this->trans->context;
58
+ }
59
+
60
+ /**
61
+ * Gets the transaction associated with the event
62
+ *
63
+ * @return CommandTransaction
64
+ */
65
+ public function getTransaction()
66
+ {
67
+ return $this->trans;
68
+ }
69
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/command/src/Event/InitEvent.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command\Event;
3
+
4
+ /**
5
+ * Event fired when a command is initializing before a request is serialized.
6
+ *
7
+ * This event is useful for adding default parameters and command validation.
8
+ */
9
+ class InitEvent extends CommandEvent {}
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/command/src/Event/PreparedEvent.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command\Event;
3
+
4
+ use GuzzleHttp\Command\CommandTransaction;
5
+ use GuzzleHttp\Message\RequestInterface;
6
+ use GuzzleHttp\Exception\StateException;
7
+
8
+ /**
9
+ * Event emitted when a command is being prepared.
10
+ *
11
+ * Event listeners can use this event to modify the request that was created
12
+ * by the client, and to intercept the event to prevent HTTP requests from
13
+ * being sent over the wire.
14
+ *
15
+ * This event provides a good way for a listener to hook into the HTTP level
16
+ * event system.
17
+ */
18
+ class PreparedEvent extends CommandEvent
19
+ {
20
+ /**
21
+ * @param CommandTransaction $trans Command transaction
22
+ * @throws StateException
23
+ */
24
+ public function __construct(CommandTransaction $trans)
25
+ {
26
+ if (!$trans->request) {
27
+ throw new StateException('No request on the command transaction');
28
+ }
29
+
30
+ $this->trans = $trans;
31
+ }
32
+
33
+ /**
34
+ * Gets the HTTP request that will be sent for the command.
35
+ *
36
+ * @return RequestInterface
37
+ */
38
+ public function getRequest()
39
+ {
40
+ return $this->trans->request;
41
+ }
42
+
43
+ /**
44
+ * Set a result on the command transaction to prevent the command from
45
+ * actually sending an HTTP request.
46
+ *
47
+ * Subsequent listeners ARE NOT emitted even when a result is set in the
48
+ * prepare event.
49
+ *
50
+ * @param mixed $result Result to associate with the command
51
+ */
52
+ public function intercept($result)
53
+ {
54
+ $this->trans->exception = null;
55
+ $this->trans->result = $result;
56
+ $this->stopPropagation();
57
+ }
58
+
59
+ /**
60
+ * Returns the result of the command (if one is available).
61
+ *
62
+ * @return mixed|null
63
+ */
64
+ public function getResult()
65
+ {
66
+ return $this->trans->result;
67
+ }
68
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/command/src/Event/ProcessEvent.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command\Event;
3
+
4
+ use GuzzleHttp\Message\RequestInterface;
5
+ use GuzzleHttp\Message\ResponseInterface;
6
+
7
+ /**
8
+ * Event emitted when the command has finished executing the underlying
9
+ * request. This event is emitted to process the the result of a command.
10
+ *
11
+ * This event is emitted when there is an exception or when the underlying
12
+ * request succeeded. You'll need to account for both cases when listening
13
+ * to the process event.
14
+ */
15
+ class ProcessEvent extends CommandEvent
16
+ {
17
+ /**
18
+ * Returns an exception if one was encountered.
19
+ *
20
+ * @return \Exception|null
21
+ */
22
+ public function getException()
23
+ {
24
+ return $this->trans->exception;
25
+ }
26
+
27
+ /**
28
+ * Gets the HTTP request that was sent.
29
+ *
30
+ * @return RequestInterface
31
+ */
32
+ public function getRequest()
33
+ {
34
+ return $this->trans->request;
35
+ }
36
+
37
+ /**
38
+ * Get the response that was received for the request if one was received.
39
+ *
40
+ * It is important to remember that a response will not be available if the
41
+ * HTTP request failed with a networking error.
42
+ *
43
+ * @return ResponseInterface|null
44
+ */
45
+ public function getResponse()
46
+ {
47
+ return $this->trans->response;
48
+ }
49
+
50
+ /**
51
+ * Set the processed result on the event.
52
+ *
53
+ * Subsequent listeners ARE STILL emitted even when a result is set.
54
+ * Calling this method will remove any exceptions associated with the
55
+ * command.
56
+ *
57
+ * @param mixed $result Result to associate with the command
58
+ */
59
+ public function setResult($result)
60
+ {
61
+ $this->trans->exception = null;
62
+ $this->trans->result = $result;
63
+ }
64
+
65
+ /**
66
+ * Returns the result of the command (if one is available).
67
+ *
68
+ * @return mixed|null
69
+ */
70
+ public function getResult()
71
+ {
72
+ return $this->trans->result;
73
+ }
74
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/command/src/Exception/CommandClientException.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command\Exception;
3
+
4
+ /**
5
+ * Exception encountered when a 4xx level response is received for a request
6
+ */
7
+ class CommandClientException extends CommandException {}
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/command/src/Exception/CommandException.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command\Exception;
3
+
4
+ use GuzzleHttp\Command\CommandTransaction;
5
+ use GuzzleHttp\Exception\RequestException;
6
+ use GuzzleHttp\Command\ServiceClientInterface;
7
+ use GuzzleHttp\Command\CommandInterface;
8
+ use GuzzleHttp\Collection;
9
+ use GuzzleHttp\Message\Request;
10
+
11
+ /**
12
+ * Exception encountered while transferring a command.
13
+ */
14
+ class CommandException extends RequestException
15
+ {
16
+ /** @var CommandTransaction */
17
+ private $trans;
18
+
19
+ /**
20
+ * @param string $message Exception message
21
+ * @param CommandTransaction $trans Contextual transfer information
22
+ * @param \Exception $previous Previous exception (if any)
23
+ */
24
+ public function __construct(
25
+ $message,
26
+ CommandTransaction $trans,
27
+ \Exception $previous = null
28
+ ) {
29
+ $this->trans = $trans;
30
+ $request = $trans->request ?: new Request(null, null);
31
+ $response = $trans->response;
32
+ parent::__construct($message, $request, $response, $previous);
33
+ }
34
+
35
+ /**
36
+ * Gets the service client associated with the failed command.
37
+ *
38
+ * @return ServiceClientInterface
39
+ */
40
+ public function getClient()
41
+ {
42
+ return $this->trans->serviceClient;
43
+ }
44
+
45
+ /**
46
+ * Gets the command that failed.
47
+ *
48
+ * @return CommandInterface
49
+ */
50
+ public function getCommand()
51
+ {
52
+ return $this->trans->command;
53
+ }
54
+
55
+ /**
56
+ * Gets the result of the command if a result was set.
57
+ *
58
+ * @return mixed
59
+ */
60
+ public function getResult()
61
+ {
62
+ return $this->trans->result;
63
+ }
64
+
65
+ /**
66
+ * Gets the context of the command as a collection.
67
+ *
68
+ * @return Collection
69
+ */
70
+ public function getContext()
71
+ {
72
+ return $this->trans->context;
73
+ }
74
+
75
+ /**
76
+ * Gets the transaction associated with the exception.
77
+ *
78
+ * @return CommandTransaction
79
+ */
80
+ public function getTransaction()
81
+ {
82
+ return $this->trans;
83
+ }
84
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/command/src/Exception/CommandServerException.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command\Exception;
3
+
4
+ /**
5
+ * Exception encountered when a 5xx level response is received for a request
6
+ */
7
+ class CommandServerException extends CommandException {}
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/command/src/ServiceClientInterface.php ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command;
3
+
4
+ use GuzzleHttp\Event\HasEmitterInterface;
5
+ use GuzzleHttp\ClientInterface;
6
+ use GuzzleHttp\Ring\FutureInterface;
7
+
8
+ /**
9
+ * Web service client interface.
10
+ *
11
+ * Any event listener or subscriber added to the client is added to each
12
+ * command created by the client when the command is created.
13
+ */
14
+ interface ServiceClientInterface extends HasEmitterInterface
15
+ {
16
+ /**
17
+ * Creates and executes a command for an operation by name.
18
+ *
19
+ * @param string $name Name of the command to execute.
20
+ * @param array $arguments Arguments to pass to the getCommand method.
21
+ *
22
+ * @throws \Exception
23
+ * @see \GuzzleHttp\Command\ServiceClientInterface::getCommand
24
+ */
25
+ public function __call($name, array $arguments);
26
+
27
+ /**
28
+ * Create a command for an operation name.
29
+ *
30
+ * Special keys may be set on the command to control how it behaves.
31
+ * Implementations SHOULD be able to utilize the following keys or throw
32
+ * an exception if unable.
33
+ *
34
+ * - @future: Set to true to create a future if possible. When processed,
35
+ * the "@future" key value pair can be removed from the input data before
36
+ * serializing the command.
37
+ *
38
+ * @param string $name Name of the operation to use in the command
39
+ * @param array $args Arguments to pass to the command
40
+ *
41
+ * @return CommandInterface
42
+ * @throws \InvalidArgumentException if no command can be found by name
43
+ */
44
+ public function getCommand($name, array $args = []);
45
+
46
+ /**
47
+ * Execute a single command.
48
+ *
49
+ * @param CommandInterface $command Command to execute
50
+ *
51
+ * @return mixed Returns the result of the executed command
52
+ * @throws \Exception
53
+ */
54
+ public function execute(CommandInterface $command);
55
+
56
+ /**
57
+ * Executes many commands concurrently using a fixed pool size.
58
+ *
59
+ * Exceptions encountered while executing the commands will not be thrown.
60
+ * Instead, callers are expected to handle errors using the event system.
61
+ *
62
+ * $commands = [$client->getCommand('foo', ['baz' => 'bar'])];
63
+ * $client->executeAll($commands);
64
+ *
65
+ * @param array|\Iterator $commands Array or iterator that contains
66
+ * CommandInterface objects to execute.
67
+ * @param array $options Associative array of options to apply.
68
+ * @see GuzzleHttp\Command\ServiceClientInterface::createCommandPool for
69
+ * a list of options.
70
+ */
71
+ public function executeAll($commands, array $options = []);
72
+
73
+ /**
74
+ * Creates a future object that, when dereferenced, sends commands in
75
+ * parallel using a fixed pool size.
76
+ *
77
+ * Exceptions encountered while executing the commands will not be thrown.
78
+ * Instead, callers are expected to handle errors using the event system.
79
+ *
80
+ * @param array|\Iterator $commands Array or iterator that contains
81
+ * CommandInterface objects to execute with the client.
82
+ * @param array $options Associative array of options to apply.
83
+ * - pool_size: (int) Max number of commands to send concurrently.
84
+ * When this number of concurrent requests are created, the sendAll
85
+ * function blocks until all of the futures have completed.
86
+ * - init: (callable) Receives an InitEvent from each command.
87
+ * - prepare: (callable) Receives a PrepareEvent from each command.
88
+ * - process: (callable) Receives a ProcessEvent from each command.
89
+ *
90
+ * @return FutureInterface
91
+ */
92
+ public function createPool($commands, array $options = []);
93
+
94
+ /**
95
+ * Get the HTTP client used to send requests for the web service client
96
+ *
97
+ * @return ClientInterface
98
+ */
99
+ public function getHttpClient();
100
+
101
+ /**
102
+ * Get a client configuration value.
103
+ *
104
+ * @param string|int|null $keyOrPath The Path to a particular configuration
105
+ * value. The syntax uses a path notation that allows you to retrieve
106
+ * nested array values without throwing warnings.
107
+ *
108
+ * @return mixed
109
+ */
110
+ public function getConfig($keyOrPath = null);
111
+
112
+ /**
113
+ * Set a client configuration value at the specified configuration path.
114
+ *
115
+ * @param string|int $keyOrPath Path at which to change a configuration
116
+ * value. This path syntax follows the same path syntax specified in
117
+ * {@see getConfig}.
118
+ *
119
+ * @param mixed $value Value to set
120
+ */
121
+ public function setConfig($keyOrPath, $value);
122
+
123
+ /**
124
+ * Create an exception for a command based on a previous exception.
125
+ *
126
+ * This method is invoked when an exception occurs while executing a
127
+ * command. You may choose to use a custom exception class for exceptions
128
+ * or return the provided exception as-is.
129
+ *
130
+ * @param CommandTransaction $transaction Command transaction context
131
+ *
132
+ * @return \Exception
133
+ */
134
+ public function createCommandException(CommandTransaction $transaction);
135
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/command/src/Subscriber/Debug.php ADDED
@@ -0,0 +1,427 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command\Subscriber;
3
+
4
+ use GuzzleHttp\Command\CommandInterface;
5
+ use GuzzleHttp\Command\Event\InitEvent;
6
+ use GuzzleHttp\Command\Event\PreparedEvent;
7
+ use GuzzleHttp\Command\Event\ProcessEvent;
8
+ use GuzzleHttp\Command\ServiceClientInterface;
9
+ use GuzzleHttp\Event\EventInterface;
10
+ use GuzzleHttp\Event\RequestEvents;
11
+ use GuzzleHttp\Event\SubscriberInterface;
12
+ use GuzzleHttp\Message\AbstractMessage;
13
+ use GuzzleHttp\Message\MessageInterface;
14
+ use GuzzleHttp\Stream\Stream;
15
+ use GuzzleHttp\Stream\StreamInterface;
16
+ use GuzzleHttp\ToArrayInterface;
17
+
18
+ /**
19
+ * Provides debug information about operations, including HTTP wire traces.
20
+ *
21
+ * This subscriber is useful for debugging the command and request event
22
+ * system and seeing what data was sent and received over the wire.
23
+ */
24
+ class Debug implements SubscriberInterface
25
+ {
26
+ /** @var \GuzzleHttp\Stream\StreamInterface */
27
+ private $output;
28
+ private $http;
29
+ private $maxStreamSize;
30
+ private $states;
31
+ private $adapterDebug;
32
+
33
+ /**
34
+ * The constructor accepts a hash of debug options.
35
+ *
36
+ * - output: Where debug data is written (fopen or StreamInterface)
37
+ * - http: Set to false to not display debug HTTP event data
38
+ * - max_stream_size: Set to an integer to override the default maximum
39
+ * stream size of 10240 bytes (or 10 KB). This value determines whether
40
+ * or not stream data is written to the output stream based on the size
41
+ * of the stream.
42
+ * - adapter_debug: Set to false to disable turning on the debug adapter
43
+ * setting.
44
+ *
45
+ * @param array $options Hash of debug options
46
+ */
47
+ public function __construct(array $options = [])
48
+ {
49
+ $this->states = new \SplObjectStorage();
50
+ $this->output = isset($options['output'])
51
+ ? $options['output']
52
+ : fopen('php://output', 'w');
53
+ $this->output = Stream::factory($this->output);
54
+ $this->http = isset($options['http']) ? $options['http'] : true;
55
+ $this->adapterDebug = isset($options['adapter_debug'])
56
+ ? $options['adapter_debug']
57
+ : true;
58
+ $this->maxStreamSize = isset($options['max_stream_size'])
59
+ ? $options['max_stream_size']
60
+ : 10240;
61
+ }
62
+
63
+ public function getEvents()
64
+ {
65
+ return [
66
+ 'init' => [
67
+ ['beforeInit', 'first'],
68
+ ['afterInit', 'last']
69
+ ],
70
+ 'prepared' => [
71
+ ['beforePrepared', 'first'],
72
+ ['afterPrepared', 'last']
73
+ ],
74
+ 'process' => [
75
+ ['beforeProcess', 'first'],
76
+ ['afterProcess', 'last']
77
+ ]
78
+ ];
79
+ }
80
+
81
+ private function write($text)
82
+ {
83
+ $this->output->write(date('c') . ': ' . $text . PHP_EOL);
84
+ }
85
+
86
+ private function hashCommand(
87
+ ServiceClientInterface $client,
88
+ CommandInterface $command,
89
+ EventInterface $event
90
+ ) {
91
+ return get_class($client) . '::' . $command->getName()
92
+ . ' (' . spl_object_hash($event) . ')';
93
+ }
94
+
95
+ private function startEvent(
96
+ $name,
97
+ $hash,
98
+ $command,
99
+ $request = null,
100
+ $response = null,
101
+ $result = null,
102
+ $error = null
103
+ ) {
104
+ $last = isset($this->states[$command])
105
+ ? $this->states[$command]
106
+ : null;
107
+ $this->states[$command] = $this->eventState(func_get_args());
108
+ $this->write(sprintf(
109
+ "Starting the %s event for %s: %s",
110
+ $name,
111
+ $hash,
112
+ $this->diffStates($last, $this->states[$command])
113
+ ));
114
+ }
115
+
116
+ private function endEvent(
117
+ $name,
118
+ $hash,
119
+ $command,
120
+ $request = null,
121
+ $response = null,
122
+ $result = null,
123
+ $error = null
124
+ ) {
125
+ if (!isset($this->states[$command])) {
126
+ throw new \RuntimeException('Matching start event not found');
127
+ }
128
+
129
+ $last = $this->states[$command];
130
+ $this->states[$command] = $this->eventState(func_get_args());
131
+ $this->write(sprintf(
132
+ "Done with the %s event for %s (took %f seconds): %s",
133
+ $name,
134
+ $hash,
135
+ microtime(true) - $last['time'],
136
+ $this->diffStates($last, $this->states[$command])
137
+ ));
138
+ }
139
+
140
+ public function beforeInit(InitEvent $e)
141
+ {
142
+ $this->proxyEvent('command:init', $e);
143
+ }
144
+
145
+ public function afterInit(InitEvent $e)
146
+ {
147
+ $this->proxyEvent('command:init', $e);
148
+ }
149
+
150
+ public function beforePrepared(PreparedEvent $e)
151
+ {
152
+ $this->proxyEvent('command:prepared', $e);
153
+ }
154
+
155
+ public function afterPrepared(PreparedEvent $e)
156
+ {
157
+ $this->proxyEvent('command:prepared', $e);
158
+ $request = $e->getRequest();
159
+
160
+ if (!$this->http || !$request) {
161
+ return;
162
+ }
163
+
164
+ if ($this->adapterDebug) {
165
+ $request->getConfig()->set('debug', true);
166
+ }
167
+
168
+ // Attach listeners to request events
169
+ $before = function ($before) use ($e) {
170
+ $this->proxyReqEvent('startEvent', $e, $before);
171
+ };
172
+
173
+ $after = function ($after) use ($e) {
174
+ $this->proxyReqEvent('endEvent', $e, $after);
175
+ };
176
+
177
+ foreach (['before', 'complete', 'error', 'end'] as $event) {
178
+ $request->getEmitter()->on($event, $before, RequestEvents::EARLY);
179
+ $request->getEmitter()->on($event, $after, RequestEvents::LATE);
180
+ }
181
+ }
182
+
183
+ public function beforeProcess(ProcessEvent $e)
184
+ {
185
+ $this->proxyEvent('command:process', $e);
186
+ }
187
+
188
+ public function afterProcess(ProcessEvent $e)
189
+ {
190
+ $this->proxyEvent('command:process', $e);
191
+ }
192
+
193
+ /**
194
+ * Proxies the appropriate call to start or end event
195
+ *
196
+ * @param string $name Name of the event
197
+ * @param EventInterface $e Event to proxy
198
+ */
199
+ public function proxyEvent($name, EventInterface $e)
200
+ {
201
+ $meth = substr(debug_backtrace()[1]['function'], 0, 6) == 'before'
202
+ ? 'startEvent'
203
+ : 'endEvent';
204
+
205
+ call_user_func_array(
206
+ [$this, $meth],
207
+ [
208
+ $name,
209
+ $this->hashCommand($e->getClient(), $e->getCommand(), $e),
210
+ $e->getCommand(),
211
+ method_exists($e, 'getRequest') ? $e->getRequest() : null,
212
+ method_exists($e, 'getResponse') ? $e->getResponse() : null,
213
+ method_exists($e, 'getResult') ? $e->getResult() : null,
214
+ method_exists($e, 'getException') ? $e->getException() : null
215
+ ]
216
+ );
217
+ }
218
+
219
+ /**
220
+ * Proxies a call to start or end event based on a request event.
221
+ *
222
+ * @param string $meth startEvent or endEvent
223
+ * @param EventInterface $cev Command event
224
+ * @param EventInterface $rev Request event
225
+ */
226
+ private function proxyReqEvent(
227
+ $meth,
228
+ EventInterface $cev,
229
+ EventInterface $rev
230
+ ) {
231
+ call_user_func(
232
+ [$this, $meth],
233
+ $this->getEventName($rev),
234
+ $this->hashCommand($cev->getClient(), $cev->getCommand(), $rev),
235
+ $cev->getCommand(),
236
+ $rev->getRequest(),
237
+ method_exists($rev, 'getResponse') ? $rev->getResponse() : null,
238
+ method_exists($cev, 'getResult') ? $cev->getResult() : null,
239
+ method_exists($cev, 'getError') ? $cev->getError() : null
240
+ );
241
+ }
242
+
243
+ /**
244
+ * Gets the state of an event as a hash.
245
+ *
246
+ * @param array $args Ordered array of arguments passed to an event fn
247
+ *
248
+ * @return array
249
+ */
250
+ private function eventState($args)
251
+ {
252
+ return [
253
+ 'time' => microtime(true),
254
+ 'command' => $this->toArrayState($args[2]),
255
+ 'request' => $this->messageState($args[3]),
256
+ 'response' => $this->messageState($args[4]),
257
+ 'result' => $this->resultState($args[5]),
258
+ 'error' => $this->errorState($args[6])
259
+ ];
260
+ }
261
+
262
+ /**
263
+ * Calculates the event name of a request event.
264
+ *
265
+ * @param EventInterface $event
266
+ *
267
+ * @return string
268
+ */
269
+ private function getEventName(EventInterface $event)
270
+ {
271
+ $cl = get_class($event);
272
+ $name = strtolower(substr($cl, strrpos($cl, '\\') + 1));
273
+ return 'request:' . substr($name, 0, -5);
274
+ }
275
+
276
+ /**
277
+ * Gets the state of a stream as a hash or null.
278
+ *
279
+ * If the size of the stream is below the max threshold and the stream is
280
+ * seekable, then the contents of the stream is included in the hash.
281
+ *
282
+ * @param StreamInterface $stream
283
+ *
284
+ * @return array|null
285
+ */
286
+ private function streamState(StreamInterface $stream = null)
287
+ {
288
+ if (!$stream) {
289
+ return null;
290
+ }
291
+
292
+ $result = [
293
+ 'class' => get_class($stream),
294
+ 'size' => $stream->getSize(),
295
+ 'tell' => $stream->tell()
296
+ ];
297
+
298
+ if ($stream->getSize() < $this->maxStreamSize &&
299
+ $stream->isSeekable()
300
+ ) {
301
+ $pos = $stream->tell();
302
+ $result['contents'] = (string) $stream;
303
+ $stream->seek($pos);
304
+ }
305
+
306
+ return $result;
307
+ }
308
+
309
+ /**
310
+ * Gets the state of a message as a hash.
311
+ *
312
+ * @param MessageInterface $msg
313
+ *
314
+ * @return array|null
315
+ */
316
+ private function messageState(MessageInterface $msg = null)
317
+ {
318
+ return !$msg ? null : [
319
+ 'start-line' => AbstractMessage::getStartLine($msg),
320
+ 'headers' => AbstractMessage::getHeadersAsString($msg),
321
+ 'body' => $this->streamState($msg->getBody())
322
+ ];
323
+ }
324
+
325
+ /**
326
+ * Converts a ToArrayInterface object into a hash with streams mapped as
327
+ * needed to hash states.
328
+ *
329
+ * @param ToArrayInterface $data
330
+ *
331
+ * @return array
332
+ */
333
+ private function toArrayState(ToArrayInterface $data)
334
+ {
335
+ $params = $data->toArray();
336
+ array_walk_recursive($params, function (&$value) {
337
+ if ($value instanceof StreamInterface) {
338
+ $value = $this->streamState($value);
339
+ }
340
+ });
341
+
342
+ $result = [
343
+ 'id' => spl_object_hash($data),
344
+ 'class' => get_class($data),
345
+ 'keys' => $params
346
+ ];
347
+
348
+ if ($data instanceof CommandInterface) {
349
+ $result['name'] = $data->getName();
350
+ }
351
+
352
+ return $result;
353
+ }
354
+
355
+ /**
356
+ * Returns the most appropriate JSON encodable value for a result state.
357
+ *
358
+ * @param null $result
359
+ *
360
+ * @return array|null|string
361
+ */
362
+ private function resultState($result = null)
363
+ {
364
+ if ($result === null) {
365
+ return null;
366
+ } elseif ($result instanceof ToArrayInterface) {
367
+ return $this->toArrayState($result);
368
+ } elseif ($result instanceof StreamInterface) {
369
+ return $this->streamState($result);
370
+ } else {
371
+ return json_encode($result);
372
+ }
373
+ }
374
+
375
+ /**
376
+ * Returns the state of an exception as a hash or null.
377
+ *
378
+ * @param \Exception $e
379
+ *
380
+ * @return array|null
381
+ */
382
+ private function errorState(\Exception $e = null)
383
+ {
384
+ return !$e ? null : [
385
+ 'class' => get_class($e),
386
+ 'message' => $e->getMessage(),
387
+ 'line' => $e->getLine(),
388
+ 'file' => $e->getFile(),
389
+ 'code' => $e->getCode()
390
+ ];
391
+ }
392
+
393
+ /**
394
+ * Provides a diff between two states as a string
395
+ */
396
+ private function diffStates($a, $b)
397
+ {
398
+ if (!$a) {
399
+ return 'State was changed to ' . print_r($b, true);
400
+ }
401
+
402
+ unset($a['time'], $b['time']);
403
+ $diff = $this->diff($a, $b);
404
+
405
+ return $diff ? print_r($diff, true) : 'No change';
406
+ }
407
+
408
+ private function diff($a, $b) {
409
+
410
+ $result = [];
411
+
412
+ // Check differences in previous keys
413
+ foreach ($a as $k => $v) {
414
+ if (!array_key_exists($k, $b)) {
415
+ $result[$k . ' was removed, previously'] = $v;
416
+ } elseif (is_array($v)) {
417
+ if ($diff = $this->diff($v, $b[$k])) {
418
+ $result[$k . ' has a change'] = $diff;
419
+ }
420
+ } elseif ($v !== $b[$k]) {
421
+ $result[$k . ' was changed'] = $b[$k];
422
+ }
423
+ }
424
+
425
+ return $result;
426
+ }
427
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/command/src/Subscriber/ResultMock.php ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command\Subscriber;
3
+
4
+ use GuzzleHttp\Command\Event\PreparedEvent;
5
+ use GuzzleHttp\Event\SubscriberInterface;
6
+
7
+ /**
8
+ * Queues mock results and/or exceptions and delivers them in a FIFO order.
9
+ */
10
+ class ResultMock implements SubscriberInterface, \Countable
11
+ {
12
+ /** @var array Array of mock results and exceptions */
13
+ private $queue = [];
14
+
15
+ /**
16
+ * @param array $results Array of results and exceptions to queue
17
+ */
18
+ public function __construct(array $results = [])
19
+ {
20
+ $this->addMultiple($results);
21
+ }
22
+
23
+ public function getEvents()
24
+ {
25
+ return ['prepare' => ['onPrepared', 'last']];
26
+ }
27
+
28
+ /**
29
+ * @throws \Exception if one has been queued.
30
+ * @throws \OutOfBoundsException if the queue is empty.
31
+ */
32
+ public function onPrepared(PreparedEvent $event)
33
+ {
34
+ if (!$result = array_shift($this->queue)) {
35
+ throw new \OutOfBoundsException('Result mock queue is empty');
36
+ } elseif ($result instanceof \Exception) {
37
+ throw $result;
38
+ } else {
39
+ $event->intercept($result);
40
+ }
41
+ }
42
+
43
+ public function count()
44
+ {
45
+ return count($this->queue);
46
+ }
47
+
48
+ /**
49
+ * Add a result to the end of the queue.
50
+ *
51
+ * @param mixed $result The result of the command.
52
+ *
53
+ * @return self
54
+ */
55
+ public function addResult($result)
56
+ {
57
+ $this->queue[] = $result;
58
+
59
+ return $this;
60
+ }
61
+
62
+ /**
63
+ * Add an exception to the end of the queue.
64
+ *
65
+ * @param \Exception $exception Thrown when executing.
66
+ *
67
+ * @return self
68
+ */
69
+ public function addException(\Exception $exception)
70
+ {
71
+ $this->queue[] = $exception;
72
+
73
+ return $this;
74
+ }
75
+
76
+ /**
77
+ * Add multiple results/exceptions to the queue
78
+ *
79
+ * @param array $results Results to add
80
+ *
81
+ * @return self
82
+ */
83
+ public function addMultiple(array $results)
84
+ {
85
+ foreach ($results as $result) {
86
+ if ($result instanceof \Exception) {
87
+ $this->addException($result);
88
+ } else {
89
+ $this->addResult($result);
90
+ }
91
+ }
92
+
93
+ return $this;
94
+ }
95
+
96
+ /**
97
+ * Clear the queue.
98
+ *
99
+ * @return self
100
+ */
101
+ public function clearQueue()
102
+ {
103
+ $this->queue = [];
104
+
105
+ return $this;
106
+ }
107
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/.gitignore ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ .idea
2
+ .DS_STORE
3
+ phpunit.xml
4
+ composer.lock
5
+ vendor/
6
+ artifacts/
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/.travis.yml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ language: php
2
+
3
+ php:
4
+ - 5.4
5
+ - 5.5
6
+ - 5.6
7
+ - hhvm
8
+
9
+ before_script:
10
+ - composer self-update
11
+ - composer install --no-interaction --prefer-source --dev
12
+
13
+ script: make test
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/LICENSE ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright (c) 2014 Michael Dowling, https://github.com/mtdowling <mtdowling@gmail.com>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/Makefile ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ all: clean test
2
+
3
+ test:
4
+ vendor/bin/phpunit
5
+
6
+ coverage:
7
+ vendor/bin/phpunit --coverage-html=artifacts/coverage
8
+
9
+ view-coverage:
10
+ open artifacts/coverage/index.html
11
+
12
+ clean:
13
+ rm -rf artifacts/*
14
+
15
+ .PHONY: coverage
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/README.rst ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ===============
2
+ Guzzle Services
3
+ ===============
4
+
5
+ Provides an implementation of the Guzzle Command library that uses Guzzle service descriptions to describe web services, serialize requests, and parse responses into easy to use model structures.
6
+
7
+ .. code-block:: php
8
+
9
+ use GuzzleHttp\Client;
10
+ use GuzzleHttp\Command\Guzzle\GuzzleClient;
11
+ use GuzzleHttp\Command\Guzzle\Description;
12
+
13
+ $client = new Client();
14
+ $description = new Description([
15
+ 'baseUrl' => 'http://httpbin.org/',
16
+ 'operations' => [
17
+ 'testing' => [
18
+ 'httpMethod' => 'GET',
19
+ 'uri' => '/get/{foo}',
20
+ 'responseModel' => 'getResponse',
21
+ 'parameters' => [
22
+ 'foo' => [
23
+ 'type' => 'string',
24
+ 'location' => 'uri'
25
+ ],
26
+ 'bar' => [
27
+ 'type' => 'string',
28
+ 'location' => 'query'
29
+ ]
30
+ ]
31
+ ]
32
+ ],
33
+ 'models' => [
34
+ 'getResponse' => [
35
+ 'type' => 'object',
36
+ 'additionalProperties' => [
37
+ 'location' => 'json'
38
+ ]
39
+ ]
40
+ ]
41
+ ]);
42
+
43
+ $guzzleClient = new GuzzleClient($client, $description);
44
+
45
+ $result = $guzzleClient->testing(['foo' => 'bar']);
46
+ echo $result['args']['foo'];
47
+ // bar
48
+
49
+ Installing
50
+ ==========
51
+
52
+ This project can be installed using Composer. Add the following to your
53
+ composer.json:
54
+
55
+ .. code-block:: javascript
56
+
57
+ {
58
+ "require": {
59
+ "guzzlehttp/guzzle-services": "0.4.*"
60
+ }
61
+ }
62
+
63
+ More documentation coming soon.
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/composer.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "guzzlehttp/guzzle-services",
3
+ "description": "Provides an implementation of the Guzzle Command library that uses Guzzle service descriptions to describe web services, serialize requests, and parse responses into easy to use model structures.",
4
+ "type": "library",
5
+ "license": "MIT",
6
+ "authors": [
7
+ {
8
+ "name": "Michael Dowling",
9
+ "email": "mtdowling@gmail.com",
10
+ "homepage": "https://github.com/mtdowling"
11
+ }
12
+ ],
13
+ "require": {
14
+ "php": ">=5.4.0",
15
+ "guzzlehttp/command": "0.7.*"
16
+ },
17
+ "require-dev": {
18
+ "phpunit/phpunit": "~4.0"
19
+ },
20
+ "autoload": {
21
+ "psr-4": {
22
+ "GuzzleHttp\\Command\\Guzzle\\": "src/"
23
+ }
24
+ },
25
+ "autoload-dev": {
26
+ "psr-4": {
27
+ "GuzzleHttp\\Tests\\Command\\Guzzle\\": "tests/"
28
+ }
29
+ },
30
+ "extra": {
31
+ "branch-alias": {
32
+ "dev-master": "0.4-dev"
33
+ }
34
+ }
35
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/phpunit.xml.dist ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <phpunit bootstrap="./vendor/autoload.php"
3
+ colors="true">
4
+ <testsuites>
5
+ <testsuite>
6
+ <directory>tests</directory>
7
+ </testsuite>
8
+ </testsuites>
9
+ <filter>
10
+ <whitelist>
11
+ <directory suffix=".php">src</directory>
12
+ </whitelist>
13
+ </filter>
14
+ </phpunit>
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/Description.php ADDED
@@ -0,0 +1,261 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command\Guzzle;
3
+
4
+ use GuzzleHttp\Url;
5
+
6
+ /**
7
+ * Represents a Guzzle service description
8
+ */
9
+ class Description implements DescriptionInterface
10
+ {
11
+ /** @var array Array of {@see OperationInterface} objects */
12
+ private $operations = [];
13
+
14
+ /** @var array Array of API models */
15
+ private $models = [];
16
+
17
+ /** @var string Name of the API */
18
+ private $name;
19
+
20
+ /** @var string API version */
21
+ private $apiVersion;
22
+
23
+ /** @var string Summary of the API */
24
+ private $description;
25
+
26
+ /** @var array Any extra API data */
27
+ private $extraData = [];
28
+
29
+ /** @var string baseUrl/basePath */
30
+ private $baseUrl;
31
+
32
+ /** @var SchemaFormatter */
33
+ private $formatter;
34
+
35
+ /**
36
+ * @param array $config Service description data
37
+ * @param array $options Custom options to apply to the description
38
+ * - formatter: Can provide a custom SchemaFormatter class
39
+ *
40
+ * @throws \InvalidArgumentException
41
+ */
42
+ public function __construct(array $config, array $options = [])
43
+ {
44
+ // Keep a list of default keys used in service descriptions that is
45
+ // later used to determine extra data keys.
46
+ static $defaultKeys = ['name', 'models', 'apiVersion', 'description'];
47
+
48
+ // Pull in the default configuration values
49
+ foreach ($defaultKeys as $key) {
50
+ if (isset($config[$key])) {
51
+ $this->{$key} = $config[$key];
52
+ }
53
+ }
54
+
55
+ // Set the baseUrl
56
+ $this->baseUrl = Url::fromString(isset($config['baseUrl']) ? $config['baseUrl'] : '');
57
+
58
+ // Ensure that the models and operations properties are always arrays
59
+ $this->models = (array) $this->models;
60
+ $this->operations = (array) $this->operations;
61
+
62
+ // We want to add operations differently than adding the other properties
63
+ $defaultKeys[] = 'operations';
64
+
65
+ // Create operations for each operation
66
+ if (isset($config['operations'])) {
67
+ foreach ($config['operations'] as $name => $operation) {
68
+ if (!is_array($operation)) {
69
+ throw new \InvalidArgumentException('Operations must be arrays');
70
+ }
71
+ $this->operations[$name] = $operation;
72
+ }
73
+ }
74
+
75
+ // Get all of the additional properties of the service description and
76
+ // store them in a data array
77
+ foreach (array_diff(array_keys($config), $defaultKeys) as $key) {
78
+ $this->extraData[$key] = $config[$key];
79
+ }
80
+
81
+ // Configure the schema formatter
82
+ if (isset($options['formatter'])) {
83
+ $this->formatter = $options['formatter'];
84
+ } else {
85
+ static $defaultFormatter;
86
+ if (!$defaultFormatter) {
87
+ $defaultFormatter = new SchemaFormatter();
88
+ }
89
+ $this->formatter = $defaultFormatter;
90
+ }
91
+ }
92
+
93
+ /**
94
+ * Get the basePath/baseUrl of the description
95
+ *
96
+ * @return Url
97
+ */
98
+ public function getBaseUrl()
99
+ {
100
+ return $this->baseUrl;
101
+ }
102
+
103
+ /**
104
+ * Get the API operations of the service
105
+ *
106
+ * @return Operation[] Returns an array of {@see Operation} objects
107
+ */
108
+ public function getOperations()
109
+ {
110
+ return $this->operations;
111
+ }
112
+
113
+ /**
114
+ * Check if the service has an operation by name
115
+ *
116
+ * @param string $name Name of the operation to check
117
+ *
118
+ * @return bool
119
+ */
120
+ public function hasOperation($name)
121
+ {
122
+ return isset($this->operations[$name]);
123
+ }
124
+
125
+ /**
126
+ * Get an API operation by name
127
+ *
128
+ * @param string $name Name of the command
129
+ *
130
+ * @return Operation
131
+ * @throws \InvalidArgumentException if the operation is not found
132
+ */
133
+ public function getOperation($name)
134
+ {
135
+ if (!$this->hasOperation($name)) {
136
+ throw new \InvalidArgumentException("No operation found named $name");
137
+ }
138
+
139
+ // Lazily create operations as they are retrieved
140
+ if (!($this->operations[$name] instanceof Operation)) {
141
+ $this->operations[$name]['name'] = $name;
142
+ $this->operations[$name] = new Operation($this->operations[$name], $this);
143
+ }
144
+
145
+ return $this->operations[$name];
146
+ }
147
+
148
+ /**
149
+ * Get a shared definition structure.
150
+ *
151
+ * @param string $id ID/name of the model to retrieve
152
+ *
153
+ * @return Parameter
154
+ * @throws \InvalidArgumentException if the model is not found
155
+ */
156
+ public function getModel($id)
157
+ {
158
+ if (!$this->hasModel($id)) {
159
+ throw new \InvalidArgumentException("No model found named $id");
160
+ }
161
+
162
+ // Lazily create models as they are retrieved
163
+ if (!($this->models[$id] instanceof Parameter)) {
164
+ $this->models[$id] = new Parameter(
165
+ $this->models[$id],
166
+ ['description' => $this]
167
+ );
168
+ }
169
+
170
+ return $this->models[$id];
171
+ }
172
+
173
+ /**
174
+ * Get all models of the service description.
175
+ *
176
+ * @return array
177
+ */
178
+ public function getModels()
179
+ {
180
+ $models = [];
181
+ foreach ($this->models as $name => $model) {
182
+ $models[$name] = $this->getModel($name);
183
+ }
184
+
185
+ return $models;
186
+ }
187
+
188
+ /**
189
+ * Check if the service description has a model by name.
190
+ *
191
+ * @param string $id Name/ID of the model to check
192
+ *
193
+ * @return bool
194
+ */
195
+ public function hasModel($id)
196
+ {
197
+ return isset($this->models[$id]);
198
+ }
199
+
200
+ /**
201
+ * Get the API version of the service
202
+ *
203
+ * @return string
204
+ */
205
+ public function getApiVersion()
206
+ {
207
+ return $this->apiVersion;
208
+ }
209
+
210
+ /**
211
+ * Get the name of the API
212
+ *
213
+ * @return string
214
+ */
215
+ public function getName()
216
+ {
217
+ return $this->name;
218
+ }
219
+
220
+ /**
221
+ * Get a summary of the purpose of the API
222
+ *
223
+ * @return string
224
+ */
225
+ public function getDescription()
226
+ {
227
+ return $this->description;
228
+ }
229
+
230
+ /**
231
+ * Format a parameter using named formats.
232
+ *
233
+ * @param string $format Format to convert it to
234
+ * @param mixed $input Input string
235
+ *
236
+ * @return mixed
237
+ */
238
+ public function format($format, $input)
239
+ {
240
+ return $this->formatter->format($format, $input);
241
+ }
242
+
243
+ /**
244
+ * Get arbitrary data from the service description that is not part of the
245
+ * Guzzle service description specification.
246
+ *
247
+ * @param string $key Data key to retrieve or null to retrieve all extra
248
+ *
249
+ * @return null|mixed
250
+ */
251
+ public function getData($key = null)
252
+ {
253
+ if ($key === null) {
254
+ return $this->extraData;
255
+ } elseif (isset($this->extraData[$key])) {
256
+ return $this->extraData[$key];
257
+ } else {
258
+ return null;
259
+ }
260
+ }
261
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/DescriptionInterface.php ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command\Guzzle;
3
+
4
+ use GuzzleHttp\Url;
5
+
6
+ interface DescriptionInterface
7
+ {
8
+ /**
9
+ * Get the basePath/baseUrl of the description
10
+ *
11
+ * @return Url
12
+ */
13
+ public function getBaseUrl();
14
+
15
+ /**
16
+ * Get the API operations of the service
17
+ *
18
+ * @return Operation[] Returns an array of {@see Operation} objects
19
+ */
20
+ public function getOperations();
21
+
22
+ /**
23
+ * Check if the service has an operation by name
24
+ *
25
+ * @param string $name Name of the operation to check
26
+ *
27
+ * @return bool
28
+ */
29
+ public function hasOperation($name);
30
+
31
+ /**
32
+ * Get an API operation by name
33
+ *
34
+ * @param string $name Name of the command
35
+ *
36
+ * @return Operation
37
+ * @throws \InvalidArgumentException if the operation is not found
38
+ */
39
+ public function getOperation($name);
40
+
41
+ /**
42
+ * Get a shared definition structure.
43
+ *
44
+ * @param string $id ID/name of the model to retrieve
45
+ *
46
+ * @return Parameter
47
+ * @throws \InvalidArgumentException if the model is not found
48
+ */
49
+ public function getModel($id);
50
+
51
+ /**
52
+ * Get all models of the service description.
53
+ *
54
+ * @return array
55
+ */
56
+ public function getModels();
57
+
58
+ /**
59
+ * Check if the service description has a model by name.
60
+ *
61
+ * @param string $id Name/ID of the model to check
62
+ *
63
+ * @return bool
64
+ */
65
+ public function hasModel($id);
66
+
67
+ /**
68
+ * Get the API version of the service
69
+ *
70
+ * @return string
71
+ */
72
+ public function getApiVersion();
73
+
74
+ /**
75
+ * Get the name of the API
76
+ *
77
+ * @return string
78
+ */
79
+ public function getName();
80
+
81
+ /**
82
+ * Get a summary of the purpose of the API
83
+ *
84
+ * @return string
85
+ */
86
+ public function getDescription();
87
+
88
+ /**
89
+ * Format a parameter using named formats.
90
+ *
91
+ * @param string $format Format to convert it to
92
+ * @param mixed $input Input string
93
+ *
94
+ * @return mixed
95
+ */
96
+ public function format($format, $input);
97
+
98
+ /**
99
+ * Get arbitrary data from the service description that is not part of the
100
+ * Guzzle service description specification.
101
+ *
102
+ * @param string $key Data key to retrieve or null to retrieve all extra
103
+ *
104
+ * @return null|mixed
105
+ */
106
+ public function getData($key = null);
107
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/GuzzleClient.php ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command\Guzzle;
3
+
4
+ use GuzzleHttp\ClientInterface;
5
+ use GuzzleHttp\Command\AbstractClient;
6
+ use GuzzleHttp\Command\Command;
7
+ use GuzzleHttp\Command\CommandTransaction;
8
+ use GuzzleHttp\Command\Guzzle\Subscriber\ProcessResponse;
9
+ use GuzzleHttp\Command\Guzzle\Subscriber\ValidateInput;
10
+ use GuzzleHttp\Event\HasEmitterTrait;
11
+ use GuzzleHttp\Command\ServiceClientInterface;
12
+ use GuzzleHttp\Ring\Future\FutureArray;
13
+
14
+ /**
15
+ * Default Guzzle web service client implementation.
16
+ */
17
+ class GuzzleClient extends AbstractClient
18
+ {
19
+ /** @var Description Guzzle service description */
20
+ private $description;
21
+
22
+ /** @var callable Factory used for creating commands */
23
+ private $commandFactory;
24
+
25
+ /** @var callable Serializer */
26
+ private $serializer;
27
+
28
+ /**
29
+ * The client constructor accepts an associative array of configuration
30
+ * options:
31
+ *
32
+ * - defaults: Associative array of default command parameters to add to
33
+ * each command created by the client.
34
+ * - validate: Specify if command input is validated (defaults to true).
35
+ * Changing this setting after the client has been created will have no
36
+ * effect.
37
+ * - process: Specify if HTTP responses are parsed (defaults to true).
38
+ * Changing this setting after the client has been created will have no
39
+ * effect.
40
+ * - response_locations: Associative array of location types mapping to
41
+ * ResponseLocationInterface objects.
42
+ * - serializer: Optional callable that accepts a CommandTransactions and
43
+ * returns a serialized request object.
44
+ *
45
+ * @param ClientInterface $client HTTP client to use.
46
+ * @param DescriptionInterface $description Guzzle service description
47
+ * @param array $config Configuration options
48
+ */
49
+ public function __construct(
50
+ ClientInterface $client,
51
+ DescriptionInterface $description,
52
+ array $config = []
53
+ ) {
54
+ parent::__construct($client, $config);
55
+ $this->description = $description;
56
+ $this->processConfig($config);
57
+ }
58
+
59
+ public function getCommand($name, array $args = [])
60
+ {
61
+ $factory = $this->commandFactory;
62
+
63
+ // Determine if a future array should be returned.
64
+ if (!empty($args['@future'])) {
65
+ $future = !empty($args['@future']);
66
+ unset($args['@future']);
67
+ } else {
68
+ $future = false;
69
+ }
70
+
71
+ // Merge in default command options
72
+ $args += $this->getConfig('defaults');
73
+
74
+ if ($command = $factory($name, $args, $this)) {
75
+ $command->setFuture($future);
76
+ return $command;
77
+ }
78
+
79
+ throw new \InvalidArgumentException("No operation found named $name");
80
+ }
81
+
82
+ public function getDescription()
83
+ {
84
+ return $this->description;
85
+ }
86
+
87
+ protected function createFutureResult(CommandTransaction $transaction)
88
+ {
89
+ return new FutureArray(
90
+ $transaction->response->then(function () use ($transaction) {
91
+ return $transaction->result;
92
+ }),
93
+ [$transaction->response, 'wait'],
94
+ [$transaction->response, 'cancel']
95
+ );
96
+ }
97
+
98
+ protected function serializeRequest(CommandTransaction $trans)
99
+ {
100
+ $fn = $this->serializer;
101
+ return $fn($trans);
102
+ }
103
+
104
+ /**
105
+ * Creates a callable function used to create command objects from a
106
+ * service description.
107
+ *
108
+ * @param DescriptionInterface $description Service description
109
+ *
110
+ * @return callable Returns a command factory
111
+ */
112
+ public static function defaultCommandFactory(DescriptionInterface $description)
113
+ {
114
+ return function (
115
+ $name,
116
+ array $args = [],
117
+ ServiceClientInterface $client
118
+ ) use ($description) {
119
+ $operation = null;
120
+
121
+ if ($description->hasOperation($name)) {
122
+ $operation = $description->getOperation($name);
123
+ } else {
124
+ $name = ucfirst($name);
125
+ if ($description->hasOperation($name)) {
126
+ $operation = $description->getOperation($name);
127
+ }
128
+ }
129
+
130
+ if (!$operation) {
131
+ return null;
132
+ }
133
+
134
+ return new Command($name, $args, ['emitter' => clone $client->getEmitter()]);
135
+ };
136
+ }
137
+
138
+ /**
139
+ * Prepares the client based on the configuration settings of the client.
140
+ *
141
+ * @param array $config Constructor config as an array
142
+ */
143
+ protected function processConfig(array $config)
144
+ {
145
+ // Use the passed in command factory or a custom factory if provided
146
+ $this->commandFactory = isset($config['command_factory'])
147
+ ? $config['command_factory']
148
+ : self::defaultCommandFactory($this->description);
149
+
150
+ // Add event listeners based on the configuration option
151
+ $emitter = $this->getEmitter();
152
+
153
+ if (!isset($config['validate']) ||
154
+ $config['validate'] === true
155
+ ) {
156
+ $emitter->attach(new ValidateInput($this->description));
157
+ }
158
+
159
+ $this->serializer = isset($config['serializer'])
160
+ ? $config['serializer']
161
+ : new Serializer($this->description);
162
+
163
+ if (!isset($config['process']) ||
164
+ $config['process'] === true
165
+ ) {
166
+ $emitter->attach(
167
+ new ProcessResponse(
168
+ $this->description,
169
+ isset($config['response_locations'])
170
+ ? $config['response_locations']
171
+ : []
172
+ )
173
+ );
174
+ }
175
+ }
176
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/Operation.php ADDED
@@ -0,0 +1,299 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command\Guzzle;
3
+
4
+ use GuzzleHttp\ToArrayInterface;
5
+
6
+ /**
7
+ * Guzzle operation
8
+ */
9
+ class Operation implements ToArrayInterface
10
+ {
11
+ /** @var array Parameters */
12
+ private $parameters = [];
13
+
14
+ /** @var Parameter Additional parameters schema */
15
+ private $additionalParameters;
16
+
17
+ /** @var Description */
18
+ private $description;
19
+
20
+ /** @var array Config data */
21
+ private $config;
22
+
23
+ /**
24
+ * Builds an Operation object using an array of configuration data.
25
+ *
26
+ * - name: (string) Name of the command
27
+ * - httpMethod: (string) HTTP method of the operation
28
+ * - uri: (string) URI template that can create a relative or absolute URL
29
+ * - parameters: (array) Associative array of parameters for the command.
30
+ * Each value must be an array that is used to create {@see Parameter}
31
+ * objects.
32
+ * - summary: (string) This is a short summary of what the operation does
33
+ * - notes: (string) A longer description of the operation.
34
+ * - documentationUrl: (string) Reference URL providing more information
35
+ * about the operation.
36
+ * - responseModel: (string) The model name used for processing response.
37
+ * - deprecated: (bool) Set to true if this is a deprecated command
38
+ * - errorResponses: (array) Errors that could occur when executing the
39
+ * command. Array of hashes, each with a 'code' (the HTTP response code),
40
+ * 'phrase' (response reason phrase or description of the error), and
41
+ * 'class' (a custom exception class that would be thrown if the error is
42
+ * encountered).
43
+ * - data: (array) Any extra data that might be used to help build or
44
+ * serialize the operation
45
+ * - additionalParameters: (null|array) Parameter schema to use when an
46
+ * option is passed to the operation that is not in the schema
47
+ *
48
+ * @param array $config Array of configuration data
49
+ * @param DescriptionInterface $description Service description used to resolve models if $ref tags are found
50
+ * @throws \InvalidArgumentException
51
+ */
52
+ public function __construct(array $config = [], DescriptionInterface $description)
53
+ {
54
+ static $defaults = [
55
+ 'name' => '',
56
+ 'httpMethod' => '',
57
+ 'uri' => '',
58
+ 'responseModel' => null,
59
+ 'notes' => '',
60
+ 'summary' => '',
61
+ 'documentationUrl' => null,
62
+ 'deprecated' => false,
63
+ 'data' => [],
64
+ 'parameters' => [],
65
+ 'additionalParameters' => null,
66
+ 'errorResponses' => []
67
+ ];
68
+
69
+ $this->description = $description;
70
+
71
+ if (isset($config['extends'])) {
72
+ $config = $this->resolveExtends($config['extends'], $config);
73
+ }
74
+
75
+ $this->config = $config + $defaults;
76
+
77
+ // Account for the old style of using responseClass
78
+ if (isset($config['responseClass'])) {
79
+ $this->config['responseModel'] = $config['responseClass'];
80
+ }
81
+
82
+ $this->resolveParameters();
83
+ }
84
+
85
+ public function toArray()
86
+ {
87
+ return $this->config;
88
+ }
89
+
90
+ /**
91
+ * Get the service description that the operation belongs to
92
+ *
93
+ * @return Description
94
+ */
95
+ public function getServiceDescription()
96
+ {
97
+ return $this->description;
98
+ }
99
+
100
+ /**
101
+ * Get the params of the operation
102
+ *
103
+ * @return Parameter[]
104
+ */
105
+ public function getParams()
106
+ {
107
+ return $this->parameters;
108
+ }
109
+
110
+ /**
111
+ * Get additionalParameters of the operation
112
+ *
113
+ * @return Parameter|null
114
+ */
115
+ public function getAdditionalParameters()
116
+ {
117
+ return $this->additionalParameters;
118
+ }
119
+
120
+ /**
121
+ * Check if the operation has a specific parameter by name
122
+ *
123
+ * @param string $name Name of the param
124
+ *
125
+ * @return bool
126
+ */
127
+ public function hasParam($name)
128
+ {
129
+ return isset($this->parameters[$name]);
130
+ }
131
+
132
+ /**
133
+ * Get a single parameter of the operation
134
+ *
135
+ * @param string $name Parameter to retrieve by name
136
+ *
137
+ * @return Parameter|null
138
+ */
139
+ public function getParam($name)
140
+ {
141
+ return isset($this->parameters[$name])
142
+ ? $this->parameters[$name]
143
+ : null;
144
+ }
145
+
146
+ /**
147
+ * Get the HTTP method of the operation
148
+ *
149
+ * @return string|null
150
+ */
151
+ public function getHttpMethod()
152
+ {
153
+ return $this->config['httpMethod'];
154
+ }
155
+
156
+ /**
157
+ * Get the name of the operation
158
+ *
159
+ * @return string|null
160
+ */
161
+ public function getName()
162
+ {
163
+ return $this->config['name'];
164
+ }
165
+
166
+ /**
167
+ * Get a short summary of what the operation does
168
+ *
169
+ * @return string|null
170
+ */
171
+ public function getSummary()
172
+ {
173
+ return $this->config['summary'];
174
+ }
175
+
176
+ /**
177
+ * Get a longer text field to explain the behavior of the operation
178
+ *
179
+ * @return string|null
180
+ */
181
+ public function getNotes()
182
+ {
183
+ return $this->config['notes'];
184
+ }
185
+
186
+ /**
187
+ * Get the documentation URL of the operation
188
+ *
189
+ * @return string|null
190
+ */
191
+ public function getDocumentationUrl()
192
+ {
193
+ return $this->config['documentationUrl'];
194
+ }
195
+
196
+ /**
197
+ * Get the name of the model used for processing the response.
198
+ *
199
+ * @return string
200
+ */
201
+ public function getResponseModel()
202
+ {
203
+ return $this->config['responseModel'];
204
+ }
205
+
206
+ /**
207
+ * Get whether or not the operation is deprecated
208
+ *
209
+ * @return bool
210
+ */
211
+ public function getDeprecated()
212
+ {
213
+ return $this->config['deprecated'];
214
+ }
215
+
216
+ /**
217
+ * Get the URI that will be merged into the generated request
218
+ *
219
+ * @return string
220
+ */
221
+ public function getUri()
222
+ {
223
+ return $this->config['uri'];
224
+ }
225
+
226
+ /**
227
+ * Get the errors that could be encountered when executing the operation
228
+ *
229
+ * @return array
230
+ */
231
+ public function getErrorResponses()
232
+ {
233
+ return $this->config['errorResponses'];
234
+ }
235
+
236
+ /**
237
+ * Get extra data from the operation
238
+ *
239
+ * @param string $name Name of the data point to retrieve or null to
240
+ * retrieve all of the extra data.
241
+ *
242
+ * @return mixed|null
243
+ */
244
+ public function getData($name = null)
245
+ {
246
+ if ($name === null) {
247
+ return $this->config['data'];
248
+ } elseif (isset($this->config['data'][$name])) {
249
+ return $this->config['data'][$name];
250
+ } else {
251
+ return null;
252
+ }
253
+ }
254
+
255
+ private function resolveExtends($name, array $config)
256
+ {
257
+ if (!$this->description->hasOperation($name)) {
258
+ throw new \InvalidArgumentException('No operation named ' . $name);
259
+ }
260
+
261
+ // Merge parameters together one level deep
262
+ $base = $this->description->getOperation($name)->toArray();
263
+ $result = $config + $base;
264
+
265
+ if (isset($base['parameters']) && isset($config['parameters'])) {
266
+ $result['parameters'] = $config['parameters'] + $base['parameters'];
267
+ }
268
+
269
+ return $result;
270
+ }
271
+
272
+ private function resolveParameters()
273
+ {
274
+ // Parameters need special handling when adding
275
+ foreach ($this->config['parameters'] as $name => $param) {
276
+ if (!is_array($param)) {
277
+ throw new \InvalidArgumentException(
278
+ 'Parameters must be arrays'
279
+ );
280
+ }
281
+ $param['name'] = $name;
282
+ $this->parameters[$name] = new Parameter(
283
+ $param,
284
+ ['description' => $this->description]
285
+ );
286
+ }
287
+
288
+ if ($this->config['additionalParameters']) {
289
+ if (is_array($this->config['additionalParameters'])) {
290
+ $this->additionalParameters = new Parameter(
291
+ $this->config['additionalParameters'],
292
+ ['description' => $this->description]
293
+ );
294
+ } else {
295
+ $this->additionalParameters = $this->config['additionalParameters'];
296
+ }
297
+ }
298
+ }
299
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/Parameter.php ADDED
@@ -0,0 +1,596 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command\Guzzle;
3
+
4
+ use GuzzleHttp\ToArrayInterface;
5
+
6
+ /**
7
+ * API parameter object used with service descriptions
8
+ */
9
+ class Parameter implements ToArrayInterface
10
+ {
11
+ private $originalData;
12
+ private $name;
13
+ private $description;
14
+ private $type;
15
+ private $required;
16
+ private $enum;
17
+ private $pattern;
18
+ private $minimum;
19
+ private $maximum;
20
+ private $minLength;
21
+ private $maxLength;
22
+ private $minItems;
23
+ private $maxItems;
24
+ private $default;
25
+ private $static;
26
+ private $filters;
27
+ private $location;
28
+ private $sentAs;
29
+ private $data;
30
+ private $properties = [];
31
+ private $additionalProperties;
32
+ private $items;
33
+ private $format;
34
+ private $propertiesCache = null;
35
+
36
+ /** @var Description */
37
+ private $serviceDescription;
38
+
39
+ /**
40
+ * Create a new Parameter using an associative array of data.
41
+ *
42
+ * The array can contain the following information:
43
+ *
44
+ * - name: (string) Unique name of the parameter
45
+ *
46
+ * - type: (string|array) Type of variable (string, number, integer,
47
+ * boolean, object, array, numeric, null, any). Types are using for
48
+ * validation and determining the structure of a parameter. You can use a
49
+ * union type by providing an array of simple types. If one of the union
50
+ * types matches the provided value, then the value is valid.
51
+ *
52
+ * - required: (bool) Whether or not the parameter is required
53
+ *
54
+ * - default: (mixed) Default value to use if no value is supplied
55
+ *
56
+ * - static: (bool) Set to true to specify that the parameter value cannot
57
+ * be changed from the default.
58
+ *
59
+ * - description: (string) Documentation of the parameter
60
+ *
61
+ * - location: (string) The location of a request used to apply a parameter.
62
+ * Custom locations can be registered with a command, but the defaults
63
+ * are uri, query, header, body, json, xml, postField, postFile.
64
+ *
65
+ * - sentAs: (string) Specifies how the data being modeled is sent over the
66
+ * wire. For example, you may wish to include certain headers in a
67
+ * response model that have a normalized casing of FooBar, but the actual
68
+ * header is x-foo-bar. In this case, sentAs would be set to x-foo-bar.
69
+ *
70
+ * - filters: (array) Array of static method names to to run a parameter
71
+ * value through. Each value in the array must be a string containing the
72
+ * full class path to a static method or an array of complex filter
73
+ * information. You can specify static methods of classes using the full
74
+ * namespace class name followed by '::' (e.g. Foo\Bar::baz). Some
75
+ * filters require arguments in order to properly filter a value. For
76
+ * complex filters, use a hash containing a 'method' key pointing to a
77
+ * static method, and an 'args' key containing an array of positional
78
+ * arguments to pass to the method. Arguments can contain keywords that
79
+ * are replaced when filtering a value: '@value' is replaced with the
80
+ * value being validated, '@api' is replaced with the Parameter object.
81
+ *
82
+ * - properties: When the type is an object, you can specify nested parameters
83
+ *
84
+ * - additionalProperties: (array) This attribute defines a schema for all
85
+ * properties that are not explicitly defined in an object type
86
+ * definition. If specified, the value MUST be a schema or a boolean. If
87
+ * false is provided, no additional properties are allowed beyond the
88
+ * properties defined in the schema. The default value is an empty schema
89
+ * which allows any value for additional properties.
90
+ *
91
+ * - items: This attribute defines the allowed items in an instance array,
92
+ * and MUST be a schema or an array of schemas. The default value is an
93
+ * empty schema which allows any value for items in the instance array.
94
+ * When this attribute value is a schema and the instance value is an
95
+ * array, then all the items in the array MUST be valid according to the
96
+ * schema.
97
+ *
98
+ * - pattern: When the type is a string, you can specify the regex pattern
99
+ * that a value must match
100
+ *
101
+ * - enum: When the type is a string, you can specify a list of acceptable
102
+ * values.
103
+ *
104
+ * - minItems: (int) Minimum number of items allowed in an array
105
+ *
106
+ * - maxItems: (int) Maximum number of items allowed in an array
107
+ *
108
+ * - minLength: (int) Minimum length of a string
109
+ *
110
+ * - maxLength: (int) Maximum length of a string
111
+ *
112
+ * - minimum: (int) Minimum value of an integer
113
+ *
114
+ * - maximum: (int) Maximum value of an integer
115
+ *
116
+ * - data: (array) Any additional custom data to use when serializing,
117
+ * validating, etc
118
+ *
119
+ * - format: (string) Format used to coax a value into the correct format
120
+ * when serializing or unserializing. You may specify either an array of
121
+ * filters OR a format, but not both. Supported values: date-time, date,
122
+ * time, timestamp, date-time-http, and boolean-string.
123
+ *
124
+ * - $ref: (string) String referencing a service description model. The
125
+ * parameter is replaced by the schema contained in the model.
126
+ *
127
+ * @param array $data Array of data as seen in service descriptions
128
+ * @param array $options Options used when creating the parameter. You can
129
+ * specify a Guzzle service description in the 'description' key.
130
+ *
131
+ * @throws \InvalidArgumentException
132
+ */
133
+ public function __construct(array $data = [], array $options = [])
134
+ {
135
+ $this->originalData = $data;
136
+
137
+ if (isset($options['description'])) {
138
+ $this->serviceDescription = $options['description'];
139
+ if (!($this->serviceDescription instanceof DescriptionInterface)) {
140
+ throw new \InvalidArgumentException('description must be a Description');
141
+ }
142
+ if (isset($data['$ref'])) {
143
+ if ($model = $this->serviceDescription->getModel($data['$ref'])) {
144
+ $name = isset($data['name']) ? $data['name'] : null;
145
+ $data = $model->toArray() + $data;
146
+ if ($name) {
147
+ $data['name'] = $name;
148
+ }
149
+ }
150
+ } elseif (isset($data['extends'])) {
151
+ // If this parameter extends from another parameter then start
152
+ // with the actual data union in the parent's data (e.g. actual
153
+ // supersedes parent)
154
+ if ($extends = $this->serviceDescription->getModel($data['extends'])) {
155
+ $data += $extends->toArray();
156
+ }
157
+ }
158
+ }
159
+
160
+ // Pull configuration data into the parameter
161
+ foreach ($data as $key => $value) {
162
+ $this->{$key} = $value;
163
+ }
164
+
165
+ $this->required = (bool) $this->required;
166
+ $this->data = (array) $this->data;
167
+
168
+ if ($this->filters) {
169
+ $this->setFilters((array) $this->filters);
170
+ }
171
+
172
+ if ($this->type == 'object' && $this->additionalProperties === null) {
173
+ $this->additionalProperties = true;
174
+ }
175
+ }
176
+
177
+ /**
178
+ * Convert the object to an array
179
+ *
180
+ * @return array
181
+ */
182
+ public function toArray()
183
+ {
184
+ return $this->originalData;
185
+ }
186
+
187
+ /**
188
+ * Get the default or static value of the command based on a value
189
+ *
190
+ * @param string $value Value that is currently set
191
+ *
192
+ * @return mixed Returns the value, a static value if one is present, or a default value
193
+ */
194
+ public function getValue($value)
195
+ {
196
+ if ($this->static || ($this->default !== null && $value === null)) {
197
+ return $this->default;
198
+ }
199
+
200
+ return $value;
201
+ }
202
+
203
+ /**
204
+ * Run a value through the filters OR format attribute associated with the
205
+ * parameter.
206
+ *
207
+ * @param mixed $value Value to filter
208
+ *
209
+ * @return mixed Returns the filtered value
210
+ * @throws \RuntimeException when trying to format when no service
211
+ * description is available.
212
+ */
213
+ public function filter($value)
214
+ {
215
+ // Formats are applied exclusively and supersed filters
216
+ if ($this->format) {
217
+ if (!$this->serviceDescription) {
218
+ throw new \RuntimeException('No service description was set so '
219
+ . 'the value cannot be formatted.');
220
+ }
221
+ return $this->serviceDescription->format($this->format, $value);
222
+ }
223
+
224
+ // Convert Boolean values
225
+ if ($this->type == 'boolean' && !is_bool($value)) {
226
+ $value = filter_var($value, FILTER_VALIDATE_BOOLEAN);
227
+ }
228
+
229
+ // Apply filters to the value
230
+ if ($this->filters) {
231
+ foreach ($this->filters as $filter) {
232
+ if (is_array($filter)) {
233
+ // Convert complex filters that hold value place holders
234
+ foreach ($filter['args'] as &$data) {
235
+ if ($data == '@value') {
236
+ $data = $value;
237
+ } elseif ($data == '@api') {
238
+ $data = $this;
239
+ }
240
+ }
241
+ $value = call_user_func_array(
242
+ $filter['method'],
243
+ $filter['args']
244
+ );
245
+ } else {
246
+ $value = call_user_func($filter, $value);
247
+ }
248
+ }
249
+ }
250
+
251
+ return $value;
252
+ }
253
+
254
+ /**
255
+ * Get the name of the parameter
256
+ *
257
+ * @return string
258
+ */
259
+ public function getName()
260
+ {
261
+ return $this->name;
262
+ }
263
+
264
+ /**
265
+ * Set the name of the parameter
266
+ *
267
+ * @param string $name Name to set
268
+ */
269
+ public function setName($name)
270
+ {
271
+ $this->name = $name;
272
+ }
273
+
274
+ /**
275
+ * Get the key of the parameter, where sentAs will supersede name if it is
276
+ * set.
277
+ *
278
+ * @return string
279
+ */
280
+ public function getWireName()
281
+ {
282
+ return $this->sentAs ?: $this->name;
283
+ }
284
+
285
+ /**
286
+ * Get the type(s) of the parameter
287
+ *
288
+ * @return string|array
289
+ */
290
+ public function getType()
291
+ {
292
+ return $this->type;
293
+ }
294
+
295
+ /**
296
+ * Get if the parameter is required
297
+ *
298
+ * @return bool
299
+ */
300
+ public function getRequired()
301
+ {
302
+ return $this->required;
303
+ }
304
+
305
+ /**
306
+ * Get the default value of the parameter
307
+ *
308
+ * @return string|null
309
+ */
310
+ public function getDefault()
311
+ {
312
+ return $this->default;
313
+ }
314
+
315
+ /**
316
+ * Get the description of the parameter
317
+ *
318
+ * @return string|null
319
+ */
320
+ public function getDescription()
321
+ {
322
+ return $this->description;
323
+ }
324
+
325
+ /**
326
+ * Get the minimum acceptable value for an integer
327
+ *
328
+ * @return int|null
329
+ */
330
+ public function getMinimum()
331
+ {
332
+ return $this->minimum;
333
+ }
334
+
335
+ /**
336
+ * Get the maximum acceptable value for an integer
337
+ *
338
+ * @return int|null
339
+ */
340
+ public function getMaximum()
341
+ {
342
+ return $this->maximum;
343
+ }
344
+
345
+ /**
346
+ * Get the minimum allowed length of a string value
347
+ *
348
+ * @return int
349
+ */
350
+ public function getMinLength()
351
+ {
352
+ return $this->minLength;
353
+ }
354
+
355
+ /**
356
+ * Get the maximum allowed length of a string value
357
+ *
358
+ * @return int|null
359
+ */
360
+ public function getMaxLength()
361
+ {
362
+ return $this->maxLength;
363
+ }
364
+
365
+ /**
366
+ * Get the maximum allowed number of items in an array value
367
+ *
368
+ * @return int|null
369
+ */
370
+ public function getMaxItems()
371
+ {
372
+ return $this->maxItems;
373
+ }
374
+
375
+ /**
376
+ * Get the minimum allowed number of items in an array value
377
+ *
378
+ * @return int
379
+ */
380
+ public function getMinItems()
381
+ {
382
+ return $this->minItems;
383
+ }
384
+
385
+ /**
386
+ * Get the location of the parameter
387
+ *
388
+ * @return string|null
389
+ */
390
+ public function getLocation()
391
+ {
392
+ return $this->location;
393
+ }
394
+
395
+ /**
396
+ * Get the sentAs attribute of the parameter that used with locations to
397
+ * sentAs an attribute when it is being applied to a location.
398
+ *
399
+ * @return string|null
400
+ */
401
+ public function getSentAs()
402
+ {
403
+ return $this->sentAs;
404
+ }
405
+
406
+ /**
407
+ * Retrieve a known property from the parameter by name or a data property
408
+ * by name. When not specific name value is specified, all data properties
409
+ * will be returned.
410
+ *
411
+ * @param string|null $name Specify a particular property name to retrieve
412
+ *
413
+ * @return array|mixed|null
414
+ */
415
+ public function getData($name = null)
416
+ {
417
+ if (!$name) {
418
+ return $this->data;
419
+ } elseif (isset($this->data[$name])) {
420
+ return $this->data[$name];
421
+ } elseif (isset($this->{$name})) {
422
+ return $this->{$name};
423
+ }
424
+
425
+ return null;
426
+ }
427
+
428
+ /**
429
+ * Get whether or not the default value can be changed
430
+ *
431
+ * @return mixed|null
432
+ */
433
+ public function getStatic()
434
+ {
435
+ return $this->static;
436
+ }
437
+
438
+ /**
439
+ * Get an array of filters used by the parameter
440
+ *
441
+ * @return array
442
+ */
443
+ public function getFilters()
444
+ {
445
+ return $this->filters ?: [];
446
+ }
447
+
448
+ /**
449
+ * Get the properties of the parameter
450
+ *
451
+ * @return Parameter[]
452
+ */
453
+ public function getProperties()
454
+ {
455
+ if (!$this->propertiesCache) {
456
+ $this->propertiesCache = [];
457
+ foreach (array_keys($this->properties) as $name) {
458
+ $this->propertiesCache[$name] = $this->getProperty($name);
459
+ }
460
+ }
461
+
462
+ return $this->propertiesCache;
463
+ }
464
+
465
+ /**
466
+ * Get a specific property from the parameter
467
+ *
468
+ * @param string $name Name of the property to retrieve
469
+ *
470
+ * @return null|Parameter
471
+ */
472
+ public function getProperty($name)
473
+ {
474
+ if (!isset($this->properties[$name])) {
475
+ return null;
476
+ }
477
+
478
+ if (!($this->properties[$name] instanceof self)) {
479
+ $this->properties[$name]['name'] = $name;
480
+ $this->properties[$name] = new static(
481
+ $this->properties[$name],
482
+ ['description' => $this->serviceDescription]
483
+ );
484
+ }
485
+
486
+ return $this->properties[$name];
487
+ }
488
+
489
+ /**
490
+ * Get the additionalProperties value of the parameter
491
+ *
492
+ * @return bool|Parameter|null
493
+ */
494
+ public function getAdditionalProperties()
495
+ {
496
+ if (is_array($this->additionalProperties)) {
497
+ $this->additionalProperties = new static(
498
+ $this->additionalProperties,
499
+ ['description' => $this->serviceDescription]
500
+ );
501
+ }
502
+
503
+ return $this->additionalProperties;
504
+ }
505
+
506
+ /**
507
+ * Get the item data of the parameter
508
+ *
509
+ * @return Parameter|null
510
+ */
511
+ public function getItems()
512
+ {
513
+ if (is_array($this->items)) {
514
+ $this->items = new static(
515
+ $this->items,
516
+ ['description' => $this->serviceDescription]
517
+ );
518
+ }
519
+
520
+ return $this->items;
521
+ }
522
+
523
+ /**
524
+ * Get the enum of strings that are valid for the parameter
525
+ *
526
+ * @return array|null
527
+ */
528
+ public function getEnum()
529
+ {
530
+ return $this->enum;
531
+ }
532
+
533
+ /**
534
+ * Get the regex pattern that must match a value when the value is a string
535
+ *
536
+ * @return string
537
+ */
538
+ public function getPattern()
539
+ {
540
+ return $this->pattern;
541
+ }
542
+
543
+ /**
544
+ * Get the format attribute of the schema
545
+ *
546
+ * @return string
547
+ */
548
+ public function getFormat()
549
+ {
550
+ return $this->format;
551
+ }
552
+
553
+ /**
554
+ * Set the array of filters used by the parameter
555
+ *
556
+ * @param array $filters Array of functions to use as filters
557
+ *
558
+ * @return self
559
+ */
560
+ private function setFilters(array $filters)
561
+ {
562
+ $this->filters = [];
563
+ foreach ($filters as $filter) {
564
+ $this->addFilter($filter);
565
+ }
566
+
567
+ return $this;
568
+ }
569
+
570
+ /**
571
+ * Add a filter to the parameter
572
+ *
573
+ * @param string|array $filter Method to filter the value through
574
+ *
575
+ * @return self
576
+ * @throws \InvalidArgumentException
577
+ */
578
+ private function addFilter($filter)
579
+ {
580
+ if (is_array($filter)) {
581
+ if (!isset($filter['method'])) {
582
+ throw new \InvalidArgumentException(
583
+ 'A [method] value must be specified for each complex filter'
584
+ );
585
+ }
586
+ }
587
+
588
+ if (!$this->filters) {
589
+ $this->filters = [$filter];
590
+ } else {
591
+ $this->filters[] = $filter;
592
+ }
593
+
594
+ return $this;
595
+ }
596
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/RequestLocation/AbstractLocation.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command\Guzzle\RequestLocation;
3
+
4
+ use GuzzleHttp\Command\Guzzle\Operation;
5
+ use GuzzleHttp\Command\Guzzle\Parameter;
6
+ use GuzzleHttp\Message\RequestInterface;
7
+ use GuzzleHttp\Command\CommandInterface;
8
+
9
+ abstract class AbstractLocation implements RequestLocationInterface
10
+ {
11
+ /** @var string */
12
+ protected $locationName;
13
+
14
+ /**
15
+ * Set the name of the location
16
+ *
17
+ * @param $locationName
18
+ */
19
+ public function __construct($locationName)
20
+ {
21
+ $this->locationName = $locationName;
22
+ }
23
+
24
+ public function visit(
25
+ CommandInterface $command,
26
+ RequestInterface $request,
27
+ Parameter $param,
28
+ array $context
29
+ ) {}
30
+
31
+ public function after(
32
+ CommandInterface $command,
33
+ RequestInterface $request,
34
+ Operation $operation,
35
+ array $context
36
+ ) {}
37
+
38
+ /**
39
+ * Prepare (filter and set desired name for request item) the value for
40
+ * request.
41
+ *
42
+ * @param mixed $value
43
+ * @param Parameter $param
44
+ *
45
+ * @return array|mixed
46
+ */
47
+ protected function prepareValue($value, Parameter $param)
48
+ {
49
+ return is_array($value)
50
+ ? $this->resolveRecursively($value, $param)
51
+ : $param->filter($value);
52
+ }
53
+
54
+ /**
55
+ * Recursively prepare and filter nested values.
56
+ *
57
+ * @param array $value Value to map
58
+ * @param Parameter $param Parameter related to the current key.
59
+ *
60
+ * @return array Returns the mapped array
61
+ */
62
+ protected function resolveRecursively(array $value, Parameter $param)
63
+ {
64
+ foreach ($value as $name => &$v) {
65
+ switch ($param->getType()) {
66
+ case 'object':
67
+ if ($subParam = $param->getProperty($name)) {
68
+ $key = $subParam->getWireName();
69
+ $value[$key] = $this->prepareValue($v, $subParam);
70
+ if ($name != $key) {
71
+ unset($value[$name]);
72
+ }
73
+ } elseif ($param->getAdditionalProperties() instanceof Parameter) {
74
+ $v = $this->prepareValue($v, $param->getAdditionalProperties());
75
+ }
76
+ break;
77
+ case 'array':
78
+ if ($items = $param->getItems()) {
79
+ $v = $this->prepareValue($v, $items);
80
+ }
81
+ break;
82
+ }
83
+ }
84
+
85
+ return $param->filter($value);
86
+ }
87
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/RequestLocation/BodyLocation.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command\Guzzle\RequestLocation;
3
+
4
+ use GuzzleHttp\Command\CommandInterface;
5
+ use GuzzleHttp\Command\Guzzle\Parameter;
6
+ use GuzzleHttp\Message\RequestInterface;
7
+ use GuzzleHttp\Stream\Stream;
8
+
9
+ /**
10
+ * Adds a body to a request
11
+ */
12
+ class BodyLocation extends AbstractLocation
13
+ {
14
+ public function visit(
15
+ CommandInterface $command,
16
+ RequestInterface $request,
17
+ Parameter $param,
18
+ array $context
19
+ ) {
20
+ $value = $command[$param->getName()];
21
+ $request->setBody(Stream::factory($param->filter($value)));
22
+ }
23
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/RequestLocation/HeaderLocation.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command\Guzzle\RequestLocation;
3
+
4
+ use GuzzleHttp\Command\Guzzle\Parameter;
5
+ use GuzzleHttp\Message\RequestInterface;
6
+ use GuzzleHttp\Command\Guzzle\Operation;
7
+ use GuzzleHttp\Command\CommandInterface;
8
+
9
+ /**
10
+ * Request header location
11
+ */
12
+ class HeaderLocation extends AbstractLocation
13
+ {
14
+ public function visit(
15
+ CommandInterface $command,
16
+ RequestInterface $request,
17
+ Parameter $param,
18
+ array $context
19
+ ) {
20
+ $value = $command[$param->getName()];
21
+ $request->setHeader($param->getWireName(), $param->filter($value));
22
+ }
23
+
24
+ public function after(
25
+ CommandInterface $command,
26
+ RequestInterface $request,
27
+ Operation $operation,
28
+ array $context
29
+ ) {
30
+ $additional = $operation->getAdditionalParameters();
31
+ if ($additional && $additional->getLocation() == $this->locationName) {
32
+ foreach ($command->toArray() as $key => $value) {
33
+ if (!$operation->hasParam($key)) {
34
+ $request->setHeader($key, $additional->filter($value));
35
+ }
36
+ }
37
+ }
38
+ }
39
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/RequestLocation/JsonLocation.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command\Guzzle\RequestLocation;
3
+
4
+ use GuzzleHttp\Command\Guzzle\Operation;
5
+ use GuzzleHttp\Command\Guzzle\Parameter;
6
+ use GuzzleHttp\Command\CommandInterface;
7
+ use GuzzleHttp\Message\RequestInterface;
8
+ use GuzzleHttp\Stream\Stream;
9
+
10
+ /**
11
+ * Creates a JSON document
12
+ */
13
+ class JsonLocation extends AbstractLocation
14
+ {
15
+ /** @var bool Whether or not to add a Content-Type header when JSON is found */
16
+ private $jsonContentType;
17
+
18
+ /** @var array */
19
+ private $jsonData;
20
+
21
+ /**
22
+ * @param string $locationName Name of the location
23
+ * @param string $contentType Content-Type header to add to the request if
24
+ * JSON is added to the body. Pass an empty string to omit.
25
+ */
26
+ public function __construct($locationName, $contentType = 'application/json')
27
+ {
28
+ $this->locationName = $locationName;
29
+ $this->jsonContentType = $contentType;
30
+ }
31
+
32
+ public function visit(
33
+ CommandInterface $command,
34
+ RequestInterface $request,
35
+ Parameter $param,
36
+ array $context
37
+ ) {
38
+ $this->jsonData[$param->getWireName()] = $this->prepareValue(
39
+ $command[$param->getName()],
40
+ $param
41
+ );
42
+ }
43
+
44
+ public function after(
45
+ CommandInterface $command,
46
+ RequestInterface $request,
47
+ Operation $operation,
48
+ array $context
49
+ ) {
50
+ $data = $this->jsonData;
51
+ $this->jsonData = null;
52
+
53
+ // Add additional parameters to the JSON document
54
+ $additional = $operation->getAdditionalParameters();
55
+ if ($additional && $additional->getLocation() == $this->locationName) {
56
+ foreach ($command->toArray() as $key => $value) {
57
+ if (!$operation->hasParam($key)) {
58
+ $data[$key] = $this->prepareValue($value, $additional);
59
+ }
60
+ }
61
+ }
62
+
63
+ // Don't overwrite the Content-Type if one is set
64
+ if ($this->jsonContentType && !$request->hasHeader('Content-Type')) {
65
+ $request->setHeader('Content-Type', $this->jsonContentType);
66
+ }
67
+
68
+ $request->setBody(Stream::factory(json_encode($data)));
69
+ }
70
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/RequestLocation/PostFieldLocation.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command\Guzzle\RequestLocation;
3
+
4
+ use GuzzleHttp\Command\Guzzle\Parameter;
5
+ use GuzzleHttp\Message\RequestInterface;
6
+ use GuzzleHttp\Post\PostBodyInterface;
7
+ use GuzzleHttp\Command\CommandInterface;
8
+ use GuzzleHttp\Command\Guzzle\Operation;
9
+
10
+ /**
11
+ * Adds POST fields to a request
12
+ */
13
+ class PostFieldLocation extends AbstractLocation
14
+ {
15
+ public function visit(
16
+ CommandInterface $command,
17
+ RequestInterface $request,
18
+ Parameter $param,
19
+ array $context
20
+ ) {
21
+ $body = $request->getBody();
22
+ if (!($body instanceof PostBodyInterface)) {
23
+ throw new \RuntimeException('Must be a POST body interface');
24
+ }
25
+
26
+ $body->setField(
27
+ $param->getWireName(),
28
+ $this->prepareValue($command[$param->getName()], $param)
29
+ );
30
+ }
31
+
32
+ public function after(
33
+ CommandInterface $command,
34
+ RequestInterface $request,
35
+ Operation $operation,
36
+ array $context
37
+ ) {
38
+ $additional = $operation->getAdditionalParameters();
39
+ if ($additional && $additional->getLocation() == $this->locationName) {
40
+
41
+ $body = $request->getBody();
42
+ if (!($body instanceof PostBodyInterface)) {
43
+ throw new \RuntimeException('Must be a POST body interface');
44
+ }
45
+
46
+ foreach ($command->toArray() as $key => $value) {
47
+ if (!$operation->hasParam($key)) {
48
+ $body->setField(
49
+ $key,
50
+ $this->prepareValue($value, $additional)
51
+ );
52
+ }
53
+ }
54
+ }
55
+ }
56
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/RequestLocation/PostFileLocation.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command\Guzzle\RequestLocation;
3
+
4
+ use GuzzleHttp\Command\Guzzle\Parameter;
5
+ use GuzzleHttp\Message\RequestInterface;
6
+ use GuzzleHttp\Post\PostBodyInterface;
7
+ use GuzzleHttp\Post\PostFileInterface;
8
+ use GuzzleHttp\Post\PostFile;
9
+ use GuzzleHttp\Command\CommandInterface;
10
+
11
+ /**
12
+ * Adds POST files to a request
13
+ */
14
+ class PostFileLocation extends AbstractLocation
15
+ {
16
+ public function visit(
17
+ CommandInterface $command,
18
+ RequestInterface $request,
19
+ Parameter $param,
20
+ array $context
21
+ ) {
22
+ $body = $request->getBody();
23
+ if (!($body instanceof PostBodyInterface)) {
24
+ throw new \RuntimeException('Must be a POST body interface');
25
+ }
26
+
27
+ $value = $param->filter($command[$param->getName()]);
28
+ if (!($value instanceof PostFileInterface)) {
29
+ $value = new PostFile($param->getWireName(), $value);
30
+ }
31
+
32
+ $body->addFile($value);
33
+ }
34
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/RequestLocation/QueryLocation.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command\Guzzle\RequestLocation;
3
+
4
+ use GuzzleHttp\Command\Guzzle\Parameter;
5
+ use GuzzleHttp\Message\RequestInterface;
6
+ use GuzzleHttp\Command\Guzzle\Operation;
7
+ use GuzzleHttp\Command\CommandInterface;
8
+
9
+ /**
10
+ * Adds query string values to requests
11
+ */
12
+ class QueryLocation extends AbstractLocation
13
+ {
14
+ public function visit(
15
+ CommandInterface $command,
16
+ RequestInterface $request,
17
+ Parameter $param,
18
+ array $context
19
+ ) {
20
+ $request->getQuery()[$param->getWireName()] = $this->prepareValue(
21
+ $command[$param->getName()],
22
+ $param
23
+ );
24
+ }
25
+
26
+ public function after(
27
+ CommandInterface $command,
28
+ RequestInterface $request,
29
+ Operation $operation,
30
+ array $context
31
+ ) {
32
+ $additional = $operation->getAdditionalParameters();
33
+ if ($additional && $additional->getLocation() == $this->locationName) {
34
+ foreach ($command->toArray() as $key => $value) {
35
+ if (!$operation->hasParam($key)) {
36
+ $request->getQuery()[$key] = $this->prepareValue(
37
+ $value,
38
+ $additional
39
+ );
40
+ }
41
+ }
42
+ }
43
+ }
44
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/RequestLocation/RequestLocationInterface.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace GuzzleHttp\Command\Guzzle\RequestLocation;
4
+
5
+ use GuzzleHttp\Command\Guzzle\Operation;
6
+ use GuzzleHttp\Command\Guzzle\Parameter;
7
+ use GuzzleHttp\Command\CommandInterface;
8
+ use GuzzleHttp\Message\RequestInterface;
9
+
10
+ /**
11
+ * Handles locations specified in a service description
12
+ */
13
+ interface RequestLocationInterface
14
+ {
15
+ /**
16
+ * Visits a location for each top-level parameter
17
+ *
18
+ * @param CommandInterface $command Command being prepared
19
+ * @param RequestInterface $request Request being modified
20
+ * @param Parameter $param Parameter being visited
21
+ * @param array $context Associative array containing a
22
+ * 'client' key referencing the client that created the command.
23
+ */
24
+ public function visit(
25
+ CommandInterface $command,
26
+ RequestInterface $request,
27
+ Parameter $param,
28
+ array $context
29
+ );
30
+
31
+ /**
32
+ * Called when all of the parameters of a command have been visited.
33
+ *
34
+ * @param CommandInterface $command Command being prepared
35
+ * @param RequestInterface $request Request being modified
36
+ * @param Operation $operation Operation being serialized
37
+ * @param array $context Associative array containing a
38
+ * 'client' key referencing the client that created the command.
39
+ */
40
+ public function after(
41
+ CommandInterface $command,
42
+ RequestInterface $request,
43
+ Operation $operation,
44
+ array $context
45
+ );
46
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/RequestLocation/XmlLocation.php ADDED
@@ -0,0 +1,300 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command\Guzzle\RequestLocation;
3
+
4
+ use GuzzleHttp\Command\Guzzle\Operation;
5
+ use GuzzleHttp\Command\Guzzle\Parameter;
6
+ use GuzzleHttp\Command\CommandInterface;
7
+ use GuzzleHttp\Message\RequestInterface;
8
+ use GuzzleHttp\Stream\Stream;
9
+
10
+ /**
11
+ * Creates an XML document
12
+ */
13
+ class XmlLocation extends AbstractLocation
14
+ {
15
+ /** @var \XMLWriter XML writer resource */
16
+ private $writer;
17
+
18
+ /** @var bool Content-Type header added when XML is found */
19
+ private $contentType;
20
+
21
+ /** @var Parameter[] Buffered elements to write */
22
+ private $buffered = [];
23
+
24
+ /**
25
+ * @param string $locationName Name of the location
26
+ * @param string $contentType Set to a non-empty string to add a
27
+ * Content-Type header to a request if any XML content is added to the
28
+ * body. Pass an empty string to disable the addition of the header.
29
+ */
30
+ public function __construct($locationName, $contentType = 'application/xml')
31
+ {
32
+ $this->locationName = $locationName;
33
+ $this->contentType = $contentType;
34
+ $this->data = new \SplObjectStorage();
35
+ }
36
+
37
+ public function visit(
38
+ CommandInterface $command,
39
+ RequestInterface $request,
40
+ Parameter $param,
41
+ array $context
42
+ ) {
43
+ // Buffer and order the parameters to visit based on if they are
44
+ // top-level attributes or child nodes.
45
+ // @link https://github.com/guzzle/guzzle/pull/494
46
+ if ($param->getData('xmlAttribute')) {
47
+ array_unshift($this->buffered, $param);
48
+ } else {
49
+ $this->buffered[] = $param;
50
+ }
51
+ }
52
+
53
+ public function after(
54
+ CommandInterface $command,
55
+ RequestInterface $request,
56
+ Operation $operation,
57
+ array $context
58
+ ) {
59
+ foreach ($this->buffered as $param) {
60
+ $this->visitWithValue(
61
+ $command[$param->getName()],
62
+ $param,
63
+ $operation
64
+ );
65
+ }
66
+
67
+ $this->buffered = [];
68
+
69
+ $additional = $operation->getAdditionalParameters();
70
+ if ($additional && $additional->getLocation() == $this->locationName) {
71
+ foreach ($command->toArray() as $key => $value) {
72
+ if (!$operation->hasParam($key)) {
73
+ $additional->setName($key);
74
+ $this->visitWithValue($value, $additional, $operation);
75
+ }
76
+ }
77
+ $additional->setName(null);
78
+ }
79
+
80
+ // If data was found that needs to be serialized, then do so
81
+ $xml = null;
82
+ if ($this->writer) {
83
+ $xml = $this->finishDocument($this->writer);
84
+ } elseif ($operation->getData('xmlAllowEmpty')) {
85
+ // Check if XML should always be sent for the command
86
+ $writer = $this->createRootElement($operation);
87
+ $xml = $this->finishDocument($writer);
88
+ }
89
+
90
+ if ($xml) {
91
+ $request->setBody(Stream::factory($xml));
92
+ // Don't overwrite the Content-Type if one is set
93
+ if ($this->contentType && !$request->hasHeader('Content-Type')) {
94
+ $request->setHeader('Content-Type', $this->contentType);
95
+ }
96
+ }
97
+
98
+ $this->writer = null;
99
+ }
100
+
101
+ /**
102
+ * Create the root XML element to use with a request
103
+ *
104
+ * @param Operation $operation Operation object
105
+ *
106
+ * @return \XMLWriter
107
+ */
108
+ protected function createRootElement(Operation $operation)
109
+ {
110
+ static $defaultRoot = ['name' => 'Request'];
111
+ // If no root element was specified, then just wrap the XML in 'Request'
112
+ $root = $operation->getData('xmlRoot') ?: $defaultRoot;
113
+ // Allow the XML declaration to be customized with xmlEncoding
114
+ $encoding = $operation->getData('xmlEncoding');
115
+ $writer = $this->startDocument($encoding);
116
+ $writer->startElement($root['name']);
117
+
118
+ // Create the wrapping element with no namespaces if no namespaces were present
119
+ if (!empty($root['namespaces'])) {
120
+ // Create the wrapping element with an array of one or more namespaces
121
+ foreach ((array) $root['namespaces'] as $prefix => $uri) {
122
+ $nsLabel = 'xmlns';
123
+ if (!is_numeric($prefix)) {
124
+ $nsLabel .= ':'.$prefix;
125
+ }
126
+ $writer->writeAttribute($nsLabel, $uri);
127
+ }
128
+ }
129
+
130
+ return $writer;
131
+ }
132
+
133
+ /**
134
+ * Recursively build the XML body
135
+ *
136
+ * @param \XMLWriter $writer XML to modify
137
+ * @param Parameter $param API Parameter
138
+ * @param mixed $value Value to add
139
+ */
140
+ protected function addXml(\XMLWriter $writer, Parameter $param, $value)
141
+ {
142
+ $value = $param->filter($value);
143
+ $type = $param->getType();
144
+ $name = $param->getWireName();
145
+ $prefix = null;
146
+ $namespace = $param->getData('xmlNamespace');
147
+ if (false !== strpos($name, ':')) {
148
+ list($prefix, $name) = explode(':', $name, 2);
149
+ }
150
+
151
+ if ($type == 'object' || $type == 'array') {
152
+ if (!$param->getData('xmlFlattened')) {
153
+ if ($namespace) {
154
+ $writer->startElementNS(null, $name, $namespace);
155
+ } else {
156
+ $writer->startElement($name);
157
+ }
158
+ }
159
+ if ($param->getType() == 'array') {
160
+ $this->addXmlArray($writer, $param, $value);
161
+ } elseif ($param->getType() == 'object') {
162
+ $this->addXmlObject($writer, $param, $value);
163
+ }
164
+ if (!$param->getData('xmlFlattened')) {
165
+ $writer->endElement();
166
+ }
167
+ return;
168
+ }
169
+ if ($param->getData('xmlAttribute')) {
170
+ $this->writeAttribute($writer, $prefix, $name, $namespace, $value);
171
+ } else {
172
+ $this->writeElement($writer, $prefix, $name, $namespace, $value);
173
+ }
174
+ }
175
+
176
+ /**
177
+ * Write an attribute with namespace if used
178
+ *
179
+ * @param \XMLWriter $writer XMLWriter instance
180
+ * @param string $prefix Namespace prefix if any
181
+ * @param string $name Attribute name
182
+ * @param string $namespace The uri of the namespace
183
+ * @param string $value The attribute content
184
+ */
185
+ protected function writeAttribute($writer, $prefix, $name, $namespace, $value)
186
+ {
187
+ if ($namespace) {
188
+ $writer->writeAttributeNS($prefix, $name, $namespace, $value);
189
+ } else {
190
+ $writer->writeAttribute($name, $value);
191
+ }
192
+ }
193
+
194
+ /**
195
+ * Write an element with namespace if used
196
+ *
197
+ * @param \XMLWriter $writer XML writer resource
198
+ * @param string $prefix Namespace prefix if any
199
+ * @param string $name Element name
200
+ * @param string $namespace The uri of the namespace
201
+ * @param string $value The element content
202
+ */
203
+ protected function writeElement(\XMLWriter $writer, $prefix, $name, $namespace, $value)
204
+ {
205
+ if ($namespace) {
206
+ $writer->startElementNS($prefix, $name, $namespace);
207
+ } else {
208
+ $writer->startElement($name);
209
+ }
210
+ if (strpbrk($value, '<>&')) {
211
+ $writer->writeCData($value);
212
+ } else {
213
+ $writer->writeRaw($value);
214
+ }
215
+ $writer->endElement();
216
+ }
217
+
218
+ /**
219
+ * Create a new xml writer and start a document
220
+ *
221
+ * @param string $encoding document encoding
222
+ *
223
+ * @return \XMLWriter the writer resource
224
+ * @throws \RuntimeException if the document cannot be started
225
+ */
226
+ protected function startDocument($encoding)
227
+ {
228
+ $this->writer = new \XMLWriter();
229
+ if (!$this->writer->openMemory()) {
230
+ throw new \RuntimeException('Unable to open XML document in memory');
231
+ }
232
+ if (!$this->writer->startDocument('1.0', $encoding)) {
233
+ throw new \RuntimeException('Unable to start XML document');
234
+ }
235
+
236
+ return $this->writer;
237
+ }
238
+
239
+ /**
240
+ * End the document and return the output
241
+ *
242
+ * @param \XMLWriter $writer
243
+ *
244
+ * @return \string the writer resource
245
+ */
246
+ protected function finishDocument($writer)
247
+ {
248
+ $writer->endDocument();
249
+
250
+ return $writer->outputMemory();
251
+ }
252
+
253
+ /**
254
+ * Add an array to the XML
255
+ */
256
+ protected function addXmlArray(\XMLWriter $writer, Parameter $param, &$value)
257
+ {
258
+ if ($items = $param->getItems()) {
259
+ foreach ($value as $v) {
260
+ $this->addXml($writer, $items, $v);
261
+ }
262
+ }
263
+ }
264
+
265
+ /**
266
+ * Add an object to the XML
267
+ */
268
+ protected function addXmlObject(\XMLWriter $writer, Parameter $param, &$value)
269
+ {
270
+ $noAttributes = [];
271
+
272
+ // add values which have attributes
273
+ foreach ($value as $name => $v) {
274
+ if ($property = $param->getProperty($name)) {
275
+ if ($property->getData('xmlAttribute')) {
276
+ $this->addXml($writer, $property, $v);
277
+ } else {
278
+ $noAttributes[] = ['value' => $v, 'property' => $property];
279
+ }
280
+ }
281
+ }
282
+
283
+ // now add values with no attributes
284
+ foreach ($noAttributes as $element) {
285
+ $this->addXml($writer, $element['property'], $element['value']);
286
+ }
287
+ }
288
+
289
+ private function visitWithValue(
290
+ $value,
291
+ Parameter $param,
292
+ Operation $operation
293
+ ) {
294
+ if (!$this->writer) {
295
+ $this->createRootElement($operation);
296
+ }
297
+
298
+ $this->addXml($this->writer, $param, $value);
299
+ }
300
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/ResponseLocation/AbstractLocation.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command\Guzzle\ResponseLocation;
3
+
4
+ use GuzzleHttp\Command\Guzzle\Parameter;
5
+ use GuzzleHttp\Message\ResponseInterface;
6
+ use GuzzleHttp\Command\CommandInterface;
7
+
8
+ abstract class AbstractLocation implements ResponseLocationInterface
9
+ {
10
+ /** @var string */
11
+ protected $locationName;
12
+
13
+ /**
14
+ * Set the name of the location
15
+ *
16
+ * @param $locationName
17
+ */
18
+ public function __construct($locationName)
19
+ {
20
+ $this->locationName = $locationName;
21
+ }
22
+
23
+ public function before(
24
+ CommandInterface $command,
25
+ ResponseInterface $response,
26
+ Parameter $model,
27
+ &$result,
28
+ array $context = []
29
+ ) {}
30
+
31
+ public function after(
32
+ CommandInterface $command,
33
+ ResponseInterface $response,
34
+ Parameter $model,
35
+ &$result,
36
+ array $context = []
37
+ ) {}
38
+
39
+ public function visit(
40
+ CommandInterface $command,
41
+ ResponseInterface $response,
42
+ Parameter $param,
43
+ &$result,
44
+ array $context = []
45
+ ) {}
46
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/ResponseLocation/BodyLocation.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command\Guzzle\ResponseLocation;
3
+
4
+ use GuzzleHttp\Command\Guzzle\Parameter;
5
+ use GuzzleHttp\Message\ResponseInterface;
6
+ use GuzzleHttp\Command\CommandInterface;
7
+
8
+ /**
9
+ * Extracts the body of a response into a result field
10
+ */
11
+ class BodyLocation extends AbstractLocation
12
+ {
13
+ public function visit(
14
+ CommandInterface $command,
15
+ ResponseInterface $response,
16
+ Parameter $param,
17
+ &$result,
18
+ array $context = []
19
+ ) {
20
+ $result[$param->getName()] = $param->filter($response->getBody());
21
+ }
22
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/ResponseLocation/HeaderLocation.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command\Guzzle\ResponseLocation;
3
+
4
+ use GuzzleHttp\Command\Guzzle\Parameter;
5
+ use GuzzleHttp\Message\ResponseInterface;
6
+ use GuzzleHttp\Command\CommandInterface;
7
+
8
+ /**
9
+ * Extracts headers from the response into a result fields
10
+ */
11
+ class HeaderLocation extends AbstractLocation
12
+ {
13
+ public function visit(
14
+ CommandInterface $command,
15
+ ResponseInterface $response,
16
+ Parameter $param,
17
+ &$result,
18
+ array $context = []
19
+ ) {
20
+ // Retrieving a single header by name
21
+ $name = $param->getName();
22
+ if ($header = $response->getHeader($param->getWireName())) {
23
+ $result[$name] = $param->filter($header);
24
+ }
25
+ }
26
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/ResponseLocation/JsonLocation.php ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command\Guzzle\ResponseLocation;
3
+
4
+ use GuzzleHttp\Command\Guzzle\Parameter;
5
+ use GuzzleHttp\Message\ResponseInterface;
6
+ use GuzzleHttp\Command\CommandInterface;
7
+
8
+ /**
9
+ * Extracts elements from a JSON document.
10
+ */
11
+ class JsonLocation extends AbstractLocation
12
+ {
13
+ /** @var array The JSON document being visited */
14
+ private $json = [];
15
+
16
+ public function before(
17
+ CommandInterface $command,
18
+ ResponseInterface $response,
19
+ Parameter $model,
20
+ &$result,
21
+ array $context = []
22
+ ) {
23
+ $this->json = $response->json() ?: [];
24
+ // relocate named arrays, so that they have the same structure as
25
+ // arrays nested in objects and visit can work on them in the same way
26
+ if ($model->getType() == 'array' && ($name = $model->getName())) {
27
+ $this->json = [$name => $this->json];
28
+ }
29
+ }
30
+
31
+ public function after(
32
+ CommandInterface $command,
33
+ ResponseInterface $response,
34
+ Parameter $model,
35
+ &$result,
36
+ array $context = []
37
+ ) {
38
+ // Handle additional, undefined properties
39
+ $additional = $model->getAdditionalProperties();
40
+ if (!($additional instanceof Parameter)) {
41
+ return;
42
+ }
43
+
44
+ // Use the model location as the default if one is not set on additional
45
+ $addLocation = $additional->getLocation() ?: $model->getLocation();
46
+ if ($addLocation == $this->locationName) {
47
+ foreach ($this->json as $prop => $val) {
48
+ if (!isset($result[$prop])) {
49
+ // Only recurse if there is a type specified
50
+ $result[$prop] = $additional->getType()
51
+ ? $this->recurse($additional, $val)
52
+ : $val;
53
+ }
54
+ }
55
+ }
56
+
57
+ $this->json = [];
58
+ }
59
+
60
+ public function visit(
61
+ CommandInterface $command,
62
+ ResponseInterface $response,
63
+ Parameter $param,
64
+ &$result,
65
+ array $context = []
66
+ ) {
67
+ $name = $param->getName();
68
+ $key = $param->getWireName();
69
+
70
+ // Check if the result should be treated as a list
71
+ if ($param->getType() == 'array') {
72
+ // Treat as javascript array
73
+ if ($name) {
74
+ // name provided, store it under a key in the array
75
+ $result[$name] = $this->recurse($param, $this->json[$name]);
76
+ } else {
77
+ // top-level `array` or an empty name
78
+ $result = array_merge($result, $this->recurse($param, $this->json));
79
+ }
80
+ } elseif (isset($this->json[$key])) {
81
+ $result[$name] = $this->recurse($param, $this->json[$key]);
82
+ }
83
+ }
84
+
85
+ /**
86
+ * Recursively process a parameter while applying filters
87
+ *
88
+ * @param Parameter $param API parameter being validated
89
+ * @param mixed $value Value to process.
90
+ * @return mixed|null
91
+ */
92
+ private function recurse(Parameter $param, $value)
93
+ {
94
+ if (!is_array($value)) {
95
+ return $param->filter($value);
96
+ }
97
+
98
+ $result = [];
99
+ $type = $param->getType();
100
+
101
+ if ($type == 'array') {
102
+ $items = $param->getItems();
103
+ foreach ($value as $val) {
104
+ $result[] = $this->recurse($items, $val);
105
+ }
106
+ } elseif ($type == 'object' && !isset($value[0])) {
107
+ // On the above line, we ensure that the array is associative and
108
+ // not numerically indexed
109
+ if ($properties = $param->getProperties()) {
110
+ foreach ($properties as $property) {
111
+ $key = $property->getWireName();
112
+ if (isset($value[$key])) {
113
+ $result[$property->getName()] = $this->recurse(
114
+ $property,
115
+ $value[$key]
116
+ );
117
+ // Remove from the value so that AP can later be handled
118
+ unset($value[$key]);
119
+ }
120
+ }
121
+ }
122
+ // Only check additional properties if everything wasn't already
123
+ // handled
124
+ if ($value) {
125
+ $additional = $param->getAdditionalProperties();
126
+ if ($additional === null || $additional === true) {
127
+ // Merge the JSON under the resulting array
128
+ $result += $value;
129
+ } elseif ($additional instanceof Parameter) {
130
+ // Process all child elements according to the given schema
131
+ foreach ($value as $prop => $val) {
132
+ $result[$prop] = $this->recurse($additional, $val);
133
+ }
134
+ }
135
+ }
136
+ }
137
+
138
+ return $param->filter($result);
139
+ }
140
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/ResponseLocation/ReasonPhraseLocation.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command\Guzzle\ResponseLocation;
3
+
4
+ use GuzzleHttp\Command\Guzzle\Parameter;
5
+ use GuzzleHttp\Message\ResponseInterface;
6
+ use GuzzleHttp\Command\CommandInterface;
7
+
8
+ /**
9
+ * Extracts the reason phrase of a response into a result field
10
+ */
11
+ class ReasonPhraseLocation extends AbstractLocation
12
+ {
13
+ public function visit(
14
+ CommandInterface $command,
15
+ ResponseInterface $response,
16
+ Parameter $param,
17
+ &$result,
18
+ array $context = []
19
+ ) {
20
+ $result[$param->getName()] = $param->filter(
21
+ $response->getReasonPhrase()
22
+ );
23
+ }
24
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/ResponseLocation/ResponseLocationInterface.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command\Guzzle\ResponseLocation;
3
+
4
+ use GuzzleHttp\Command\Guzzle\Parameter;
5
+ use GuzzleHttp\Message\ResponseInterface;
6
+ use GuzzleHttp\Command\CommandInterface;
7
+
8
+ /**
9
+ * Location visitor used to parse values out of a response into an associative
10
+ * array
11
+ */
12
+ interface ResponseLocationInterface
13
+ {
14
+ /**
15
+ * Called before visiting all parameters. This can be used for seeding the
16
+ * result of a command with default data (e.g. populating with JSON data in
17
+ * the response then adding to the parsed data).
18
+ *
19
+ * @param CommandInterface $command Command being visited
20
+ * @param ResponseInterface $response Response being visited
21
+ * @param Parameter $model Response model
22
+ * @param mixed $result Result associative array value
23
+ * being updated by reference.
24
+ * @param array $context Parsing context
25
+ */
26
+ public function before(
27
+ CommandInterface $command,
28
+ ResponseInterface $response,
29
+ Parameter $model,
30
+ &$result,
31
+ array $context = []
32
+ );
33
+
34
+ /**
35
+ * Called after visiting all parameters
36
+ *
37
+ * @param CommandInterface $command Command being visited
38
+ * @param ResponseInterface $response Response being visited
39
+ * @param Parameter $model Response model
40
+ * @param mixed $result Result associative array value
41
+ * being updated by reference.
42
+ * @param array $context Parsing context
43
+ */
44
+ public function after(
45
+ CommandInterface $command,
46
+ ResponseInterface $response,
47
+ Parameter $model,
48
+ &$result,
49
+ array $context = []
50
+ );
51
+
52
+ /**
53
+ * Called once for each parameter being visited that matches the location
54
+ * type.
55
+ *
56
+ * @param CommandInterface $command Command being visited
57
+ * @param ResponseInterface $response Response being visited
58
+ * @param Parameter $param Parameter being visited
59
+ * @param mixed $result Result associative array value
60
+ * being updated by reference.
61
+ * @param array $context Parsing context
62
+ */
63
+ public function visit(
64
+ CommandInterface $command,
65
+ ResponseInterface $response,
66
+ Parameter $param,
67
+ &$result,
68
+ array $context = []
69
+ );
70
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/ResponseLocation/StatusCodeLocation.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command\Guzzle\ResponseLocation;
3
+
4
+ use GuzzleHttp\Command\Guzzle\Parameter;
5
+ use GuzzleHttp\Message\ResponseInterface;
6
+ use GuzzleHttp\Command\CommandInterface;
7
+
8
+ /**
9
+ * Extracts the status code of a response into a result field
10
+ */
11
+ class StatusCodeLocation extends AbstractLocation
12
+ {
13
+ public function visit(
14
+ CommandInterface $command,
15
+ ResponseInterface $response,
16
+ Parameter $param,
17
+ &$result,
18
+ array $context = []
19
+ ) {
20
+ $result[$param->getName()] = $param->filter($response->getStatusCode());
21
+ }
22
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/ResponseLocation/XmlLocation.php ADDED
@@ -0,0 +1,269 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command\Guzzle\ResponseLocation;
3
+
4
+ use GuzzleHttp\Command\Guzzle\Parameter;
5
+ use GuzzleHttp\Message\ResponseInterface;
6
+ use GuzzleHttp\Command\CommandInterface;
7
+
8
+ /**
9
+ * Extracts elements from an XML document
10
+ */
11
+ class XmlLocation extends AbstractLocation
12
+ {
13
+ /** @var \SimpleXMLElement XML document being visited */
14
+ private $xml;
15
+
16
+ public function before(
17
+ CommandInterface $command,
18
+ ResponseInterface $response,
19
+ Parameter $model,
20
+ &$result,
21
+ array $context = []
22
+ ) {
23
+ $this->xml = $response->xml();
24
+ }
25
+
26
+ public function after(
27
+ CommandInterface $command,
28
+ ResponseInterface $response,
29
+ Parameter $model,
30
+ &$result,
31
+ array $context = []
32
+ ) {
33
+ // Handle additional, undefined properties
34
+ $additional = $model->getAdditionalProperties();
35
+ if ($additional instanceof Parameter &&
36
+ $additional->getLocation() == $this->locationName
37
+ ) {
38
+ $result += self::xmlToArray($this->xml);
39
+ }
40
+
41
+ $this->xml = null;
42
+ }
43
+
44
+ public function visit(
45
+ CommandInterface $command,
46
+ ResponseInterface $response,
47
+ Parameter $param,
48
+ &$result,
49
+ array $context = []
50
+ ) {
51
+ $sentAs = $param->getWireName();
52
+ $ns = null;
53
+ if (strstr($sentAs, ':')) {
54
+ list($ns, $sentAs) = explode(':', $sentAs);
55
+ }
56
+
57
+ // Process the primary property
58
+ if (count($this->xml->children($ns, true)->{$sentAs})) {
59
+ $result[$param->getName()] = $this->recursiveProcess(
60
+ $param,
61
+ $this->xml->children($ns, true)->{$sentAs}
62
+ );
63
+ }
64
+ }
65
+
66
+ /**
67
+ * Recursively process a parameter while applying filters
68
+ *
69
+ * @param Parameter $param API parameter being processed
70
+ * @param \SimpleXMLElement $node Node being processed
71
+ * @return array
72
+ */
73
+ private function recursiveProcess(
74
+ Parameter $param,
75
+ \SimpleXMLElement $node
76
+ ) {
77
+ $result = [];
78
+ $type = $param->getType();
79
+
80
+ if ($type == 'object') {
81
+ $result = $this->processObject($param, $node);
82
+ } elseif ($type == 'array') {
83
+ $result = $this->processArray($param, $node);
84
+ } else {
85
+ // We are probably handling a flat data node (i.e. string or
86
+ // integer), so let's check if it's childless, which indicates a
87
+ // node containing plain text.
88
+ if ($node->children()->count() == 0) {
89
+ // Retrieve text from node
90
+ $result = (string) $node;
91
+ }
92
+ }
93
+
94
+ // Filter out the value
95
+ if (isset($result)) {
96
+ $result = $param->filter($result);
97
+ }
98
+
99
+ return $result;
100
+ }
101
+
102
+ private function processArray(Parameter $param, \SimpleXMLElement $node)
103
+ {
104
+ // Cast to an array if the value was a string, but should be an array
105
+ $items = $param->getItems();
106
+ $sentAs = $items->getWireName();
107
+ $result = [];
108
+ $ns = null;
109
+
110
+ if (strstr($sentAs, ':')) {
111
+ // Get namespace from the wire name
112
+ list($ns, $sentAs) = explode(':', $sentAs);
113
+ } else {
114
+ // Get namespace from data
115
+ $ns = $items->getData('xmlNs');
116
+ }
117
+
118
+ if ($sentAs === null) {
119
+ // A general collection of nodes
120
+ foreach ($node as $child) {
121
+ $result[] = $this->recursiveProcess($items, $child);
122
+ }
123
+ } else {
124
+ // A collection of named, repeating nodes
125
+ // (i.e. <collection><foo></foo><foo></foo></collection>)
126
+ $children = $node->children($ns, true)->{$sentAs};
127
+ foreach ($children as $child) {
128
+ $result[] = $this->recursiveProcess($items, $child);
129
+ }
130
+ }
131
+
132
+ return $result;
133
+ }
134
+
135
+ /**
136
+ * Process an object
137
+ *
138
+ * @param Parameter $param API parameter being parsed
139
+ * @param \SimpleXMLElement $node Value to process
140
+ * @return array
141
+ */
142
+ private function processObject(Parameter $param, \SimpleXMLElement $node)
143
+ {
144
+ $result = $knownProps = $knownAttributes = [];
145
+
146
+ // Handle known properties
147
+ if ($properties = $param->getProperties()) {
148
+ foreach ($properties as $property) {
149
+ $name = $property->getName();
150
+ $sentAs = $property->getWireName();
151
+ $knownProps[$sentAs] = 1;
152
+ if (strpos($sentAs, ':')) {
153
+ list($ns, $sentAs) = explode(':', $sentAs);
154
+ } else {
155
+ $ns = $property->getData('xmlNs');
156
+ }
157
+
158
+ if ($property->getData('xmlAttribute')) {
159
+ // Handle XML attributes
160
+ $result[$name] = (string) $node->attributes($ns, true)->{$sentAs};
161
+ $knownAttributes[$sentAs] = 1;
162
+ } elseif (count($node->children($ns, true)->{$sentAs})) {
163
+ // Found a child node matching wire name
164
+ $childNode = $node->children($ns, true)->{$sentAs};
165
+ $result[$name] = $this->recursiveProcess(
166
+ $property,
167
+ $childNode
168
+ );
169
+ }
170
+ }
171
+ }
172
+
173
+ // Handle additional, undefined properties
174
+ $additional = $param->getAdditionalProperties();
175
+ if ($additional instanceof Parameter) {
176
+ // Process all child elements according to the given schema
177
+ foreach ($node->children($additional->getData('xmlNs'), true) as $childNode) {
178
+ $sentAs = $childNode->getName();
179
+ if (!isset($knownProps[$sentAs])) {
180
+ $result[$sentAs] = $this->recursiveProcess(
181
+ $additional,
182
+ $childNode
183
+ );
184
+ }
185
+ }
186
+ } elseif ($additional === null || $additional === true) {
187
+ // Blindly transform the XML into an array preserving as much data
188
+ // as possible. Remove processed, aliased properties.
189
+ $array = array_diff_key(static::xmlToArray($node), $knownProps);
190
+ // Remove @attributes that were explicitly plucked from the
191
+ // attributes list.
192
+ if (isset($array['@attributes']) && $knownAttributes) {
193
+ $array['@attributes'] = array_diff_key($array['@attributes'], $knownProps);
194
+ if (!$array['@attributes']) {
195
+ unset($array['@attributes']);
196
+ }
197
+ }
198
+
199
+ // Merge it together with the original result
200
+ $result = array_merge($array, $result);
201
+ }
202
+
203
+ return $result;
204
+ }
205
+
206
+ /**
207
+ * Convert an XML document to an array.
208
+ *
209
+ * @param \SimpleXMLElement $xml
210
+ * @param int $nesting
211
+ * @param null $ns
212
+ *
213
+ * @return array
214
+ */
215
+ private static function xmlToArray(
216
+ \SimpleXMLElement $xml,
217
+ $ns = null,
218
+ $nesting = 0
219
+ ) {
220
+ $result = [];
221
+ $children = $xml->children($ns, true);
222
+
223
+ foreach ($children as $name => $child) {
224
+ $attributes = (array) $child->attributes($ns, true);
225
+ if (!isset($result[$name])) {
226
+ $childArray = static::xmlToArray($child, $ns, $nesting + 1);
227
+ $result[$name] = $attributes
228
+ ? array_merge($attributes, $childArray)
229
+ : $childArray;
230
+ continue;
231
+ }
232
+ // A child element with this name exists so we're assuming
233
+ // that the node contains a list of elements
234
+ if (!is_array($result[$name])) {
235
+ $result[$name] = [$result[$name]];
236
+ }
237
+ $childArray = static::xmlToArray($child, $ns, $nesting + 1);
238
+ if ($attributes) {
239
+ $result[$name][] = array_merge($attributes, $childArray);
240
+ } else {
241
+ $result[$name][] = $childArray;
242
+ }
243
+ }
244
+
245
+ // Extract text from node
246
+ $text = trim((string) $xml);
247
+ if ($text === '') {
248
+ $text = null;
249
+ }
250
+
251
+ // Process attributes
252
+ $attributes = (array) $xml->attributes($ns, true);
253
+ if ($attributes) {
254
+ if ($text !== null) {
255
+ $result['value'] = $text;
256
+ }
257
+ $result = array_merge($attributes, $result);
258
+ } elseif ($text !== null) {
259
+ $result = $text;
260
+ }
261
+
262
+ // Make sure we're always returning an array
263
+ if ($nesting == 0 && !is_array($result)) {
264
+ $result = [$result];
265
+ }
266
+
267
+ return $result;
268
+ }
269
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/SchemaFormatter.php ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command\Guzzle;
3
+
4
+ /**
5
+ * JSON Schema formatter class
6
+ */
7
+ class SchemaFormatter
8
+ {
9
+ /**
10
+ * Format a value by a registered format name
11
+ *
12
+ * @param string $format Registered format used to format the value
13
+ * @param mixed $value Value being formatted
14
+ *
15
+ * @return mixed
16
+ */
17
+ public function format($format, $value)
18
+ {
19
+ switch ($format) {
20
+ case 'date-time':
21
+ return $this->formatDateTime($value);
22
+ case 'date-time-http':
23
+ return $this->formatDateTimeHttp($value);
24
+ case 'date':
25
+ return $this->formatDate($value);
26
+ case 'time':
27
+ return $this->formatTime($value);
28
+ case 'timestamp':
29
+ return $this->formatTimestamp($value);
30
+ case 'boolean-string':
31
+ return $this->formatBooleanAsString($value);
32
+ default:
33
+ return $value;
34
+ }
35
+ }
36
+
37
+ /**
38
+ * Perform the actual DateTime formatting
39
+ *
40
+ * @param int|string|\DateTime $dateTime Date time value
41
+ * @param string $format Format of the result
42
+ *
43
+ * @return string
44
+ * @throws \InvalidArgumentException
45
+ */
46
+ protected function dateFormatter($dateTime, $format)
47
+ {
48
+ if (is_numeric($dateTime)) {
49
+ return gmdate($format, (int) $dateTime);
50
+ }
51
+
52
+ if (is_string($dateTime)) {
53
+ $dateTime = new \DateTime($dateTime);
54
+ }
55
+
56
+ if ($dateTime instanceof \DateTime) {
57
+ static $utc;
58
+ if (!$utc) {
59
+ $utc = new \DateTimeZone('UTC');
60
+ }
61
+ return $dateTime->setTimezone($utc)->format($format);
62
+ }
63
+
64
+ throw new \InvalidArgumentException('Date/Time values must be either '
65
+ . 'be a string, integer, or DateTime object');
66
+ }
67
+
68
+ /**
69
+ * Create a ISO 8601 (YYYY-MM-DDThh:mm:ssZ) formatted date time value in
70
+ * UTC time.
71
+ *
72
+ * @param string|integer|\DateTime $value Date time value
73
+ *
74
+ * @return string
75
+ */
76
+ private function formatDateTime($value)
77
+ {
78
+ return $this->dateFormatter($value, 'Y-m-d\TH:i:s\Z');
79
+ }
80
+
81
+ /**
82
+ * Create an HTTP date (RFC 1123 / RFC 822) formatted UTC date-time string
83
+ *
84
+ * @param string|integer|\DateTime $value Date time value
85
+ *
86
+ * @return string
87
+ */
88
+ private function formatDateTimeHttp($value)
89
+ {
90
+ return $this->dateFormatter($value, 'D, d M Y H:i:s \G\M\T');
91
+ }
92
+
93
+ /**
94
+ * Create a YYYY-MM-DD formatted string
95
+ *
96
+ * @param string|integer|\DateTime $value Date time value
97
+ *
98
+ * @return string
99
+ */
100
+ private function formatDate($value)
101
+ {
102
+ return $this->dateFormatter($value, 'Y-m-d');
103
+ }
104
+
105
+ /**
106
+ * Create a hh:mm:ss formatted string
107
+ *
108
+ * @param string|integer|\DateTime $value Date time value
109
+ *
110
+ * @return string
111
+ */
112
+ private function formatTime($value)
113
+ {
114
+ return $this->dateFormatter($value, 'H:i:s');
115
+ }
116
+
117
+ /**
118
+ * Formats a boolean value as a string
119
+ *
120
+ * @param string|integer|bool $value Value to convert to a boolean
121
+ * 'true' / 'false' value
122
+ *
123
+ * @return string
124
+ */
125
+ private function formatBooleanAsString($value)
126
+ {
127
+ return filter_var($value, FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false';
128
+ }
129
+
130
+ /**
131
+ * Return a UNIX timestamp in the UTC timezone
132
+ *
133
+ * @param string|integer|\DateTime $value Time value
134
+ *
135
+ * @return int
136
+ */
137
+ private function formatTimestamp($value)
138
+ {
139
+ return (int) $this->dateFormatter($value, 'U');
140
+ }
141
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/SchemaValidator.php ADDED
@@ -0,0 +1,296 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command\Guzzle;
3
+
4
+ use GuzzleHttp\ToArrayInterface;
5
+
6
+ /**
7
+ * Default parameter validator
8
+ */
9
+ class SchemaValidator
10
+ {
11
+ /**
12
+ * Whether or not integers are converted to strings when an integer is
13
+ * received for a string input
14
+ *
15
+ * @var bool
16
+ */
17
+ protected $castIntegerToStringType;
18
+
19
+ /** @var array Errors encountered while validating */
20
+ protected $errors;
21
+
22
+ /**
23
+ * @param bool $castIntegerToStringType Set to true to convert integers
24
+ * into strings when a required type is a string and the input value is
25
+ * an integer. Defaults to true.
26
+ */
27
+ public function __construct($castIntegerToStringType = true)
28
+ {
29
+ $this->castIntegerToStringType = $castIntegerToStringType;
30
+ }
31
+
32
+ public function validate(Parameter $param, &$value)
33
+ {
34
+ $this->errors = [];
35
+ $this->recursiveProcess($param, $value);
36
+
37
+ if (empty($this->errors)) {
38
+ return true;
39
+ } else {
40
+ sort($this->errors);
41
+ return false;
42
+ }
43
+ }
44
+
45
+ /**
46
+ * Get the errors encountered while validating
47
+ *
48
+ * @return array
49
+ */
50
+ public function getErrors()
51
+ {
52
+ return $this->errors ?: [];
53
+ }
54
+
55
+ /**
56
+ * From the allowable types, determine the type that the variable matches
57
+ *
58
+ * @param string $type Parameter type
59
+ * @param mixed $value Value to determine the type
60
+ *
61
+ * @return string|bool Returns the matching type on
62
+ */
63
+ protected function determineType($type, $value)
64
+ {
65
+ foreach ((array) $type as $t) {
66
+ if ($t == 'string'
67
+ && (is_string($value) || (is_object($value) && method_exists($value, '__toString')))
68
+ ) {
69
+ return 'string';
70
+ } elseif ($t == 'object' && (is_array($value) || is_object($value))) {
71
+ return 'object';
72
+ } elseif ($t == 'array' && is_array($value)) {
73
+ return 'array';
74
+ } elseif ($t == 'integer' && is_integer($value)) {
75
+ return 'integer';
76
+ } elseif ($t == 'boolean' && is_bool($value)) {
77
+ return 'boolean';
78
+ } elseif ($t == 'number' && is_numeric($value)) {
79
+ return 'number';
80
+ } elseif ($t == 'numeric' && is_numeric($value)) {
81
+ return 'numeric';
82
+ } elseif ($t == 'null' && !$value) {
83
+ return 'null';
84
+ } elseif ($t == 'any') {
85
+ return 'any';
86
+ }
87
+ }
88
+
89
+ return false;
90
+ }
91
+
92
+ /**
93
+ * Recursively validate a parameter
94
+ *
95
+ * @param Parameter $param API parameter being validated
96
+ * @param mixed $value Value to validate and validate. The value may
97
+ * change during this validate.
98
+ * @param string $path Current validation path (used for error reporting)
99
+ * @param int $depth Current depth in the validation validate
100
+ *
101
+ * @return bool Returns true if valid, or false if invalid
102
+ */
103
+ protected function recursiveProcess(
104
+ Parameter $param,
105
+ &$value,
106
+ $path = '',
107
+ $depth = 0
108
+ ) {
109
+ // Update the value by adding default or static values
110
+ $value = $param->getValue($value);
111
+
112
+ $required = $param->getRequired();
113
+ // if the value is null and the parameter is not required or is static,
114
+ // then skip any further recursion
115
+ if ((null === $value && !$required) || $param->getStatic()) {
116
+ return true;
117
+ }
118
+
119
+ $type = $param->getType();
120
+ // Attempt to limit the number of times is_array is called by tracking
121
+ // if the value is an array
122
+ $valueIsArray = is_array($value);
123
+ // If a name is set then update the path so that validation messages
124
+ // are more helpful
125
+ if ($name = $param->getName()) {
126
+ $path .= "[{$name}]";
127
+ }
128
+
129
+ if ($type == 'object') {
130
+
131
+ // Determine whether or not this "value" has properties and should
132
+ // be traversed
133
+ $traverse = $temporaryValue = false;
134
+
135
+ // Convert the value to an array
136
+ if (!$valueIsArray && $value instanceof ToArrayInterface) {
137
+ $value = $value->toArray();
138
+ }
139
+
140
+ if ($valueIsArray) {
141
+ // Ensure that the array is associative and not numerically
142
+ // indexed
143
+ if (isset($value[0])) {
144
+ $this->errors[] = "{$path} must be an array of properties. Got a numerically indexed array.";
145
+ return false;
146
+ }
147
+ $traverse = true;
148
+ } elseif ($value === null) {
149
+ // Attempt to let the contents be built up by default values if
150
+ // possible
151
+ $value = [];
152
+ $temporaryValue = $valueIsArray = $traverse = true;
153
+ }
154
+
155
+ if ($traverse) {
156
+
157
+ if ($properties = $param->getProperties()) {
158
+ // if properties were found, validate each property
159
+ foreach ($properties as $property) {
160
+ $name = $property->getName();
161
+ if (isset($value[$name])) {
162
+ $this->recursiveProcess($property, $value[$name], $path, $depth + 1);
163
+ } else {
164
+ $current = null;
165
+ $this->recursiveProcess($property, $current, $path, $depth + 1);
166
+ // Only set the value if it was populated
167
+ if (null !== $current) {
168
+ $value[$name] = $current;
169
+ }
170
+ }
171
+ }
172
+ }
173
+
174
+ $additional = $param->getAdditionalProperties();
175
+ if ($additional !== true) {
176
+ // If additional properties were found, then validate each
177
+ // against the additionalProperties attr.
178
+ $keys = array_keys($value);
179
+ // Determine the keys that were specified that were not
180
+ // listed in the properties of the schema
181
+ $diff = array_diff($keys, array_keys($properties));
182
+ if (!empty($diff)) {
183
+ // Determine which keys are not in the properties
184
+ if ($additional instanceOf Parameter) {
185
+ foreach ($diff as $key) {
186
+ $this->recursiveProcess($additional, $value[$key], "{$path}[{$key}]", $depth);
187
+ }
188
+ } else {
189
+ // if additionalProperties is set to false and there
190
+ // are additionalProperties in the values, then fail
191
+ foreach ($diff as $prop) {
192
+ $this->errors[] = sprintf('%s[%s] is not an allowed property', $path, $prop);
193
+ }
194
+ }
195
+ }
196
+ }
197
+
198
+ // A temporary value will be used to traverse elements that
199
+ // have no corresponding input value. This allows nested
200
+ // required parameters with default values to bubble up into the
201
+ // input. Here we check if we used a temp value and nothing
202
+ // bubbled up, then we need to remote the value.
203
+ if ($temporaryValue && empty($value)) {
204
+ $value = null;
205
+ $valueIsArray = false;
206
+ }
207
+ }
208
+
209
+ } elseif ($type == 'array' && $valueIsArray && $param->getItems()) {
210
+ foreach ($value as $i => &$item) {
211
+ // Validate each item in an array against the items attribute of the schema
212
+ $this->recursiveProcess($param->getItems(), $item, $path . "[{$i}]", $depth + 1);
213
+ }
214
+ }
215
+
216
+ // If the value is required and the type is not null, then there is an
217
+ // error if the value is not set
218
+ if ($required && $value === null && $type != 'null') {
219
+ $message = "{$path} is " . ($param->getType()
220
+ ? ('a required ' . implode(' or ', (array) $param->getType()))
221
+ : 'required');
222
+ if ($param->getDescription()) {
223
+ $message .= ': ' . $param->getDescription();
224
+ }
225
+ $this->errors[] = $message;
226
+ return false;
227
+ }
228
+
229
+ // Validate that the type is correct. If the type is string but an
230
+ // integer was passed, the class can be instructed to cast the integer
231
+ // to a string to pass validation. This is the default behavior.
232
+ if ($type && (!$type = $this->determineType($type, $value))) {
233
+ if ($this->castIntegerToStringType
234
+ && $param->getType() == 'string'
235
+ && is_integer($value)
236
+ ) {
237
+ $value = (string) $value;
238
+ } else {
239
+ $this->errors[] = "{$path} must be of type " . implode(' or ', (array) $param->getType());
240
+ }
241
+ }
242
+
243
+ // Perform type specific validation for strings, arrays, and integers
244
+ if ($type == 'string') {
245
+
246
+ // Strings can have enums which are a list of predefined values
247
+ if (($enum = $param->getEnum()) && !in_array($value, $enum)) {
248
+ $this->errors[] = "{$path} must be one of " . implode(' or ', array_map(function ($s) {
249
+ return '"' . addslashes($s) . '"';
250
+ }, $enum));
251
+ }
252
+ // Strings can have a regex pattern that the value must match
253
+ if (($pattern = $param->getPattern()) && !preg_match($pattern, $value)) {
254
+ $this->errors[] = "{$path} must match the following regular expression: {$pattern}";
255
+ }
256
+
257
+ $strLen = null;
258
+ if ($min = $param->getMinLength()) {
259
+ $strLen = strlen($value);
260
+ if ($strLen < $min) {
261
+ $this->errors[] = "{$path} length must be greater than or equal to {$min}";
262
+ }
263
+ }
264
+ if ($max = $param->getMaxLength()) {
265
+ if (($strLen ?: strlen($value)) > $max) {
266
+ $this->errors[] = "{$path} length must be less than or equal to {$max}";
267
+ }
268
+ }
269
+
270
+ } elseif ($type == 'array') {
271
+
272
+ $size = null;
273
+ if ($min = $param->getMinItems()) {
274
+ $size = count($value);
275
+ if ($size < $min) {
276
+ $this->errors[] = "{$path} must contain {$min} or more elements";
277
+ }
278
+ }
279
+ if ($max = $param->getMaxItems()) {
280
+ if (($size ?: count($value)) > $max) {
281
+ $this->errors[] = "{$path} must contain {$max} or fewer elements";
282
+ }
283
+ }
284
+
285
+ } elseif ($type == 'integer' || $type == 'number' || $type == 'numeric') {
286
+ if (($min = $param->getMinimum()) && $value < $min) {
287
+ $this->errors[] = "{$path} must be greater than or equal to {$min}";
288
+ }
289
+ if (($max = $param->getMaximum()) && $value > $max) {
290
+ $this->errors[] = "{$path} must be less than or equal to {$max}";
291
+ }
292
+ }
293
+
294
+ return empty($this->errors);
295
+ }
296
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/Serializer.php ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command\Guzzle;
3
+
4
+ use GuzzleHttp\Command\ServiceClientInterface;
5
+ use GuzzleHttp\Command\CommandInterface;
6
+ use GuzzleHttp\Command\CommandTransaction;
7
+ use GuzzleHttp\Message\RequestInterface;
8
+ use GuzzleHttp\Command\Guzzle\RequestLocation\BodyLocation;
9
+ use GuzzleHttp\Command\Guzzle\RequestLocation\HeaderLocation;
10
+ use GuzzleHttp\Command\Guzzle\RequestLocation\JsonLocation;
11
+ use GuzzleHttp\Command\Guzzle\RequestLocation\PostFieldLocation;
12
+ use GuzzleHttp\Command\Guzzle\RequestLocation\PostFileLocation;
13
+ use GuzzleHttp\Command\Guzzle\RequestLocation\QueryLocation;
14
+ use GuzzleHttp\Command\Guzzle\RequestLocation\XmlLocation;
15
+ use GuzzleHttp\Command\Guzzle\RequestLocation\RequestLocationInterface;
16
+ use GuzzleHttp\Utils;
17
+
18
+ /**
19
+ * Serializes requests for a given command.
20
+ */
21
+ class Serializer
22
+ {
23
+ /** @var RequestLocationInterface[] */
24
+ private $requestLocations;
25
+
26
+ /** @var DescriptionInterface */
27
+ private $description;
28
+
29
+ /**
30
+ * @param DescriptionInterface $description
31
+ * @param RequestLocationInterface[] $requestLocations Extra request locations
32
+ */
33
+ public function __construct(
34
+ DescriptionInterface $description,
35
+ array $requestLocations = []
36
+ ) {
37
+ static $defaultRequestLocations;
38
+ if (!$defaultRequestLocations) {
39
+ $defaultRequestLocations = [
40
+ 'body' => new BodyLocation('body'),
41
+ 'query' => new QueryLocation('query'),
42
+ 'header' => new HeaderLocation('header'),
43
+ 'json' => new JsonLocation('json'),
44
+ 'xml' => new XmlLocation('xml'),
45
+ 'postField' => new PostFieldLocation('postField'),
46
+ 'postFile' => new PostFileLocation('postFile')
47
+ ];
48
+ }
49
+
50
+ $this->requestLocations = $requestLocations + $defaultRequestLocations;
51
+ $this->description = $description;
52
+ }
53
+
54
+ public function __invoke(CommandTransaction $trans)
55
+ {
56
+ $request = $this->createRequest($trans);
57
+ $this->prepareRequest($trans, $request);
58
+
59
+ return $request;
60
+ }
61
+
62
+ /**
63
+ * Prepares a request for sending using location visitors
64
+ *
65
+ * @param CommandTransaction $trans
66
+ * @param RequestInterface $request Request being created
67
+ * @throws \RuntimeException If a location cannot be handled
68
+ */
69
+ protected function prepareRequest(
70
+ CommandTransaction $trans,
71
+ RequestInterface $request
72
+ ) {
73
+ $visitedLocations = [];
74
+ $context = ['client' => $trans->client, 'command' => $trans->command];
75
+ $operation = $this->description->getOperation($trans->command->getName());
76
+
77
+ // Visit each actual parameter
78
+ foreach ($operation->getParams() as $name => $param) {
79
+ /* @var Parameter $param */
80
+ $location = $param->getLocation();
81
+ // Skip parameters that have not been set or are URI location
82
+ if ($location == 'uri' || !$trans->command->hasParam($name)) {
83
+ continue;
84
+ }
85
+ if (!isset($this->requestLocations[$location])) {
86
+ throw new \RuntimeException("No location registered for $location");
87
+ }
88
+ $visitedLocations[$location] = true;
89
+ $this->requestLocations[$location]->visit(
90
+ $trans->command,
91
+ $request,
92
+ $param,
93
+ $context
94
+ );
95
+ }
96
+
97
+ // Ensure that the after() method is invoked for additionalParameters
98
+ if ($additional = $operation->getAdditionalParameters()) {
99
+ $visitedLocations[$additional->getLocation()] = true;
100
+ }
101
+
102
+ // Call the after() method for each visited location
103
+ foreach (array_keys($visitedLocations) as $location) {
104
+ $this->requestLocations[$location]->after(
105
+ $trans->command,
106
+ $request,
107
+ $operation,
108
+ $context
109
+ );
110
+ }
111
+ }
112
+
113
+ /**
114
+ * Create a request for the command and operation
115
+ *
116
+ * @param CommandTransaction $trans
117
+ *
118
+ * @return RequestInterface
119
+ * @throws \RuntimeException
120
+ */
121
+ protected function createRequest(CommandTransaction $trans)
122
+ {
123
+ $operation = $this->description->getOperation($trans->command->getName());
124
+
125
+ // If the command does not specify a template, then assume the base URL
126
+ // of the client
127
+ if (null === ($uri = $operation->getUri())) {
128
+ return $trans->client->createRequest(
129
+ $operation->getHttpMethod(),
130
+ $this->description->getBaseUrl(),
131
+ $trans->command['request_options'] ?: []
132
+ );
133
+ }
134
+
135
+ return $this->createCommandWithUri(
136
+ $operation, $trans->command, $trans->serviceClient
137
+ );
138
+ }
139
+
140
+ /**
141
+ * Create a request for an operation with a uri merged onto a base URI
142
+ */
143
+ private function createCommandWithUri(
144
+ Operation $operation,
145
+ CommandInterface $command,
146
+ ServiceClientInterface $client
147
+ ) {
148
+ // Get the path values and use the client config settings
149
+ $variables = [];
150
+ foreach ($operation->getParams() as $name => $arg) {
151
+ /* @var Parameter $arg */
152
+ if ($arg->getLocation() == 'uri') {
153
+ if (isset($command[$name])) {
154
+ $variables[$name] = $arg->filter($command[$name]);
155
+ if (!is_array($variables[$name])) {
156
+ $variables[$name] = (string) $variables[$name];
157
+ }
158
+ }
159
+ }
160
+ }
161
+
162
+ // Expand the URI template.
163
+ $uri = Utils::uriTemplate($operation->getUri(), $variables);
164
+
165
+ return $client->getHttpClient()->createRequest(
166
+ $operation->getHttpMethod(),
167
+ $this->description->getBaseUrl()->combine($uri),
168
+ $command['request_options'] ?: []
169
+ );
170
+ }
171
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/Subscriber/ProcessResponse.php ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command\Guzzle\Subscriber;
3
+
4
+ use GuzzleHttp\Command\Guzzle\DescriptionInterface;
5
+ use GuzzleHttp\Event\SubscriberInterface;
6
+ use GuzzleHttp\Message\ResponseInterface;
7
+ use GuzzleHttp\Command\Guzzle\Parameter;
8
+ use GuzzleHttp\Command\CommandInterface;
9
+ use GuzzleHttp\Command\Guzzle\ResponseLocation\JsonLocation;
10
+ use GuzzleHttp\Command\Event\ProcessEvent;
11
+ use GuzzleHttp\Command\Guzzle\ResponseLocation\ResponseLocationInterface;
12
+ use GuzzleHttp\Command\Guzzle\ResponseLocation\BodyLocation;
13
+ use GuzzleHttp\Command\Guzzle\ResponseLocation\StatusCodeLocation;
14
+ use GuzzleHttp\Command\Guzzle\ResponseLocation\ReasonPhraseLocation;
15
+ use GuzzleHttp\Command\Guzzle\ResponseLocation\HeaderLocation;
16
+ use GuzzleHttp\Command\Guzzle\ResponseLocation\XmlLocation;
17
+
18
+ /**
19
+ * Subscriber used to create response models based on an HTTP response and
20
+ * a service description.
21
+ *
22
+ * Response location visitors are registered with this subscriber to handle
23
+ * locations (e.g., 'xml', 'json', 'header'). All of the locations of a response
24
+ * model that will be visited first have their ``before`` method triggered.
25
+ * After the before method is called on every visitor that will be walked, each
26
+ * visitor is triggered using the ``visit()`` method. After all of the visitors
27
+ * are visited, the ``after()`` method is called on each visitor. This is the
28
+ * place in which you should handle things like additionalProperties with
29
+ * custom locations (i.e., this is how it is handled in the JSON visitor).
30
+ */
31
+ class ProcessResponse implements SubscriberInterface
32
+ {
33
+ /** @var ResponseLocationInterface[] */
34
+ private $responseLocations;
35
+
36
+ /** @var DescriptionInterface */
37
+ private $description;
38
+
39
+ /**
40
+ * @param DescriptionInterface $description
41
+ * @param ResponseLocationInterface[] $responseLocations Extra response locations
42
+ */
43
+ public function __construct(
44
+ DescriptionInterface $description,
45
+ array $responseLocations = []
46
+ ) {
47
+ static $defaultResponseLocations;
48
+ if (!$defaultResponseLocations) {
49
+ $defaultResponseLocations = [
50
+ 'body' => new BodyLocation('body'),
51
+ 'header' => new HeaderLocation('header'),
52
+ 'reasonPhrase' => new ReasonPhraseLocation('reasonPhrase'),
53
+ 'statusCode' => new StatusCodeLocation('statusCode'),
54
+ 'xml' => new XmlLocation('xml'),
55
+ 'json' => new JsonLocation('json')
56
+ ];
57
+ }
58
+
59
+ $this->responseLocations = $responseLocations + $defaultResponseLocations;
60
+ $this->description = $description;
61
+ }
62
+
63
+ public function getEvents()
64
+ {
65
+ return ['process' => ['onProcess']];
66
+ }
67
+
68
+ public function onProcess(ProcessEvent $event)
69
+ {
70
+ // Only add a result object if no exception was encountered.
71
+ if ($event->getException()) {
72
+ return;
73
+ }
74
+
75
+ $command = $event->getCommand();
76
+
77
+ // Do not overwrite a previous result
78
+ if ($event->getResult()) {
79
+ return;
80
+ }
81
+
82
+ $operation = $this->description->getOperation($command->getName());
83
+
84
+ // Add a default Model as the result if no matching schema was found.
85
+ if (!($modelName = $operation->getResponseModel())) {
86
+ $event->setResult([]);
87
+ return;
88
+ }
89
+
90
+ $model = $operation->getServiceDescription()->getModel($modelName);
91
+ if (!$model) {
92
+ throw new \RuntimeException("Unknown model: {$modelName}");
93
+ }
94
+
95
+ $event->setResult($this->visit($model, $event));
96
+ }
97
+
98
+ protected function visit(Parameter $model, ProcessEvent $event)
99
+ {
100
+ $result = [];
101
+ $context = ['client' => $event->getClient(), 'visitors' => []];
102
+ $command = $event->getCommand();
103
+ $response = $event->getResponse();
104
+
105
+ if ($model->getType() == 'object') {
106
+ $this->visitOuterObject($model, $result, $command, $response, $context);
107
+ } elseif ($model->getType() == 'array') {
108
+ $this->visitOuterArray($model, $result, $command, $response, $context);
109
+ } else {
110
+ throw new \InvalidArgumentException('Invalid response model: ' . $model->getType());
111
+ }
112
+
113
+ // Call the after() method of each found visitor
114
+ foreach ($context['visitors'] as $visitor) {
115
+ $visitor->after($command, $response, $model, $result, $context);
116
+ }
117
+
118
+ return $result;
119
+ }
120
+
121
+ private function triggerBeforeVisitor(
122
+ $location,
123
+ Parameter $model,
124
+ array &$result,
125
+ CommandInterface $command,
126
+ ResponseInterface $response,
127
+ array &$context
128
+ ) {
129
+ if (!isset($this->responseLocations[$location])) {
130
+ throw new \RuntimeException("Unknown location: $location");
131
+ }
132
+
133
+ $context['visitors'][$location] = $this->responseLocations[$location];
134
+
135
+ $this->responseLocations[$location]->before(
136
+ $command,
137
+ $response,
138
+ $model,
139
+ $result,
140
+ $context
141
+ );
142
+ }
143
+
144
+ private function visitOuterObject(
145
+ Parameter $model,
146
+ array &$result,
147
+ CommandInterface $command,
148
+ ResponseInterface $response,
149
+ array &$context
150
+ ) {
151
+ $parentLocation = $model->getLocation();
152
+
153
+ // If top-level additionalProperties is a schema, then visit it
154
+ $additional = $model->getAdditionalProperties();
155
+ if ($additional instanceof Parameter) {
156
+ // Use the model location if none set on additionalProperties.
157
+ $location = $additional->getLocation() ?: $parentLocation;
158
+ $this->triggerBeforeVisitor(
159
+ $location, $model, $result, $command, $response, $context
160
+ );
161
+ }
162
+
163
+ // Use 'location' from all individual defined properties, but fall back
164
+ // to the model location if no per-property location is set. Collect
165
+ // the properties that need to be visited into an array.
166
+ $visitProperties = [];
167
+ foreach ($model->getProperties() as $schema) {
168
+ $location = $schema->getLocation() ?: $parentLocation;
169
+ if ($location) {
170
+ $visitProperties[] = [$location, $schema];
171
+ // Trigger the before method on each unique visitor location
172
+ if (!isset($context['visitors'][$location])) {
173
+ $this->triggerBeforeVisitor(
174
+ $location, $model, $result, $command, $response, $context
175
+ );
176
+ }
177
+ }
178
+ }
179
+
180
+ // Actually visit each response element
181
+ foreach ($visitProperties as $prop) {
182
+ $this->responseLocations[$prop[0]]->visit(
183
+ $command, $response, $prop[1], $result, $context
184
+ );
185
+ }
186
+ }
187
+
188
+ private function visitOuterArray(
189
+ Parameter $model,
190
+ array &$result,
191
+ CommandInterface $command,
192
+ ResponseInterface $response,
193
+ array &$context
194
+ ) {
195
+ // Use 'location' defined on the top of the model
196
+ if (!($location = $model->getLocation())) {
197
+ return;
198
+ }
199
+
200
+ if (!isset($foundVisitors[$location])) {
201
+ $this->triggerBeforeVisitor(
202
+ $location, $model, $result, $command, $response, $context
203
+ );
204
+ }
205
+
206
+ // Visit each item in the response
207
+ $this->responseLocations[$location]->visit(
208
+ $command, $response, $model, $result, $context
209
+ );
210
+ }
211
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/src/Subscriber/ValidateInput.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Command\Guzzle\Subscriber;
3
+
4
+ use GuzzleHttp\Command\Guzzle\DescriptionInterface;
5
+ use GuzzleHttp\Event\SubscriberInterface;
6
+ use GuzzleHttp\Command\Exception\CommandException;
7
+ use GuzzleHttp\Command\Guzzle\SchemaValidator;
8
+ use GuzzleHttp\Command\Event\InitEvent;
9
+
10
+ /**
11
+ * Subscriber used to validate command input against a service description.
12
+ */
13
+ class ValidateInput implements SubscriberInterface
14
+ {
15
+ /** @var SchemaValidator */
16
+ private $validator;
17
+
18
+ /** @var DescriptionInterface */
19
+ private $description;
20
+
21
+ public function __construct(
22
+ DescriptionInterface $description,
23
+ SchemaValidator $schemaValidator = null
24
+ ) {
25
+ $this->description = $description;
26
+ $this->validator = $schemaValidator ?: new SchemaValidator();
27
+ }
28
+
29
+ public function getEvents()
30
+ {
31
+ return ['init' => ['onInit']];
32
+ }
33
+
34
+ public function onInit(InitEvent $event)
35
+ {
36
+ $command = $event->getCommand();
37
+ $errors = [];
38
+ $operation = $this->description->getOperation($command->getName());
39
+
40
+ foreach ($operation->getParams() as $name => $schema) {
41
+ $value = $command[$name];
42
+ if (!$this->validator->validate($schema, $value)) {
43
+ $errors = array_merge($errors, $this->validator->getErrors());
44
+ } elseif ($value !== $command[$name]) {
45
+ // Update the config value if it changed and no validation
46
+ // errors were encountered
47
+ $command[$name] = $value;
48
+ }
49
+ }
50
+
51
+ if ($params = $operation->getAdditionalParameters()) {
52
+ foreach ($command->toArray() as $name => $value) {
53
+ // It's only additional if it isn't defined in the schema
54
+ if (!$operation->hasParam($name)) {
55
+ // Always set the name so that error messages are useful
56
+ $params->setName($name);
57
+ if (!$this->validator->validate($params, $value)) {
58
+ $errors = array_merge(
59
+ $errors,
60
+ $this->validator->getErrors()
61
+ );
62
+ } elseif ($value !== $command[$name]) {
63
+ $command[$name] = $value;
64
+ }
65
+ }
66
+ }
67
+ }
68
+
69
+ if ($errors) {
70
+ throw new CommandException(
71
+ 'Validation errors: ' . implode("\n", $errors),
72
+ $event->getTransaction()
73
+ );
74
+ }
75
+ }
76
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/DescriptionTest.php ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Command\Guzzle;
3
+
4
+ use GuzzleHttp\Command\Guzzle\Description;
5
+
6
+ /**
7
+ * @covers GuzzleHttp\Command\Guzzle\Description
8
+ */
9
+ class DescriptionTest extends \PHPUnit_Framework_TestCase
10
+ {
11
+ protected $operations;
12
+
13
+ public function setup()
14
+ {
15
+ $this->operations = array(
16
+ 'test_command' => [
17
+ 'name' => 'test_command',
18
+ 'description' => 'documentationForCommand',
19
+ 'httpMethod' => 'DELETE',
20
+ 'class' => 'Guzzle\\Tests\\Service\\Mock\\Command\\MockCommand',
21
+ 'parameters' => array(
22
+ 'bucket' => array('required' => true),
23
+ 'key' => array('required' => true)
24
+ )
25
+ ]
26
+ );
27
+ }
28
+
29
+ public function testConstructor()
30
+ {
31
+ $service = new Description(['operations' => $this->operations]);
32
+ $this->assertEquals(1, count($service->getOperations()));
33
+ $this->assertFalse($service->hasOperation('foobar'));
34
+ $this->assertTrue($service->hasOperation('test_command'));
35
+ }
36
+
37
+ public function testContainsModels()
38
+ {
39
+ $d = new Description([
40
+ 'operations' => ['foo' => []],
41
+ 'models' => [
42
+ 'Tag' => ['type' => 'object'],
43
+ 'Person' => ['type' => 'object']
44
+ ]
45
+ ]);
46
+ $this->assertTrue($d->hasModel('Tag'));
47
+ $this->assertTrue($d->hasModel('Person'));
48
+ $this->assertFalse($d->hasModel('Foo'));
49
+ $this->assertInstanceOf('GuzzleHttp\Command\Guzzle\Parameter', $d->getModel('Tag'));
50
+ $this->assertEquals(['Tag', 'Person'], array_keys($d->getModels()));
51
+ }
52
+
53
+ public function testCanUseResponseClass()
54
+ {
55
+ $d = new Description([
56
+ 'operations' => [
57
+ 'foo' => ['responseClass' => 'Tag']
58
+ ],
59
+ 'models' => ['Tag' => ['type' => 'object']]
60
+ ]);
61
+ $op = $d->getOperation('foo');
62
+ $this->assertNotNull($op->getResponseModel());
63
+ }
64
+
65
+ /**
66
+ * @expectedException \InvalidArgumentException
67
+ */
68
+ public function testRetrievingMissingModelThrowsException()
69
+ {
70
+ $d = new Description([]);
71
+ $d->getModel('foo');
72
+ }
73
+
74
+ public function testHasAttributes()
75
+ {
76
+ $d = new Description(array(
77
+ 'operations' => array(),
78
+ 'name' => 'Name',
79
+ 'description' => 'Description',
80
+ 'apiVersion' => '1.24'
81
+ ));
82
+
83
+ $this->assertEquals('Name', $d->getName());
84
+ $this->assertEquals('Description', $d->getDescription());
85
+ $this->assertEquals('1.24', $d->getApiVersion());
86
+ }
87
+
88
+ public function testPersistsCustomAttributes()
89
+ {
90
+ $data = [
91
+ 'operations' => ['foo' => ['class' => 'foo', 'parameters' => []]],
92
+ 'name' => 'Name',
93
+ 'description' => 'Test',
94
+ 'apiVersion' => '1.24',
95
+ 'auth' => 'foo',
96
+ 'keyParam' => 'bar'
97
+ ];
98
+ $d = new Description($data);
99
+ $this->assertEquals('foo', $d->getData('auth'));
100
+ $this->assertEquals('bar', $d->getData('keyParam'));
101
+ $this->assertEquals(['auth' => 'foo', 'keyParam' => 'bar'], $d->getData());
102
+ $this->assertNull($d->getData('missing'));
103
+ }
104
+
105
+ /**
106
+ * @expectedException \InvalidArgumentException
107
+ */
108
+ public function testThrowsExceptionForMissingOperation()
109
+ {
110
+ $s = new Description([]);
111
+ $this->assertNull($s->getOperation('foo'));
112
+ }
113
+
114
+ /**
115
+ * @expectedException \InvalidArgumentException
116
+ */
117
+ public function testValidatesOperationTypes()
118
+ {
119
+ $s = new Description(array(
120
+ 'operations' => array('foo' => new \stdClass())
121
+ ));
122
+ }
123
+
124
+ public function testHasBaseUrl()
125
+ {
126
+ $description = new Description(['baseUrl' => 'http://foo.com']);
127
+ $this->assertEquals('http://foo.com', $description->getBaseUrl());
128
+ }
129
+
130
+ public function testModelsHaveNames()
131
+ {
132
+ $desc = [
133
+ 'models' => [
134
+ 'date' => ['type' => 'string'],
135
+ 'user'=> [
136
+ 'type' => 'object',
137
+ 'properties' => [
138
+ 'dob' => ['$ref' => 'date']
139
+ ]
140
+ ]
141
+ ]
142
+ ];
143
+
144
+ $s = new Description($desc);
145
+ $this->assertEquals('string', $s->getModel('date')->getType());
146
+ $this->assertEquals('dob', $s->getModel('user')->getProperty('dob')->getName());
147
+ }
148
+
149
+ public function testHasOperations()
150
+ {
151
+ $desc = ['operations' => ['foo' => ['parameters' => ['foo' => [
152
+ 'name' => 'foo'
153
+ ]]]]];
154
+ $s = new Description($desc);
155
+ $this->assertInstanceOf('GuzzleHttp\\Command\\Guzzle\\Operation', $s->getOperation('foo'));
156
+ $this->assertSame($s->getOperation('foo'), $s->getOperation('foo'));
157
+ }
158
+
159
+ public function testHasFormatter()
160
+ {
161
+ $s = new Description([]);
162
+ $this->assertNotEmpty($s->format('date', 'now'));
163
+ }
164
+
165
+ public function testCanUseCustomFormatter()
166
+ {
167
+ $formatter = $this->getMockBuilder('GuzzleHttp\\Common\\Guzzle\\SchemaFormatter')
168
+ ->setMethods(['format'])
169
+ ->getMock();
170
+ $formatter->expects($this->once())
171
+ ->method('format');
172
+ $s = new Description([], ['formatter' => $formatter]);
173
+ $s->format('time', 'now');
174
+ }
175
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/GuzzleClientTest.php ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Command\Guzzle;
3
+
4
+ use GuzzleHttp\Client;
5
+ use GuzzleHttp\Message\Response;
6
+ use GuzzleHttp\Command\Guzzle\Description;
7
+ use GuzzleHttp\Command\Guzzle\GuzzleClient;
8
+ use GuzzleHttp\Event\BeforeEvent;
9
+
10
+ /**
11
+ * @covers \GuzzleHttp\Command\Guzzle\GuzzleClient
12
+ */
13
+ class GuzzleClientTest extends \PHPUnit_Framework_TestCase
14
+ {
15
+ public function testHasConfig()
16
+ {
17
+ $client = new Client();
18
+ $description = new Description([]);
19
+ $guzzle = new GuzzleClient($client, $description, [
20
+ 'foo' => 'bar',
21
+ 'baz' => ['bam' => 'boo']
22
+ ]);
23
+ $this->assertSame($client, $guzzle->getHttpClient());
24
+ $this->assertSame($description, $guzzle->getDescription());
25
+ $this->assertEquals('bar', $guzzle->getConfig('foo'));
26
+ $this->assertEquals('boo', $guzzle->getConfig('baz/bam'));
27
+ $this->assertEquals([], $guzzle->getConfig('defaults'));
28
+ $guzzle->setConfig('abc/123', 'listen');
29
+ $this->assertEquals('listen', $guzzle->getConfig('abc/123'));
30
+ $this->assertCount(1, $guzzle->getEmitter()->listeners('process'));
31
+ }
32
+
33
+ public function testAddsSubscribersWhenTrue()
34
+ {
35
+ $client = new Client();
36
+ $description = new Description([]);
37
+ $guzzle = new GuzzleClient($client, $description, [
38
+ 'validate' => true,
39
+ 'process' => true
40
+ ]);
41
+ $this->assertCount(1, $guzzle->getEmitter()->listeners('process'));
42
+ }
43
+
44
+ public function testDisablesSubscribersWhenFalse()
45
+ {
46
+ $client = new Client();
47
+ $description = new Description([]);
48
+ $guzzle = new GuzzleClient($client, $description, [
49
+ 'validate' => false,
50
+ 'process' => false
51
+ ]);
52
+ $this->assertCount(0, $guzzle->getEmitter()->listeners('process'));
53
+ }
54
+
55
+ public function testCanUseCustomConfigFactory()
56
+ {
57
+ $mock = $this->getMockBuilder('GuzzleHttp\\Command\\Command')
58
+ ->disableOriginalConstructor()
59
+ ->getMock();
60
+ $client = new Client();
61
+ $description = new Description([]);
62
+ $guzzle = new GuzzleClient($client, $description, [
63
+ 'command_factory' => function () use ($mock) {
64
+ $this->assertCount(3, func_get_args());
65
+ return $mock;
66
+ }
67
+ ]);
68
+ $this->assertSame($mock, $guzzle->getCommand('foo'));
69
+ }
70
+
71
+ public function testMagicMethodExecutesCommands()
72
+ {
73
+ $mock = $this->getMockBuilder('GuzzleHttp\\Command\\Command')
74
+ ->setConstructorArgs(['foo'])
75
+ ->getMock();
76
+ $client = new Client();
77
+ $description = new Description([]);
78
+ $guzzle = $this->getMockBuilder('GuzzleHttp\\Command\\Guzzle\\GuzzleClient')
79
+ ->setConstructorArgs([
80
+ $client, $description, [
81
+ 'command_factory' => function ($name) use ($mock) {
82
+ $this->assertEquals('foo', $name);
83
+ $this->assertCount(3, func_get_args());
84
+ return $mock;
85
+ }
86
+ ]
87
+ ])
88
+ ->setMethods(['execute'])
89
+ ->getMock();
90
+ $guzzle->expects($this->once())
91
+ ->method('execute')
92
+ ->will($this->returnValue('foo'));
93
+
94
+ $this->assertEquals('foo', $guzzle->foo([]));
95
+ }
96
+
97
+ /**
98
+ * @expectedException \InvalidArgumentException
99
+ * @expectedExceptionMessage No operation found named foo
100
+ */
101
+ public function testThrowsWhenFactoryReturnsNull()
102
+ {
103
+ $client = new Client();
104
+ $description = new Description([]);
105
+ $guzzle = new GuzzleClient($client, $description);
106
+ $guzzle->getCommand('foo');
107
+ }
108
+
109
+ public function testDefaultFactoryChecksWithUppercaseToo()
110
+ {
111
+ $description = new Description([
112
+ 'operations' => ['Foo' => [], 'bar' => []]
113
+ ]);
114
+ $c = new GuzzleClient(new Client(), $description);
115
+ $f = GuzzleClient::defaultCommandFactory($description);
116
+ $command1 = $f('foo', [], $c);
117
+ $this->assertInstanceOf('GuzzleHttp\\Command\\Command', $command1);
118
+ $this->assertEquals('Foo', $command1->getName());
119
+ $command2 = $f('Foo', [], $c);
120
+ $this->assertInstanceOf('GuzzleHttp\\Command\\Command', $command2);
121
+ $this->assertEquals('Foo', $command2->getName());
122
+ }
123
+
124
+ public function testReturnsProcessedResponse()
125
+ {
126
+ $client = new Client();
127
+ $client->getEmitter()->on('before', function (BeforeEvent $event) {
128
+ $event->intercept(new Response(201));
129
+ });
130
+ $description = new Description([
131
+ 'operations' => [
132
+ 'Foo' => ['responseModel' => 'Bar']
133
+ ],
134
+ 'models' => [
135
+ 'Bar' => [
136
+ 'type' => 'object',
137
+ 'properties' => [
138
+ 'code' => ['location' => 'statusCode']
139
+ ]
140
+ ]
141
+ ]
142
+ ]);
143
+ $guzzle = new GuzzleClient($client, $description);
144
+ $command = $guzzle->getCommand('foo');
145
+ $result = $guzzle->execute($command);
146
+ $this->assertInternalType('array', $result);
147
+ $this->assertEquals(201, $result['code']);
148
+ }
149
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/OperationTest.php ADDED
@@ -0,0 +1,224 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Guzzle\Tests\Service\Description;
3
+
4
+ use GuzzleHttp\Command\Guzzle\Operation;
5
+ use GuzzleHttp\Command\Guzzle\Description;
6
+
7
+ /**
8
+ * @covers \GuzzleHttp\Command\Guzzle\Operation
9
+ */
10
+ class OperationTest extends \PHPUnit_Framework_TestCase
11
+ {
12
+ public static function strtoupper($string)
13
+ {
14
+ return strtoupper($string);
15
+ }
16
+
17
+ public function testOperationIsDataObject()
18
+ {
19
+ $description = new Description([]);
20
+ $c = new Operation(array(
21
+ 'name' => 'test',
22
+ 'summary' => 'doc',
23
+ 'notes' => 'notes',
24
+ 'documentationUrl' => 'http://www.example.com',
25
+ 'httpMethod' => 'POST',
26
+ 'uri' => '/api/v1',
27
+ 'responseModel' => 'abc',
28
+ 'deprecated' => true,
29
+ 'parameters' => array(
30
+ 'key' => array(
31
+ 'required' => true,
32
+ 'type' => 'string',
33
+ 'maxLength' => 10,
34
+ 'name' => 'key'
35
+ ),
36
+ 'key_2' => array(
37
+ 'required' => true,
38
+ 'type' => 'integer',
39
+ 'default' => 10,
40
+ 'name' => 'key_2'
41
+ )
42
+ )
43
+ ), $description);
44
+
45
+ $this->assertEquals('test', $c->getName());
46
+ $this->assertEquals('doc', $c->getSummary());
47
+ $this->assertEquals('http://www.example.com', $c->getDocumentationUrl());
48
+ $this->assertEquals('POST', $c->getHttpMethod());
49
+ $this->assertEquals('/api/v1', $c->getUri());
50
+ $this->assertEquals('abc', $c->getResponseModel());
51
+ $this->assertTrue($c->getDeprecated());
52
+
53
+ $params = array_map(function ($c) {
54
+ return $c->toArray();
55
+ }, $c->getParams());
56
+
57
+ $this->assertEquals([
58
+ 'key' => [
59
+ 'required' => true,
60
+ 'type' => 'string',
61
+ 'maxLength' => 10,
62
+ 'name' => 'key'
63
+ ],
64
+ 'key_2' => [
65
+ 'required' => true,
66
+ 'type' => 'integer',
67
+ 'default' => 10,
68
+ 'name' => 'key_2'
69
+ ]
70
+ ], $params);
71
+
72
+ $this->assertEquals([
73
+ 'required' => true,
74
+ 'type' => 'integer',
75
+ 'default' => 10,
76
+ 'name' => 'key_2'
77
+ ], $c->getParam('key_2')->toArray());
78
+
79
+ $this->assertNull($c->getParam('afefwef'));
80
+ $this->assertArrayNotHasKey('parent', $c->getParam('key_2')->toArray());
81
+ }
82
+
83
+ public function testDeterminesIfHasParam()
84
+ {
85
+ $command = $this->getTestCommand();
86
+ $this->assertTrue($command->hasParam('data'));
87
+ $this->assertFalse($command->hasParam('baz'));
88
+ }
89
+
90
+ protected function getTestCommand()
91
+ {
92
+ return new Operation([
93
+ 'parameters' => [
94
+ 'data' => ['type' => 'string']
95
+ ]
96
+ ], new Description([]));
97
+ }
98
+
99
+ public function testAddsNameToParametersIfNeeded()
100
+ {
101
+ $command = new Operation(['parameters' => ['foo' => []]], new Description([]));
102
+ $this->assertEquals('foo', $command->getParam('foo')->getName());
103
+ }
104
+
105
+ public function testContainsApiErrorInformation()
106
+ {
107
+ $command = $this->getOperation();
108
+ $this->assertEquals(1, count($command->getErrorResponses()));
109
+ }
110
+
111
+ public function testHasNotes()
112
+ {
113
+ $o = new Operation(array('notes' => 'foo'), new Description([]));
114
+ $this->assertEquals('foo', $o->getNotes());
115
+ }
116
+
117
+ public function testHasData()
118
+ {
119
+ $o = new Operation(array('data' => array('foo' => 'baz', 'bar' => 123)), new Description([]));
120
+ $this->assertEquals('baz', $o->getData('foo'));
121
+ $this->assertEquals(123, $o->getData('bar'));
122
+ $this->assertNull($o->getData('wfefwe'));
123
+ $this->assertEquals(['foo' => 'baz', 'bar' => 123], $o->getData());
124
+ }
125
+
126
+ /**
127
+ * @expectedException \InvalidArgumentException
128
+ * @expectedExceptionMesssage Parameters must be arrays
129
+ */
130
+ public function testEnsuresParametersAreArrays()
131
+ {
132
+ new Operation(['parameters' => ['foo' => true]], new Description([]));
133
+ }
134
+
135
+ public function testHasDescription()
136
+ {
137
+ $s = new Description([]);
138
+ $o = new Operation(array(), $s);
139
+ $this->assertSame($s, $o->getServiceDescription());
140
+ }
141
+
142
+ public function testHasAdditionalParameters()
143
+ {
144
+ $o = new Operation(array(
145
+ 'additionalParameters' => array(
146
+ 'type' => 'string', 'name' => 'binks'
147
+ ),
148
+ 'parameters' => array(
149
+ 'foo' => array('type' => 'integer')
150
+ )
151
+ ), new Description([]));
152
+ $this->assertEquals('string', $o->getAdditionalParameters()->getType());
153
+ }
154
+
155
+ /**
156
+ * @return Operation
157
+ */
158
+ protected function getOperation()
159
+ {
160
+ return new Operation(array(
161
+ 'name' => 'OperationTest',
162
+ 'class' => get_class($this),
163
+ 'parameters' => array(
164
+ 'test' => array('type' => 'object'),
165
+ 'bool_1' => array('default' => true, 'type' => 'boolean'),
166
+ 'bool_2' => array('default' => false),
167
+ 'float' => array('type' => 'numeric'),
168
+ 'int' => array('type' => 'integer'),
169
+ 'date' => array('type' => 'string'),
170
+ 'timestamp' => array('type' => 'string'),
171
+ 'string' => array('type' => 'string'),
172
+ 'username' => array('type' => 'string', 'required' => true, 'filters' => 'strtolower'),
173
+ 'test_function' => array('type' => 'string', 'filters' => __CLASS__ . '::strtoupper')
174
+ ),
175
+ 'errorResponses' => array(
176
+ array('code' => 503, 'reason' => 'InsufficientCapacity', 'class' => 'Guzzle\\Exception\\RuntimeException')
177
+ )
178
+ ), new Description([]));
179
+ }
180
+
181
+ public function testCanExtendFromOtherOperations()
182
+ {
183
+ $d = new Description([
184
+ 'operations' => [
185
+ 'A' => [
186
+ 'parameters' => [
187
+ 'A' => [
188
+ 'type' => 'object',
189
+ 'properties' => ['foo' => ['type' => 'string']]
190
+ ],
191
+ 'B' => ['type' => 'string']
192
+ ],
193
+ 'summary' => 'foo'
194
+ ],
195
+ 'B' => [
196
+ 'extends' => 'A',
197
+ 'summary' => 'Bar'
198
+ ],
199
+ 'C' => [
200
+ 'extends' => 'B',
201
+ 'summary' => 'Bar',
202
+ 'parameters' => [
203
+ 'B' => ['type' => 'number']
204
+ ]
205
+ ]
206
+ ]
207
+ ]);
208
+
209
+ $a = $d->getOperation('A');
210
+ $this->assertEquals('foo', $a->getSummary());
211
+ $this->assertTrue($a->hasParam('A'));
212
+ $this->assertEquals('string', $a->getParam('B')->getType());
213
+
214
+ $b = $d->getOperation('B');
215
+ $this->assertTrue($a->hasParam('A'));
216
+ $this->assertEquals('Bar', $b->getSummary());
217
+ $this->assertEquals('string', $a->getParam('B')->getType());
218
+
219
+ $c = $d->getOperation('C');
220
+ $this->assertTrue($a->hasParam('A'));
221
+ $this->assertEquals('Bar', $c->getSummary());
222
+ $this->assertEquals('number', $c->getParam('B')->getType());
223
+ }
224
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/ParameterTest.php ADDED
@@ -0,0 +1,342 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Guzzle\Tests\Service\Description;
3
+
4
+ use GuzzleHttp\Command\Guzzle\Parameter;
5
+ use GuzzleHttp\Command\Guzzle\Description;
6
+
7
+ /**
8
+ * @covers \GuzzleHttp\Command\Guzzle\Parameter
9
+ */
10
+ class ParameterTest extends \PHPUnit_Framework_TestCase
11
+ {
12
+ protected $data = array(
13
+ 'name' => 'foo',
14
+ 'type' => 'bar',
15
+ 'required' => true,
16
+ 'default' => '123',
17
+ 'description' => '456',
18
+ 'minLength' => 2,
19
+ 'maxLength' => 5,
20
+ 'location' => 'body',
21
+ 'static' => 'static!',
22
+ 'filters' => array('trim', 'json_encode')
23
+ );
24
+
25
+ public function testCreatesParamFromArray()
26
+ {
27
+ $p = new Parameter($this->data);
28
+ $this->assertEquals('foo', $p->getName());
29
+ $this->assertEquals('bar', $p->getType());
30
+ $this->assertEquals(true, $p->getRequired());
31
+ $this->assertEquals('123', $p->getDefault());
32
+ $this->assertEquals('456', $p->getDescription());
33
+ $this->assertEquals(2, $p->getMinLength());
34
+ $this->assertEquals(5, $p->getMaxLength());
35
+ $this->assertEquals('body', $p->getLocation());
36
+ $this->assertEquals('static!', $p->getStatic());
37
+ $this->assertEquals(array('trim', 'json_encode'), $p->getFilters());
38
+ $p->setName('abc');
39
+ $this->assertEquals('abc', $p->getName());
40
+ }
41
+
42
+ /**
43
+ * @expectedException \InvalidArgumentException
44
+ */
45
+ public function testValidatesDescription()
46
+ {
47
+ new Parameter($this->data, ['description' => 'foo']);
48
+ }
49
+
50
+ public function testCanConvertToArray()
51
+ {
52
+ $p = new Parameter($this->data);
53
+ $this->assertEquals($this->data, $p->toArray());
54
+ }
55
+
56
+ public function testUsesStatic()
57
+ {
58
+ $d = $this->data;
59
+ $d['default'] = 'booboo';
60
+ $d['static'] = true;
61
+ $p = new Parameter($d);
62
+ $this->assertEquals('booboo', $p->getValue('bar'));
63
+ }
64
+
65
+ public function testUsesDefault()
66
+ {
67
+ $d = $this->data;
68
+ $d['default'] = 'foo';
69
+ $d['static'] = null;
70
+ $p = new Parameter($d);
71
+ $this->assertEquals('foo', $p->getValue(null));
72
+ }
73
+
74
+ public function testReturnsYourValue()
75
+ {
76
+ $d = $this->data;
77
+ $d['static'] = null;
78
+ $p = new Parameter($d);
79
+ $this->assertEquals('foo', $p->getValue('foo'));
80
+ }
81
+
82
+ public function testZeroValueDoesNotCauseDefaultToBeReturned()
83
+ {
84
+ $d = $this->data;
85
+ $d['default'] = '1';
86
+ $d['static'] = null;
87
+ $p = new Parameter($d);
88
+ $this->assertEquals('0', $p->getValue('0'));
89
+ }
90
+
91
+ public function testFiltersValues()
92
+ {
93
+ $d = $this->data;
94
+ $d['static'] = null;
95
+ $d['filters'] = 'strtoupper';
96
+ $p = new Parameter($d);
97
+ $this->assertEquals('FOO', $p->filter('foo'));
98
+ }
99
+
100
+ /**
101
+ * @expectedException \RuntimeException
102
+ * @expectedExceptionMessage No service description
103
+ */
104
+ public function testRequiresServiceDescriptionForFormatting()
105
+ {
106
+ $d = $this->data;
107
+ $d['format'] = 'foo';
108
+ $p = new Parameter($d);
109
+ $p->filter('bar');
110
+ }
111
+
112
+ public function testConvertsBooleans()
113
+ {
114
+ $p = new Parameter(array('type' => 'boolean'));
115
+ $this->assertEquals(true, $p->filter('true'));
116
+ $this->assertEquals(false, $p->filter('false'));
117
+ }
118
+
119
+ public function testUsesArrayByDefaultForFilters()
120
+ {
121
+ $d = $this->data;
122
+ $d['filters'] = null;
123
+ $p = new Parameter($d);
124
+ $this->assertEquals(array(), $p->getFilters());
125
+ }
126
+
127
+ public function testAllowsSimpleLocationValue()
128
+ {
129
+ $p = new Parameter(array('name' => 'myname', 'location' => 'foo', 'sentAs' => 'Hello'));
130
+ $this->assertEquals('foo', $p->getLocation());
131
+ $this->assertEquals('Hello', $p->getSentAs());
132
+ }
133
+
134
+ public function testParsesTypeValues()
135
+ {
136
+ $p = new Parameter(array('type' => 'foo'));
137
+ $this->assertEquals('foo', $p->getType());
138
+ }
139
+
140
+ /**
141
+ * @expectedException \InvalidArgumentException
142
+ * @expectedExceptionMessage A [method] value must be specified for each complex filter
143
+ */
144
+ public function testValidatesComplexFilters()
145
+ {
146
+ $p = new Parameter(array('filters' => array(array('args' => 'foo'))));
147
+ }
148
+
149
+ public function testAllowsComplexFilters()
150
+ {
151
+ $that = $this;
152
+ $param = new Parameter([
153
+ 'filters' => [
154
+ [
155
+ 'method' => function ($a, $b, $c, $d) use ($that, &$param) {
156
+ $that->assertEquals('test', $a);
157
+ $that->assertEquals('my_value!', $b);
158
+ $that->assertEquals('bar', $c);
159
+ $that->assertSame($param, $d);
160
+ return 'abc' . $b;
161
+ },
162
+ 'args' => ['test', '@value', 'bar', '@api']
163
+ ]
164
+ ]
165
+ ]);
166
+
167
+ $this->assertEquals('abcmy_value!', $param->filter('my_value!'));
168
+ }
169
+
170
+ public function testAddsAdditionalProperties()
171
+ {
172
+ $p = new Parameter(array(
173
+ 'type' => 'object',
174
+ 'additionalProperties' => array('type' => 'string')
175
+ ));
176
+ $this->assertInstanceOf('GuzzleHttp\Command\Guzzle\Parameter', $p->getAdditionalProperties());
177
+ $this->assertNull($p->getAdditionalProperties()->getAdditionalProperties());
178
+ $p = new Parameter(array('type' => 'object'));
179
+ $this->assertTrue($p->getAdditionalProperties());
180
+ }
181
+
182
+ public function testAddsItems()
183
+ {
184
+ $p = new Parameter(array(
185
+ 'type' => 'array',
186
+ 'items' => array('type' => 'string')
187
+ ));
188
+ $this->assertInstanceOf('GuzzleHttp\Command\Guzzle\Parameter', $p->getItems());
189
+ $out = $p->toArray();
190
+ $this->assertEquals('array', $out['type']);
191
+ $this->assertInternalType('array', $out['items']);
192
+ }
193
+
194
+ public function testCanRetrieveKnownPropertiesUsingDataMethod()
195
+ {
196
+ $p = new Parameter(['data' => ['name' => 'test'], 'extra' => 'hi!']);
197
+ $this->assertEquals('test', $p->getData('name'));
198
+ $this->assertEquals(['name' => 'test'], $p->getData());
199
+ $this->assertNull($p->getData('fjnweefe'));
200
+ $this->assertEquals('hi!', $p->getData('extra'));
201
+ }
202
+
203
+ public function testHasPattern()
204
+ {
205
+ $p = new Parameter(['pattern' => '/[0-9]+/']);
206
+ $this->assertEquals('/[0-9]+/', $p->getPattern());
207
+ }
208
+
209
+ public function testHasEnum()
210
+ {
211
+ $p = new Parameter(['enum' => ['foo', 'bar']]);
212
+ $this->assertEquals(array('foo', 'bar'), $p->getEnum());
213
+ }
214
+
215
+ public function testSerializesItems()
216
+ {
217
+ $p = new Parameter(array(
218
+ 'type' => 'object',
219
+ 'additionalProperties' => array('type' => 'string')
220
+ ));
221
+ $this->assertEquals(array(
222
+ 'type' => 'object',
223
+ 'additionalProperties' => array('type' => 'string')
224
+ ), $p->toArray());
225
+ }
226
+
227
+ public function testResolvesRefKeysRecursively()
228
+ {
229
+ $description = new Description(array(
230
+ 'models' => array(
231
+ 'JarJar' => array('type' => 'string', 'default' => 'Mesa address tha senate!'),
232
+ 'Anakin' => array('type' => 'array', 'items' => array('$ref' => 'JarJar'))
233
+ )
234
+ ));
235
+ $p = new Parameter(array('$ref' => 'Anakin', 'description' => 'added'), ['description' => $description]);
236
+ $this->assertEquals(array(
237
+ 'description' => 'added',
238
+ '$ref' => 'Anakin'
239
+ ), $p->toArray());
240
+ }
241
+
242
+ public function testResolvesExtendsRecursively()
243
+ {
244
+ $jarJar = array('type' => 'string', 'default' => 'Mesa address tha senate!', 'description' => 'a');
245
+ $anakin = array('type' => 'array', 'items' => array('extends' => 'JarJar', 'description' => 'b'));
246
+ $description = new Description(array(
247
+ 'models' => array('JarJar' => $jarJar, 'Anakin' => $anakin)
248
+ ));
249
+ // Description attribute will be updated, and format added
250
+ $p = new Parameter(array('extends' => 'Anakin', 'format' => 'date'), ['description' => $description]);
251
+ $this->assertEquals(array(
252
+ 'format' => 'date',
253
+ 'extends' => 'Anakin'
254
+ ), $p->toArray());
255
+ }
256
+
257
+ public function testHasKeyMethod()
258
+ {
259
+ $p = new Parameter(['name' => 'foo', 'sentAs' => 'bar']);
260
+ $this->assertEquals('bar', $p->getWireName());
261
+ }
262
+
263
+ public function testIncludesNameInToArrayWhenItemsAttributeHasName()
264
+ {
265
+ $p = new Parameter(array(
266
+ 'type' => 'array',
267
+ 'name' => 'Abc',
268
+ 'items' => array(
269
+ 'name' => 'Foo',
270
+ 'type' => 'object'
271
+ )
272
+ ));
273
+ $result = $p->toArray();
274
+ $this->assertEquals(array(
275
+ 'type' => 'array',
276
+ 'name' => 'Abc',
277
+ 'items' => array(
278
+ 'name' => 'Foo',
279
+ 'type' => 'object'
280
+ )
281
+ ), $result);
282
+ }
283
+
284
+ public function dateTimeProvider()
285
+ {
286
+ $d = 'October 13, 2012 16:15:46 UTC';
287
+
288
+ return array(
289
+ array($d, 'date-time', '2012-10-13T16:15:46Z'),
290
+ array($d, 'date', '2012-10-13'),
291
+ array($d, 'timestamp', strtotime($d)),
292
+ array(new \DateTime($d), 'timestamp', strtotime($d))
293
+ );
294
+ }
295
+
296
+ /**
297
+ * @dataProvider dateTimeProvider
298
+ */
299
+ public function testAppliesFormat($d, $format, $result)
300
+ {
301
+ $p = new Parameter(['format' => $format], ['description' => new Description([])]);
302
+ $this->assertEquals($format, $p->getFormat());
303
+ $this->assertEquals($result, $p->filter($d));
304
+ }
305
+
306
+ public function testHasMinAndMax()
307
+ {
308
+ $p = new Parameter([
309
+ 'minimum' => 2,
310
+ 'maximum' => 3,
311
+ 'minItems' => 4,
312
+ 'maxItems' => 5,
313
+ ]);
314
+ $this->assertEquals(2, $p->getMinimum());
315
+ $this->assertEquals(3, $p->getMaximum());
316
+ $this->assertEquals(4, $p->getMinItems());
317
+ $this->assertEquals(5, $p->getMaxItems());
318
+ }
319
+
320
+ public function testHasProperties()
321
+ {
322
+ $data = [
323
+ 'type' => 'object',
324
+ 'properties' => [
325
+ 'foo' => ['type' => 'string'],
326
+ 'bar' => ['type' => 'string'],
327
+ ]
328
+ ];
329
+ $p = new Parameter($data);
330
+ $this->assertInstanceOf('GuzzleHttp\\Command\\Guzzle\\Parameter', $p->getProperty('foo'));
331
+ $this->assertSame($p->getProperty('foo'), $p->getProperty('foo'));
332
+ $this->assertNull($p->getProperty('wefwe'));
333
+
334
+ $properties = $p->getProperties();
335
+ $this->assertInternalType('array', $properties);
336
+ foreach ($properties as $prop) {
337
+ $this->assertInstanceOf('GuzzleHttp\\Command\\Guzzle\\Parameter', $prop);
338
+ }
339
+
340
+ $this->assertEquals($data, $p->toArray());
341
+ }
342
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/RequestLocation/BodyLocationTest.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Command\Guzzle;
3
+
4
+ use GuzzleHttp\Command\Command;
5
+ use GuzzleHttp\Command\Guzzle\Parameter;
6
+ use GuzzleHttp\Command\Guzzle\RequestLocation\BodyLocation;
7
+ use GuzzleHttp\Message\Request;
8
+
9
+ /**
10
+ * @covers \GuzzleHttp\Command\Guzzle\RequestLocation\BodyLocation
11
+ */
12
+ class BodyLocationTest extends \PHPUnit_Framework_TestCase
13
+ {
14
+ public function testVisitsLocation()
15
+ {
16
+ $location = new BodyLocation('body');
17
+ $command = new Command('foo', ['foo' => 'bar']);
18
+ $request = new Request('POST', 'http://httbin.org');
19
+ $param = new Parameter(['name' => 'foo']);
20
+ $location->visit($command, $request, $param, []);
21
+ $this->assertEquals('bar', $request->getBody());
22
+ }
23
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/RequestLocation/HeaderLocationTest.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Command\Guzzle;
3
+
4
+ use GuzzleHttp\Command\Command;
5
+ use GuzzleHttp\Command\Guzzle\RequestLocation\HeaderLocation;
6
+ use GuzzleHttp\Message\Request;
7
+ use GuzzleHttp\Command\Guzzle\Parameter;
8
+ use GuzzleHttp\Command\Guzzle\Operation;
9
+ use GuzzleHttp\Command\Guzzle\Description;
10
+
11
+ /**
12
+ * @covers \GuzzleHttp\Command\Guzzle\RequestLocation\HeaderLocation
13
+ * @covers \GuzzleHttp\Command\Guzzle\RequestLocation\AbstractLocation
14
+ */
15
+ class HeaderLocationTest extends \PHPUnit_Framework_TestCase
16
+ {
17
+ public function testVisitsLocation()
18
+ {
19
+ $location = new HeaderLocation('header');
20
+ $command = new Command('foo', ['foo' => 'bar']);
21
+ $request = new Request('POST', 'http://httbin.org');
22
+ $param = new Parameter(['name' => 'foo']);
23
+ $location->visit($command, $request, $param, []);
24
+ $this->assertEquals('bar', $request->getHeader('foo'));
25
+ }
26
+
27
+ public function testAddsAdditionalProperties()
28
+ {
29
+ $location = new HeaderLocation('header');
30
+ $command = new Command('foo', ['foo' => 'bar']);
31
+ $command['add'] = 'props';
32
+ $operation = new Operation([
33
+ 'additionalParameters' => [
34
+ 'location' => 'header'
35
+ ]
36
+ ], new Description([]));
37
+ $request = new Request('POST', 'http://httbin.org');
38
+ $location->after($command, $request, $operation, []);
39
+ $this->assertEquals('props', $request->getHeader('add'));
40
+ }
41
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/RequestLocation/JsonLocationTest.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Command\Guzzle;
3
+
4
+ use GuzzleHttp\Command\Guzzle\Description;
5
+ use GuzzleHttp\Message\Request;
6
+ use GuzzleHttp\Command\Guzzle\RequestLocation\JsonLocation;
7
+ use GuzzleHttp\Command\Guzzle\Parameter;
8
+ use GuzzleHttp\Command\Guzzle\Operation;
9
+ use GuzzleHttp\Command\Command;
10
+
11
+ /**
12
+ * @covers \GuzzleHttp\Command\Guzzle\RequestLocation\JsonLocation
13
+ * @covers \GuzzleHttp\Command\Guzzle\RequestLocation\AbstractLocation
14
+ */
15
+ class JsonLocationTest extends \PHPUnit_Framework_TestCase
16
+ {
17
+ public function testVisitsLocation()
18
+ {
19
+ $location = new JsonLocation('json');
20
+ $command = new Command('foo', ['foo' => 'bar']);
21
+ $request = new Request('POST', 'http://httbin.org');
22
+ $param = new Parameter(['name' => 'foo']);
23
+ $location->visit($command, $request, $param, []);
24
+ $operation = new Operation([], new Description([]));
25
+ $location->after($command, $request, $operation, []);
26
+ $this->assertEquals('{"foo":"bar"}', $request->getBody());
27
+ $this->assertEquals('application/json', $request->getHeader('Content-Type'));
28
+ }
29
+
30
+ public function testVisitsAdditionalProperties()
31
+ {
32
+ $location = new JsonLocation('json', 'foo');
33
+ $command = new Command('foo', ['foo' => 'bar']);
34
+ $command['baz'] = ['bam' => [1]];
35
+ $request = new Request('POST', 'http://httbin.org');
36
+ $param = new Parameter(['name' => 'foo']);
37
+ $location->visit($command, $request, $param, []);
38
+ $operation = new Operation([
39
+ 'additionalParameters' => [
40
+ 'location' => 'json'
41
+ ]
42
+ ], new Description([]));
43
+ $location->after($command, $request, $operation, []);
44
+ $this->assertEquals('{"foo":"bar","baz":{"bam":[1]}}', $request->getBody());
45
+ $this->assertEquals('foo', $request->getHeader('Content-Type'));
46
+ }
47
+
48
+ public function testVisitsNestedLocation()
49
+ {
50
+ $location = new JsonLocation('json');
51
+ $command = new Command('foo', ['foo' => 'bar']);
52
+ $request = new Request('POST', 'http://httbin.org');
53
+ $param = new Parameter([
54
+ 'name' => 'foo',
55
+ 'type' => 'object',
56
+ 'properties' => [
57
+ 'baz' => [
58
+ 'type' => 'array',
59
+ 'items' => [
60
+ 'type' => 'string',
61
+ 'filters' => ['strtoupper']
62
+ ]
63
+ ]
64
+ ],
65
+ 'additionalProperties' => [
66
+ 'type' => 'array',
67
+ 'items' => [
68
+ 'type' => 'string',
69
+ 'filters' => ['strtolower']
70
+ ]
71
+ ]
72
+ ]);
73
+ $command['foo'] = [
74
+ 'baz' => ['a', 'b'],
75
+ 'bam' => ['A', 'B'],
76
+ ];
77
+ $location->visit($command, $request, $param, []);
78
+ $operation = new Operation([], new Description([]));
79
+ $location->after($command, $request, $operation, []);
80
+ $this->assertEquals('{"foo":{"baz":["A","B"],"bam":["a","b"]}}', (string) $request->getBody());
81
+ $this->assertEquals('application/json', $request->getHeader('Content-Type'));
82
+ }
83
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/RequestLocation/PostFieldLocationTest.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Command\Guzzle;
3
+
4
+ use GuzzleHttp\Command\Guzzle\Description;
5
+ use GuzzleHttp\Command\Guzzle\Operation;
6
+ use GuzzleHttp\Command\Guzzle\RequestLocation\PostFieldLocation;
7
+ use GuzzleHttp\Message\Request;
8
+ use GuzzleHttp\Command\Guzzle\Parameter;
9
+ use GuzzleHttp\Post\PostBody;
10
+ use GuzzleHttp\Command\Command;
11
+
12
+ /**
13
+ * @covers \GuzzleHttp\Command\Guzzle\RequestLocation\PostFieldLocation
14
+ * @covers \GuzzleHttp\Command\Guzzle\RequestLocation\AbstractLocation
15
+ */
16
+ class PostFieldLocationTest extends \PHPUnit_Framework_TestCase
17
+ {
18
+ public function testVisitsLocation()
19
+ {
20
+ $location = new PostFieldLocation('body');
21
+ $command = new Command('foo', ['foo' => 'bar']);
22
+ $request = new Request('POST', 'http://httbin.org', [], new PostBody());
23
+ $param = new Parameter(['name' => 'foo']);
24
+ $location->visit($command, $request, $param, []);
25
+ $this->assertEquals('bar', $request->getBody()->getField('foo'));
26
+ }
27
+
28
+ /**
29
+ * @expectedException \RuntimeException
30
+ */
31
+ public function testValidatesBodyIsPost()
32
+ {
33
+ $location = new PostFieldLocation('postField');
34
+ $command = new Command('foo', ['foo' => 'bar']);
35
+ $request = new Request('POST', 'http://httbin.org');
36
+ $param = new Parameter(['name' => 'foo']);
37
+ $location->visit($command, $request, $param, []);
38
+ }
39
+
40
+ public function testAddsAdditionalProperties()
41
+ {
42
+ $location = new PostFieldLocation('postField');
43
+ $command = new Command('foo', ['foo' => 'bar']);
44
+ $command['add'] = 'props';
45
+ $operation = new Operation([
46
+ 'additionalParameters' => [
47
+ 'location' => 'postField'
48
+ ]
49
+ ], new Description([]));
50
+ $request = new Request('POST', 'http://httbin.org', [], new PostBody());
51
+ $location->after($command, $request, $operation, []);
52
+ $this->assertEquals('props', $request->getBody()->getField('add'));
53
+ }
54
+
55
+ /**
56
+ * @expectedException \RuntimeException
57
+ */
58
+ public function testValidatesBodyInAfter()
59
+ {
60
+ $location = new PostFieldLocation('postField');
61
+ $command = new Command('foo', ['foo' => 'bar']);
62
+ $operation = new Operation([
63
+ 'additionalParameters' => [
64
+ 'location' => 'postField'
65
+ ]
66
+ ], new Description([]));
67
+ $request = new Request('POST', 'http://httbin.org');
68
+ $location->after($command, $request, $operation, []);
69
+ }
70
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/RequestLocation/PostFileLocationTest.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Command\Guzzle;
3
+
4
+ use GuzzleHttp\Post\PostBody;
5
+ use GuzzleHttp\Message\Request;
6
+ use GuzzleHttp\Command\Guzzle\Parameter;
7
+ use GuzzleHttp\Command\Guzzle\RequestLocation\PostFileLocation;
8
+ use GuzzleHttp\Command\Command;
9
+
10
+ /**
11
+ * @covers \GuzzleHttp\Command\Guzzle\RequestLocation\PostFileLocation
12
+ */
13
+ class PostFileLocationTest extends \PHPUnit_Framework_TestCase
14
+ {
15
+ public function testVisitsLocation()
16
+ {
17
+ $location = new PostFileLocation('postFile');
18
+ $command = new Command('foo', ['foo' => 'bar']);
19
+ $request = new Request('POST', 'http://httbin.org', [], new PostBody());
20
+ $param = new Parameter(['name' => 'foo']);
21
+ $location->visit($command, $request, $param, []);
22
+ $this->assertEquals(
23
+ 'bar',
24
+ $request->getBody()->getFile('foo')->getContent()
25
+ );
26
+ }
27
+
28
+ /**
29
+ * @expectedException \RuntimeException
30
+ */
31
+ public function testValidatesBodyIsPost()
32
+ {
33
+ $location = new PostFileLocation('postFile');
34
+ $command = new Command('foo', ['foo' => 'bar']);
35
+ $request = new Request('POST', 'http://httbin.org');
36
+ $param = new Parameter(['name' => 'foo']);
37
+ $location->visit($command, $request, $param, []);
38
+ }
39
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/RequestLocation/QueryLocationTest.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Command\Guzzle;
3
+
4
+ use GuzzleHttp\Message\Request;
5
+ use GuzzleHttp\Command\Guzzle\Parameter;
6
+ use GuzzleHttp\Command\Guzzle\RequestLocation\QueryLocation;
7
+ use GuzzleHttp\Command\Guzzle\Operation;
8
+ use GuzzleHttp\Command\Guzzle\Description;
9
+ use GuzzleHttp\Command\Command;
10
+
11
+ /**
12
+ * @covers \GuzzleHttp\Command\Guzzle\RequestLocation\QueryLocation
13
+ * @covers \GuzzleHttp\Command\Guzzle\RequestLocation\AbstractLocation
14
+ */
15
+ class QueryLocationTest extends \PHPUnit_Framework_TestCase
16
+ {
17
+ public function testVisitsLocation()
18
+ {
19
+ $location = new QueryLocation('query');
20
+ $command = new Command('foo', ['foo' => 'bar']);
21
+ $request = new Request('POST', 'http://httbin.org');
22
+ $param = new Parameter(['name' => 'foo']);
23
+ $location->visit($command, $request, $param, []);
24
+ $this->assertEquals('bar', $request->getQuery()['foo']);
25
+ }
26
+
27
+ public function testAddsAdditionalProperties()
28
+ {
29
+ $location = new QueryLocation('query');
30
+ $command = new Command('foo', ['foo' => 'bar']);
31
+ $command['add'] = 'props';
32
+ $operation = new Operation([
33
+ 'additionalParameters' => [
34
+ 'location' => 'query'
35
+ ]
36
+ ], new Description([]));
37
+ $request = new Request('POST', 'http://httbin.org');
38
+ $location->after($command, $request, $operation, []);
39
+ $this->assertEquals('props', $request->getQuery()['add']);
40
+ }
41
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/RequestLocation/XmlLocationTest.php ADDED
@@ -0,0 +1,433 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Command\Guzzle;
3
+
4
+ use GuzzleHttp\Client;
5
+ use GuzzleHttp\Command\Event\PreparedEvent;
6
+ use GuzzleHttp\Command\Guzzle\GuzzleClient;
7
+ use GuzzleHttp\Command\Guzzle\RequestLocation\XmlLocation;
8
+ use GuzzleHttp\Command\Guzzle\Description;
9
+ use GuzzleHttp\Event\BeforeEvent;
10
+ use GuzzleHttp\Message\Request;
11
+ use GuzzleHttp\Command\Guzzle\Parameter;
12
+ use GuzzleHttp\Command\Guzzle\Operation;
13
+ use GuzzleHttp\Message\Response;
14
+ use GuzzleHttp\Command\Command;
15
+
16
+ /**
17
+ * @covers \GuzzleHttp\Command\Guzzle\RequestLocation\XmlLocation
18
+ */
19
+ class XmlLocationTest extends \PHPUnit_Framework_TestCase
20
+ {
21
+ public function testVisitsLocation()
22
+ {
23
+ $location = new XmlLocation('xml');
24
+ $command = new Command('foo', ['foo' => 'bar']);
25
+ $command['bar'] = 'test';
26
+ $request = new Request('POST', 'http://httbin.org');
27
+ $param = new Parameter(['name' => 'foo']);
28
+ $location->visit($command, $request, $param, []);
29
+ $param = new Parameter(['name' => 'bar']);
30
+ $location->visit($command, $request, $param, []);
31
+ $operation = new Operation([], new Description([]));
32
+ $location->after($command, $request, $operation, []);
33
+ $xml = (string) $request->getBody();
34
+ $this->assertEquals('<?xml version="1.0"?>' . "\n"
35
+ . '<Request><foo>bar</foo><bar>test</bar></Request>' . "\n", $xml);
36
+ $this->assertEquals('application/xml', $request->getHeader('Content-Type'));
37
+ }
38
+
39
+ public function testCreatesBodyForEmptyDocument()
40
+ {
41
+ $location = new XmlLocation('xml');
42
+ $command = new Command('foo', ['foo' => 'bar']);
43
+ $request = new Request('POST', 'http://httbin.org');
44
+ $operation = new Operation([
45
+ 'data' => ['xmlAllowEmpty' => true]
46
+ ], new Description([]));
47
+ $location->after($command, $request, $operation, []);
48
+ $xml = (string) $request->getBody();
49
+ $this->assertEquals('<?xml version="1.0"?>' . "\n"
50
+ . '<Request/>' . "\n", $xml);
51
+ $this->assertEquals('application/xml', $request->getHeader('Content-Type'));
52
+ }
53
+
54
+ public function testAddsAdditionalParameters()
55
+ {
56
+ $location = new XmlLocation('xml', 'test');
57
+ $command = new Command('foo', ['foo' => 'bar']);
58
+ $request = new Request('POST', 'http://httbin.org');
59
+ $param = new Parameter(['name' => 'foo']);
60
+ $command['foo'] = 'bar';
61
+ $location->visit($command, $request, $param, []);
62
+ $operation = new Operation([
63
+ 'additionalParameters' => [
64
+ 'location' => 'xml'
65
+ ]
66
+ ], new Description([]));
67
+ $command['bam'] = 'boo';
68
+ $location->after($command, $request, $operation, []);
69
+ $xml = (string) $request->getBody();
70
+ $this->assertEquals('<?xml version="1.0"?>' . "\n"
71
+ . '<Request><foo>bar</foo><foo>bar</foo><bam>boo</bam></Request>' . "\n", $xml);
72
+ $this->assertEquals('test', $request->getHeader('Content-Type'));
73
+ }
74
+
75
+ public function testAllowsXmlEncoding()
76
+ {
77
+ $location = new XmlLocation('xml');
78
+ $operation = new Operation([
79
+ 'data' => ['xmlEncoding' => 'UTF-8']
80
+ ], new Description([]));
81
+ $command = new Command('foo', ['foo' => 'bar']);
82
+ $request = new Request('POST', 'http://httbin.org');
83
+ $param = new Parameter(['name' => 'foo']);
84
+ $command['foo'] = 'bar';
85
+ $location->visit($command, $request, $param, []);
86
+ $location->after($command, $request, $operation, []);
87
+ $xml = (string) $request->getBody();
88
+ $this->assertEquals('<?xml version="1.0" encoding="UTF-8"?>' . "\n"
89
+ . '<Request><foo>bar</foo></Request>' . "\n", $xml);
90
+ }
91
+
92
+ public function xmlProvider()
93
+ {
94
+ return array(
95
+ array(
96
+ array(
97
+ 'data' => array(
98
+ 'xmlRoot' => array(
99
+ 'name' => 'test',
100
+ 'namespaces' => 'http://foo.com'
101
+ )
102
+ ),
103
+ 'parameters' => array(
104
+ 'Foo' => array('location' => 'xml', 'type' => 'string'),
105
+ 'Baz' => array('location' => 'xml', 'type' => 'string')
106
+ )
107
+ ),
108
+ array('Foo' => 'test', 'Baz' => 'bar'),
109
+ '<test xmlns="http://foo.com"><Foo>test</Foo><Baz>bar</Baz></test>'
110
+ ),
111
+ // Ensure that the content-type is not added
112
+ array(array('parameters' => array('Foo' => array('location' => 'xml', 'type' => 'string'))), array(), ''),
113
+ // Test with adding attributes and no namespace
114
+ array(
115
+ array(
116
+ 'data' => array(
117
+ 'xmlRoot' => array(
118
+ 'name' => 'test'
119
+ )
120
+ ),
121
+ 'parameters' => array(
122
+ 'Foo' => array('location' => 'xml', 'type' => 'string', 'data' => array('xmlAttribute' => true))
123
+ )
124
+ ),
125
+ array('Foo' => 'test', 'Baz' => 'bar'),
126
+ '<test Foo="test"/>'
127
+ ),
128
+ // Test adding with an array
129
+ array(
130
+ array(
131
+ 'parameters' => array(
132
+ 'Foo' => array('location' => 'xml', 'type' => 'string'),
133
+ 'Baz' => array(
134
+ 'type' => 'array',
135
+ 'location' => 'xml',
136
+ 'items' => array(
137
+ 'type' => 'numeric',
138
+ 'sentAs' => 'Bar'
139
+ )
140
+ )
141
+ )
142
+ ),
143
+ array('Foo' => 'test', 'Baz' => array(1, 2)),
144
+ '<Request><Foo>test</Foo><Baz><Bar>1</Bar><Bar>2</Bar></Baz></Request>'
145
+ ),
146
+ // Test adding an object
147
+ array(
148
+ array(
149
+ 'parameters' => array(
150
+ 'Foo' => array('location' => 'xml', 'type' => 'string'),
151
+ 'Baz' => array(
152
+ 'type' => 'object',
153
+ 'location' => 'xml',
154
+ 'properties' => array(
155
+ 'Bar' => array('type' => 'string'),
156
+ 'Bam' => array()
157
+ )
158
+ )
159
+ )
160
+ ),
161
+ array('Foo' => 'test', 'Baz' => array('Bar' => 'abc', 'Bam' => 'foo')),
162
+ '<Request><Foo>test</Foo><Baz><Bar>abc</Bar><Bam>foo</Bam></Baz></Request>'
163
+ ),
164
+ // Add an array that contains an object
165
+ array(
166
+ array(
167
+ 'parameters' => array(
168
+ 'Baz' => array(
169
+ 'type' => 'array',
170
+ 'location' => 'xml',
171
+ 'items' => array(
172
+ 'type' => 'object',
173
+ 'sentAs' => 'Bar',
174
+ 'properties' => array('A' => array(), 'B' => array())
175
+ )
176
+ )
177
+ )
178
+ ),
179
+ array('Baz' => array(
180
+ array('A' => '1', 'B' => '2'),
181
+ array('A' => '3', 'B' => '4')
182
+ )),
183
+ '<Request><Baz><Bar><A>1</A><B>2</B></Bar><Bar><A>3</A><B>4</B></Bar></Baz></Request>'
184
+ ),
185
+ // Add an object of attributes
186
+ array(
187
+ array(
188
+ 'parameters' => array(
189
+ 'Foo' => array('location' => 'xml', 'type' => 'string'),
190
+ 'Baz' => array(
191
+ 'type' => 'object',
192
+ 'location' => 'xml',
193
+ 'properties' => array(
194
+ 'Bar' => array('type' => 'string', 'data' => array('xmlAttribute' => true)),
195
+ 'Bam' => array()
196
+ )
197
+ )
198
+ )
199
+ ),
200
+ array('Foo' => 'test', 'Baz' => array('Bar' => 'abc', 'Bam' => 'foo')),
201
+ '<Request><Foo>test</Foo><Baz Bar="abc"><Bam>foo</Bam></Baz></Request>'
202
+ ),
203
+ // Check order doesn't matter
204
+ array(
205
+ array(
206
+ 'parameters' => array(
207
+ 'Foo' => array('location' => 'xml', 'type' => 'string'),
208
+ 'Baz' => array(
209
+ 'type' => 'object',
210
+ 'location' => 'xml',
211
+ 'properties' => array(
212
+ 'Bar' => array('type' => 'string', 'data' => array('xmlAttribute' => true)),
213
+ 'Bam' => array()
214
+ )
215
+ )
216
+ )
217
+ ),
218
+ array('Foo' => 'test', 'Baz' => array('Bam' => 'foo', 'Bar' => 'abc')),
219
+ '<Request><Foo>test</Foo><Baz Bar="abc"><Bam>foo</Bam></Baz></Request>'
220
+ ),
221
+ // Add values with custom namespaces
222
+ array(
223
+ array(
224
+ 'parameters' => array(
225
+ 'Foo' => array(
226
+ 'location' => 'xml',
227
+ 'type' => 'string',
228
+ 'data' => array(
229
+ 'xmlNamespace' => 'http://foo.com'
230
+ )
231
+ )
232
+ )
233
+ ),
234
+ array('Foo' => 'test'),
235
+ '<Request><Foo xmlns="http://foo.com">test</Foo></Request>'
236
+ ),
237
+ // Add attributes with custom namespace prefix
238
+ array(
239
+ array(
240
+ 'parameters' => array(
241
+ 'Wrap' => array(
242
+ 'type' => 'object',
243
+ 'location' => 'xml',
244
+ 'properties' => array(
245
+ 'Foo' => array(
246
+ 'type' => 'string',
247
+ 'sentAs' => 'xsi:baz',
248
+ 'data' => array(
249
+ 'xmlNamespace' => 'http://foo.com',
250
+ 'xmlAttribute' => true
251
+ )
252
+ )
253
+ )
254
+ ),
255
+ )
256
+ ),
257
+ array('Wrap' => array(
258
+ 'Foo' => 'test'
259
+ )),
260
+ '<Request><Wrap xsi:baz="test" xmlns:xsi="http://foo.com"/></Request>'
261
+ ),
262
+ // Add nodes with custom namespace prefix
263
+ array(
264
+ array(
265
+ 'parameters' => array(
266
+ 'Wrap' => array(
267
+ 'type' => 'object',
268
+ 'location' => 'xml',
269
+ 'properties' => array(
270
+ 'Foo' => array(
271
+ 'type' => 'string',
272
+ 'sentAs' => 'xsi:Foo',
273
+ 'data' => array(
274
+ 'xmlNamespace' => 'http://foobar.com'
275
+ )
276
+ )
277
+ )
278
+ ),
279
+ )
280
+ ),
281
+ array('Wrap' => array(
282
+ 'Foo' => 'test'
283
+ )),
284
+ '<Request><Wrap><xsi:Foo xmlns:xsi="http://foobar.com">test</xsi:Foo></Wrap></Request>'
285
+ ),
286
+ array(
287
+ array(
288
+ 'parameters' => array(
289
+ 'Foo' => array(
290
+ 'location' => 'xml',
291
+ 'type' => 'string',
292
+ 'data' => array(
293
+ 'xmlNamespace' => 'http://foo.com'
294
+ )
295
+ )
296
+ )
297
+ ),
298
+ array('Foo' => '<h1>This is a title</h1>'),
299
+ '<Request><Foo xmlns="http://foo.com"><![CDATA[<h1>This is a title</h1>]]></Foo></Request>'
300
+ ),
301
+ // Flat array at top level
302
+ array(
303
+ array(
304
+ 'parameters' => array(
305
+ 'Bars' => array(
306
+ 'type' => 'array',
307
+ 'data' => array('xmlFlattened' => true),
308
+ 'location' => 'xml',
309
+ 'items' => array(
310
+ 'type' => 'object',
311
+ 'sentAs' => 'Bar',
312
+ 'properties' => array(
313
+ 'A' => array(),
314
+ 'B' => array()
315
+ )
316
+ )
317
+ ),
318
+ 'Boos' => array(
319
+ 'type' => 'array',
320
+ 'data' => array('xmlFlattened' => true),
321
+ 'location' => 'xml',
322
+ 'items' => array(
323
+ 'sentAs' => 'Boo',
324
+ 'type' => 'string'
325
+ )
326
+ )
327
+ )
328
+ ),
329
+ array(
330
+ 'Bars' => array(
331
+ array('A' => '1', 'B' => '2'),
332
+ array('A' => '3', 'B' => '4')
333
+ ),
334
+ 'Boos' => array('test', '123')
335
+ ),
336
+ '<Request><Bar><A>1</A><B>2</B></Bar><Bar><A>3</A><B>4</B></Bar><Boo>test</Boo><Boo>123</Boo></Request>'
337
+ ),
338
+ // Nested flat arrays
339
+ array(
340
+ array(
341
+ 'parameters' => array(
342
+ 'Delete' => array(
343
+ 'type' => 'object',
344
+ 'location' => 'xml',
345
+ 'properties' => array(
346
+ 'Items' => array(
347
+ 'type' => 'array',
348
+ 'data' => array('xmlFlattened' => true),
349
+ 'items' => array(
350
+ 'type' => 'object',
351
+ 'sentAs' => 'Item',
352
+ 'properties' => array(
353
+ 'A' => array(),
354
+ 'B' => array()
355
+ )
356
+ )
357
+ )
358
+ )
359
+ )
360
+ )
361
+ ),
362
+ array(
363
+ 'Delete' => array(
364
+ 'Items' => array(
365
+ array('A' => '1', 'B' => '2'),
366
+ array('A' => '3', 'B' => '4')
367
+ )
368
+ )
369
+ ),
370
+ '<Request><Delete><Item><A>1</A><B>2</B></Item><Item><A>3</A><B>4</B></Item></Delete></Request>'
371
+ ),
372
+ // Test adding root node attributes after nodes
373
+ array(
374
+ array(
375
+ 'data' => array(
376
+ 'xmlRoot' => array(
377
+ 'name' => 'test'
378
+ )
379
+ ),
380
+ 'parameters' => array(
381
+ 'Foo' => array('location' => 'xml', 'type' => 'string'),
382
+ 'Baz' => array('location' => 'xml', 'type' => 'string', 'data' => array('xmlAttribute' => true)),
383
+ )
384
+ ),
385
+ array('Foo' => 'test', 'Baz' => 'bar'),
386
+ '<test Baz="bar"><Foo>test</Foo></test>'
387
+ ),
388
+ );
389
+ }
390
+
391
+ /**
392
+ * @dataProvider xmlProvider
393
+ */
394
+ public function testSerializesXml(array $operation, array $input, $xml)
395
+ {
396
+ $operation['uri'] = 'http://httpbin.org';
397
+ $client = new GuzzleClient(
398
+ new Client(),
399
+ new Description([
400
+ 'operations' => [
401
+ 'foo' => $operation
402
+ ]
403
+ ]
404
+ ));
405
+
406
+ $request = null;
407
+ $command = $client->getCommand('foo', $input);
408
+
409
+ $command->getEmitter()->on(
410
+ 'prepared',
411
+ function (PreparedEvent $event) use (&$request) {
412
+ $request = $event->getRequest();
413
+ $event->getRequest()->getEmitter()->on(
414
+ 'before',
415
+ function(BeforeEvent $e) {
416
+ $e->intercept(new Response(200));
417
+ }
418
+ );
419
+ }
420
+ );
421
+
422
+ $client->execute($command);
423
+
424
+ if (empty($input)) {
425
+ $this->assertEquals('', (string) $request->getHeader('Content-Type'));
426
+ } else {
427
+ $this->assertEquals('application/xml', $request->getHeader('Content-Type'));
428
+ }
429
+
430
+ $body = str_replace(array("\n", "<?xml version=\"1.0\"?>"), '', (string) $request->getBody());
431
+ $this->assertEquals($xml, $body);
432
+ }
433
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/ResponseLocation/BodyLocationTest.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Command\Guzzle\ResponseLocation;
3
+
4
+ use GuzzleHttp\Command\Command;
5
+ use GuzzleHttp\Command\Guzzle\Parameter;
6
+ use GuzzleHttp\Command\Guzzle\ResponseLocation\BodyLocation;
7
+ use GuzzleHttp\Message\Response;
8
+ use GuzzleHttp\Stream\Stream;
9
+
10
+ /**
11
+ * @covers \GuzzleHttp\Command\Guzzle\ResponseLocation\BodyLocation
12
+ * @covers \GuzzleHttp\Command\Guzzle\ResponseLocation\AbstractLocation
13
+ */
14
+ class BodyLocationTest extends \PHPUnit_Framework_TestCase
15
+ {
16
+ public function testVisitsLocation()
17
+ {
18
+ $l = new BodyLocation('body');
19
+ $command = new Command('foo', []);
20
+ $parameter = new Parameter([
21
+ 'name' => 'val',
22
+ 'filters' => ['strtoupper']
23
+ ]);
24
+ $response = new Response(200, [], Stream::factory('foo'));
25
+ $result = [];
26
+ $l->visit($command, $response, $parameter, $result);
27
+ $this->assertEquals('FOO', $result['val']);
28
+ }
29
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/ResponseLocation/HeaderLocationTest.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Command\Guzzle\ResponseLocation;
3
+
4
+ use GuzzleHttp\Command\Command;
5
+ use GuzzleHttp\Command\Guzzle\Parameter;
6
+ use GuzzleHttp\Command\Guzzle\ResponseLocation\HeaderLocation;
7
+ use GuzzleHttp\Message\Response;
8
+
9
+ /**
10
+ * @covers \GuzzleHttp\Command\Guzzle\ResponseLocation\HeaderLocation
11
+ * @covers \GuzzleHttp\Command\Guzzle\ResponseLocation\AbstractLocation
12
+ */
13
+ class HeaderLocationTest extends \PHPUnit_Framework_TestCase
14
+ {
15
+ public function testVisitsLocation()
16
+ {
17
+ $l = new HeaderLocation('header');
18
+ $command = new Command('foo', []);
19
+ $parameter = new Parameter([
20
+ 'name' => 'val',
21
+ 'sentAs' => 'X-Foo',
22
+ 'filters' => ['strtoupper']
23
+ ]);
24
+ $response = new Response(200, ['X-Foo' => 'bar']);
25
+ $result = [];
26
+ $l->visit($command, $response, $parameter, $result);
27
+ $this->assertEquals('BAR', $result['val']);
28
+ }
29
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/ResponseLocation/JsonLocationTest.php ADDED
@@ -0,0 +1,293 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Command\Guzzle\ResponseLocation;
3
+
4
+ use GuzzleHttp\Client;
5
+ use GuzzleHttp\Command\Command;
6
+ use GuzzleHttp\Command\Guzzle\Description;
7
+ use GuzzleHttp\Command\Guzzle\GuzzleClient;
8
+ use GuzzleHttp\Command\Guzzle\Parameter;
9
+ use GuzzleHttp\Command\Guzzle\ResponseLocation\JsonLocation;
10
+ use GuzzleHttp\Event\BeforeEvent;
11
+ use GuzzleHttp\Message\Response;
12
+ use GuzzleHttp\Stream\Stream;
13
+
14
+ /**
15
+ * @covers \GuzzleHttp\Command\Guzzle\ResponseLocation\JsonLocation
16
+ * @covers \GuzzleHttp\Command\Guzzle\Subscriber\ProcessResponse
17
+ */
18
+ class JsonLocationTest extends \PHPUnit_Framework_TestCase
19
+ {
20
+ public function testVisitsLocation()
21
+ {
22
+ $l = new JsonLocation('json');
23
+ $command = new Command('foo', []);
24
+ $parameter = new Parameter([
25
+ 'name' => 'val',
26
+ 'sentAs' => 'vim',
27
+ 'filters' => ['strtoupper']
28
+ ]);
29
+ $response = new Response(200, [], Stream::factory('{"vim":"bar"}'));
30
+ $result = [];
31
+ $l->before($command, $response, $parameter, $result);
32
+ $l->visit($command, $response, $parameter, $result);
33
+ $this->assertEquals('BAR', $result['val']);
34
+ }
35
+
36
+ public function testVisitsAdditionalProperties()
37
+ {
38
+ $l = new JsonLocation('json');
39
+ $command = new Command('foo', []);
40
+ $parameter = new Parameter();
41
+ $model = new Parameter(['additionalProperties' => ['location' => 'json']]);
42
+ $response = new Response(200, [], Stream::factory('{"vim":"bar","qux":[1,2]}'));
43
+ $result = [];
44
+ $l->before($command, $response, $parameter, $result);
45
+ $l->visit($command, $response, $parameter, $result);
46
+ $l->after($command, $response, $model, $result);
47
+ $this->assertEquals('bar', $result['vim']);
48
+ $this->assertEquals([1, 2], $result['qux']);
49
+ }
50
+
51
+ public function testVisitsAdditionalPropertiesWithEmptyResponse()
52
+ {
53
+ $l = new JsonLocation('json');
54
+ $command = new Command('foo', []);
55
+ $parameter = new Parameter();
56
+ $model = new Parameter(['additionalProperties' => ['location' => 'json']]);
57
+ $response = new Response(204);
58
+ $result = [];
59
+ $l->before($command, $response, $parameter, $result);
60
+ $l->visit($command, $response, $parameter, $result);
61
+ $l->after($command, $response, $model, $result);
62
+ $this->assertEquals([], $result);
63
+ }
64
+
65
+ public function jsonProvider()
66
+ {
67
+ return [
68
+ [null, [['foo' => 'BAR'], ['baz' => 'BAM']]],
69
+ ['under_me', ['under_me' => [['foo' => 'BAR'], ['baz' => 'BAM']]]],
70
+ ];
71
+ }
72
+
73
+ /**
74
+ * @dataProvider jsonProvider
75
+ */
76
+ public function testVisitsTopLevelArrays($name, $expected)
77
+ {
78
+ $hclient = new Client();
79
+
80
+ $hclient->getEmitter()->on('before', function (BeforeEvent $event) {
81
+ $json = [
82
+ ['foo' => 'bar'],
83
+ ['baz' => 'bam'],
84
+ ];
85
+ $response = new Response(200, [
86
+ 'Content-Type' => 'application/json'
87
+ ], Stream::factory(json_encode($json)));
88
+ $event->intercept($response);
89
+ });
90
+
91
+ $description = new Description([
92
+ 'operations' => [
93
+ 'foo' => [
94
+ 'uri' => 'http://httpbin.org',
95
+ 'httpMethod' => 'GET',
96
+ 'responseModel' => 'j'
97
+ ]
98
+ ],
99
+ 'models' => [
100
+ 'j' => [
101
+ 'type' => 'array',
102
+ 'location' => 'json',
103
+ 'name' => $name,
104
+ 'items' => [
105
+ 'type' => 'object',
106
+ 'additionalProperties' => [
107
+ 'type' => 'string',
108
+ 'filters' => ['strtoupper']
109
+ ]
110
+ ]
111
+ ]
112
+ ]
113
+ ]);
114
+ $client = new GuzzleClient($hclient, $description);
115
+ $result = $client->foo();
116
+ $this->assertEquals($expected, $result);
117
+ }
118
+
119
+ public function testVisitsNestedArrays()
120
+ {
121
+ $hclient = new Client();
122
+
123
+ $hclient->getEmitter()->on('before', function (BeforeEvent $event) {
124
+ $json = [
125
+ 'scalar' => 'foo',
126
+ 'nested' => [
127
+ 'bar',
128
+ 'baz'
129
+ ]
130
+ ];
131
+ $response = new Response(200, [
132
+ 'Content-Type' => 'application/json'
133
+ ], Stream::factory(json_encode($json)));
134
+ $event->intercept($response);
135
+ });
136
+
137
+ $description = new Description([
138
+ 'operations' => [
139
+ 'foo' => [
140
+ 'uri' => 'http://httpbin.org',
141
+ 'httpMethod' => 'GET',
142
+ 'responseModel' => 'j'
143
+ ]
144
+ ],
145
+ 'models' => [
146
+ 'j' => [
147
+ 'type' => 'object',
148
+ 'location' => 'json',
149
+ 'properties' => [
150
+ 'scalar' => ['type' => 'string'],
151
+ 'nested' => [
152
+ 'type' => 'array',
153
+ 'items' => ['type' => 'string']
154
+ ]
155
+ ]
156
+ ]
157
+ ]
158
+ ]);
159
+ $client = new GuzzleClient($hclient, $description);
160
+ $result = $client->foo();
161
+ $expected = [
162
+ 'scalar' => 'foo',
163
+ 'nested' => [
164
+ 'bar',
165
+ 'baz'
166
+ ]
167
+ ];
168
+ $this->assertEquals($expected, $result);
169
+ }
170
+
171
+ public function nestedProvider()
172
+ {
173
+ return [
174
+ [
175
+ [
176
+ 'operations' => [
177
+ 'foo' => [
178
+ 'uri' => 'http://httpbin.org',
179
+ 'httpMethod' => 'GET',
180
+ 'responseModel' => 'j'
181
+ ]
182
+ ],
183
+ 'models' => [
184
+ 'j' => [
185
+ 'type' => 'object',
186
+ 'properties' => [
187
+ 'nested' => [
188
+ 'location' => 'json',
189
+ 'type' => 'object',
190
+ 'properties' => [
191
+ 'foo' => ['type' => 'string'],
192
+ 'bar' => ['type' => 'number'],
193
+ 'bam' => [
194
+ 'type' => 'object',
195
+ 'properties' => [
196
+ 'abc' => [
197
+ 'type' => 'number'
198
+ ]
199
+ ]
200
+ ]
201
+ ]
202
+ ]
203
+ ],
204
+ 'additionalProperties' => [
205
+ 'location' => 'json',
206
+ 'type' => 'string',
207
+ 'filters' => ['strtoupper']
208
+ ]
209
+ ]
210
+ ]
211
+ ]
212
+ ],
213
+ [
214
+ [
215
+ 'operations' => [
216
+ 'foo' => [
217
+ 'uri' => 'http://httpbin.org',
218
+ 'httpMethod' => 'GET',
219
+ 'responseModel' => 'j'
220
+ ]
221
+ ],
222
+ 'models' => [
223
+ 'j' => [
224
+ 'type' => 'object',
225
+ 'location' => 'json',
226
+ 'properties' => [
227
+ 'nested' => [
228
+ 'type' => 'object',
229
+ 'properties' => [
230
+ 'foo' => ['type' => 'string'],
231
+ 'bar' => ['type' => 'number'],
232
+ 'bam' => [
233
+ 'type' => 'object',
234
+ 'properties' => [
235
+ 'abc' => [
236
+ 'type' => 'number'
237
+ ]
238
+ ]
239
+ ]
240
+ ]
241
+ ]
242
+ ],
243
+ 'additionalProperties' => [
244
+ 'type' => 'string',
245
+ 'filters' => ['strtoupper']
246
+ ]
247
+ ]
248
+ ]
249
+ ]
250
+ ]
251
+ ];
252
+ }
253
+
254
+ /**
255
+ * @dataProvider nestedProvider
256
+ */
257
+ public function testVisitsNestedProperties($desc)
258
+ {
259
+ $hclient = new Client();
260
+ $hclient->getEmitter()->on('before', function (BeforeEvent $event) {
261
+ $json = [
262
+ 'nested' => [
263
+ 'foo' => 'abc',
264
+ 'bar' => 123,
265
+ 'bam' => [
266
+ 'abc' => 456
267
+ ]
268
+ ],
269
+ 'baz' => 'boo'
270
+ ];
271
+ $response = new Response(200, [
272
+ 'Content-Type' => 'application/json'
273
+ ], Stream::factory(json_encode($json)));
274
+ $event->intercept($response);
275
+ });
276
+
277
+ $description = new Description($desc);
278
+ $client = new GuzzleClient($hclient, $description);
279
+ $result = $client->foo();
280
+ $expected = [
281
+ 'nested' => [
282
+ 'foo' => 'abc',
283
+ 'bar' => 123,
284
+ 'bam' => [
285
+ 'abc' => 456
286
+ ]
287
+ ],
288
+ 'baz' => 'BOO'
289
+ ];
290
+
291
+ $this->assertEquals($expected, $result);
292
+ }
293
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/ResponseLocation/ReasonPhraseLocationTest.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Command\Guzzle\ResponseLocation;
3
+
4
+ use GuzzleHttp\Command\Command;
5
+ use GuzzleHttp\Command\Guzzle\Parameter;
6
+ use GuzzleHttp\Command\Guzzle\ResponseLocation\ReasonPhraseLocation;
7
+ use GuzzleHttp\Message\Response;
8
+
9
+ /**
10
+ * @covers \GuzzleHttp\Command\Guzzle\ResponseLocation\ReasonPhraseLocation
11
+ * @covers \GuzzleHttp\Command\Guzzle\ResponseLocation\AbstractLocation
12
+ */
13
+ class ReasonPhraseLocationTest extends \PHPUnit_Framework_TestCase
14
+ {
15
+ public function testVisitsLocation()
16
+ {
17
+ $l = new ReasonPhraseLocation('reasonPhrase');
18
+ $command = new Command('foo', []);
19
+ $parameter = new Parameter([
20
+ 'name' => 'val',
21
+ 'filters' => ['strtolower']
22
+ ]);
23
+ $response = new Response(200);
24
+ $result = [];
25
+ $l->visit($command, $response, $parameter, $result);
26
+ $this->assertEquals('ok', $result['val']);
27
+ }
28
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/ResponseLocation/StatusCodeLocationTest.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Command\Guzzle\ResponseLocation;
3
+
4
+ use GuzzleHttp\Command\Command;
5
+ use GuzzleHttp\Command\Guzzle\Parameter;
6
+ use GuzzleHttp\Command\Guzzle\ResponseLocation\StatusCodeLocation;
7
+ use GuzzleHttp\Message\Response;
8
+
9
+ /**
10
+ * @covers \GuzzleHttp\Command\Guzzle\ResponseLocation\StatusCodeLocation
11
+ * @covers \GuzzleHttp\Command\Guzzle\ResponseLocation\AbstractLocation
12
+ */
13
+ class StatusCodeLocationTest extends \PHPUnit_Framework_TestCase
14
+ {
15
+ public function testVisitsLocation()
16
+ {
17
+ $l = new StatusCodeLocation('statusCode');
18
+ $command = new Command('foo', []);
19
+ $parameter = new Parameter(['name' => 'val']);
20
+ $response = new Response(200);
21
+ $result = [];
22
+ $l->visit($command, $response, $parameter, $result);
23
+ $this->assertEquals(200, $result['val']);
24
+ }
25
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/ResponseLocation/XmlLocationTest.php ADDED
@@ -0,0 +1,764 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Command\Guzzle\ResponseLocation;
3
+
4
+ use GuzzleHttp\Command\Command;
5
+ use GuzzleHttp\Command\Guzzle\Parameter;
6
+ use GuzzleHttp\Command\Guzzle\ResponseLocation\XmlLocation;
7
+ use GuzzleHttp\Message\Response;
8
+ use GuzzleHttp\Stream\Stream;
9
+
10
+ /**
11
+ * @covers \GuzzleHttp\Command\Guzzle\ResponseLocation\XmlLocation
12
+ */
13
+ class XmlLocationTest extends \PHPUnit_Framework_TestCase
14
+ {
15
+ public function testVisitsLocation()
16
+ {
17
+ $l = new XmlLocation('xml');
18
+ $command = new Command('foo', []);
19
+ $parameter = new Parameter([
20
+ 'name' => 'val',
21
+ 'sentAs' => 'vim',
22
+ 'filters' => ['strtoupper']
23
+ ]);
24
+ $model = new Parameter();
25
+ $response = new Response(200, [], Stream::factory('<w><vim>bar</vim></w>'));
26
+ $result = [];
27
+ $l->before($command, $response, $model, $result);
28
+ $l->visit($command, $response, $parameter, $result);
29
+ $l->after($command, $response, $model, $result);
30
+ $this->assertEquals('BAR', $result['val']);
31
+ }
32
+
33
+ public function testVisitsAdditionalProperties()
34
+ {
35
+ $l = new XmlLocation('xml');
36
+ $command = new Command('foo', []);
37
+ $parameter = new Parameter();
38
+ $model = new Parameter(['additionalProperties' => ['location' => 'xml']]);
39
+ $response = new Response(200, [], Stream::factory('<w><vim>bar</vim></w>'));
40
+ $result = [];
41
+ $l->before($command, $response, $parameter, $result);
42
+ $l->visit($command, $response, $parameter, $result);
43
+ $l->after($command, $response, $model, $result);
44
+ $this->assertEquals('bar', $result['vim']);
45
+ }
46
+
47
+ public function testEnsuresFlatArraysAreFlat()
48
+ {
49
+ $param = new Parameter(array(
50
+ 'location' => 'xml',
51
+ 'name' => 'foo',
52
+ 'type' => 'array',
53
+ 'items' => array('type' => 'string')
54
+ ));
55
+
56
+ $xml = '<xml><foo>bar</foo><foo>baz</foo></xml>';
57
+ $this->xmlTest($param, $xml, array('foo' => array('bar', 'baz')));
58
+ $this->xmlTest($param, '<xml><foo>bar</foo></xml>', array('foo' => array('bar')));
59
+ }
60
+
61
+ public function xmlDataProvider()
62
+ {
63
+ $param = new Parameter(array(
64
+ 'location' => 'xml',
65
+ 'name' => 'Items',
66
+ 'type' => 'array',
67
+ 'items' => array(
68
+ 'type' => 'object',
69
+ 'name' => 'Item',
70
+ 'properties' => array(
71
+ 'Bar' => array('type' => 'string'),
72
+ 'Baz' => array('type' => 'string')
73
+ )
74
+ )
75
+ ));
76
+
77
+ return array(
78
+ array($param, '<Test><Items><Item><Bar>1</Bar></Item><Item><Bar>2</Bar></Item></Items></Test>', array(
79
+ 'Items' => array(
80
+ array('Bar' => 1),
81
+ array('Bar' => 2)
82
+ )
83
+ )),
84
+ array($param, '<Test><Items><Item><Bar>1</Bar></Item></Items></Test>', array(
85
+ 'Items' => array(
86
+ array('Bar' => 1)
87
+ )
88
+ )),
89
+ array($param, '<Test><Items /></Test>', array(
90
+ 'Items' => array()
91
+ ))
92
+ );
93
+ }
94
+
95
+ /**
96
+ * @dataProvider xmlDataProvider
97
+ */
98
+ public function testEnsuresWrappedArraysAreInCorrectLocations($param, $xml, $expected)
99
+ {
100
+ $l = new XmlLocation('xml');
101
+ $command = new Command('foo', []);
102
+ $model = new Parameter();
103
+ $response = new Response(200, [], Stream::factory($xml));
104
+ $result = [];
105
+ $l->before($command, $response, $param, $result);
106
+ $l->visit($command, $response, $param, $result);
107
+ $l->after($command, $response, $model, $result);
108
+ $this->assertEquals($result, $expected);
109
+ }
110
+
111
+ public function testCanRenameValues()
112
+ {
113
+ $param = new Parameter(array(
114
+ 'name' => 'TerminatingInstances',
115
+ 'type' => 'array',
116
+ 'location' => 'xml',
117
+ 'sentAs' => 'instancesSet',
118
+ 'items' => array(
119
+ 'name' => 'item',
120
+ 'type' => 'object',
121
+ 'sentAs' => 'item',
122
+ 'properties' => array(
123
+ 'InstanceId' => array(
124
+ 'type' => 'string',
125
+ 'sentAs' => 'instanceId',
126
+ ),
127
+ 'CurrentState' => array(
128
+ 'type' => 'object',
129
+ 'sentAs' => 'currentState',
130
+ 'properties' => array(
131
+ 'Code' => array(
132
+ 'type' => 'numeric',
133
+ 'sentAs' => 'code',
134
+ ),
135
+ 'Name' => array(
136
+ 'type' => 'string',
137
+ 'sentAs' => 'name',
138
+ ),
139
+ ),
140
+ ),
141
+ 'PreviousState' => array(
142
+ 'type' => 'object',
143
+ 'sentAs' => 'previousState',
144
+ 'properties' => array(
145
+ 'Code' => array(
146
+ 'type' => 'numeric',
147
+ 'sentAs' => 'code',
148
+ ),
149
+ 'Name' => array(
150
+ 'type' => 'string',
151
+ 'sentAs' => 'name',
152
+ ),
153
+ ),
154
+ ),
155
+ ),
156
+ )
157
+ ));
158
+
159
+ $xml = '
160
+ <xml>
161
+ <instancesSet>
162
+ <item>
163
+ <instanceId>i-3ea74257</instanceId>
164
+ <currentState>
165
+ <code>32</code>
166
+ <name>shutting-down</name>
167
+ </currentState>
168
+ <previousState>
169
+ <code>16</code>
170
+ <name>running</name>
171
+ </previousState>
172
+ </item>
173
+ </instancesSet>
174
+ </xml>
175
+ ';
176
+
177
+ $this->xmlTest($param, $xml, array(
178
+ 'TerminatingInstances' => array(
179
+ array(
180
+ 'InstanceId' => 'i-3ea74257',
181
+ 'CurrentState' => array(
182
+ 'Code' => '32',
183
+ 'Name' => 'shutting-down',
184
+ ),
185
+ 'PreviousState' => array(
186
+ 'Code' => '16',
187
+ 'Name' => 'running',
188
+ )
189
+ )
190
+ )
191
+ ));
192
+ }
193
+
194
+ public function testCanRenameAttributes()
195
+ {
196
+ $param = new Parameter(array(
197
+ 'name' => 'RunningQueues',
198
+ 'type' => 'array',
199
+ 'location' => 'xml',
200
+ 'items' => array(
201
+ 'type' => 'object',
202
+ 'sentAs' => 'item',
203
+ 'properties' => array(
204
+ 'QueueId' => array(
205
+ 'type' => 'string',
206
+ 'sentAs' => 'queue_id',
207
+ 'data' => array(
208
+ 'xmlAttribute' => true,
209
+ ),
210
+ ),
211
+ 'CurrentState' => array(
212
+ 'type' => 'object',
213
+ 'properties' => array(
214
+ 'Code' => array(
215
+ 'type' => 'numeric',
216
+ 'sentAs' => 'code',
217
+ 'data' => array(
218
+ 'xmlAttribute' => true,
219
+ ),
220
+ ),
221
+ 'Name' => array(
222
+ 'sentAs' => 'name',
223
+ 'data' => array(
224
+ 'xmlAttribute' => true,
225
+ ),
226
+ ),
227
+ ),
228
+ ),
229
+ 'PreviousState' => array(
230
+ 'type' => 'object',
231
+ 'properties' => array(
232
+ 'Code' => array(
233
+ 'type' => 'numeric',
234
+ 'sentAs' => 'code',
235
+ 'data' => array(
236
+ 'xmlAttribute' => true,
237
+ ),
238
+ ),
239
+ 'Name' => array(
240
+ 'sentAs' => 'name',
241
+ 'data' => array(
242
+ 'xmlAttribute' => true,
243
+ ),
244
+ ),
245
+ ),
246
+ ),
247
+ ),
248
+ )
249
+ ));
250
+
251
+ $xml = '
252
+ <wrap>
253
+ <RunningQueues>
254
+ <item queue_id="q-3ea74257">
255
+ <CurrentState code="32" name="processing" />
256
+ <PreviousState code="16" name="wait" />
257
+ </item>
258
+ </RunningQueues>
259
+ </wrap>';
260
+
261
+ $this->xmlTest($param, $xml, array(
262
+ 'RunningQueues' => array(
263
+ array(
264
+ 'QueueId' => 'q-3ea74257',
265
+ 'CurrentState' => array(
266
+ 'Code' => '32',
267
+ 'Name' => 'processing',
268
+ ),
269
+ 'PreviousState' => array(
270
+ 'Code' => '16',
271
+ 'Name' => 'wait',
272
+ ),
273
+ ),
274
+ )
275
+ ));
276
+ }
277
+
278
+ public function testAddsEmptyArraysWhenValueIsMissing()
279
+ {
280
+ $param = new Parameter(array(
281
+ 'name' => 'Foo',
282
+ 'type' => 'array',
283
+ 'location' => 'xml',
284
+ 'items' => array(
285
+ 'type' => 'object',
286
+ 'properties' => array(
287
+ 'Baz' => array('type' => 'array'),
288
+ 'Bar' => array(
289
+ 'type' => 'object',
290
+ 'properties' => array(
291
+ 'Baz' => array('type' => 'array'),
292
+ )
293
+ )
294
+ )
295
+ )
296
+ ));
297
+
298
+ $xml = '<xml><Foo><Bar></Bar></Foo></xml>';
299
+
300
+ $this->xmlTest($param, $xml, array(
301
+ 'Foo' => array(
302
+ array(
303
+ 'Bar' => array()
304
+ )
305
+ )
306
+ ));
307
+ }
308
+
309
+ /**
310
+ * @group issue-399
311
+ * @link https://github.com/guzzle/guzzle/issues/399
312
+ */
313
+ public function testDiscardingUnknownProperties()
314
+ {
315
+ $param = new Parameter(array(
316
+ 'name' => 'foo',
317
+ 'type' => 'object',
318
+ 'additionalProperties' => false,
319
+ 'properties' => array(
320
+ 'bar' => array(
321
+ 'type' => 'string',
322
+ 'name' => 'bar',
323
+ ),
324
+ ),
325
+ ));
326
+
327
+ $xml = '
328
+ <xml>
329
+ <foo>
330
+ <bar>15</bar>
331
+ <unknown>discard me</unknown>
332
+ </foo>
333
+ </xml>
334
+ ';
335
+
336
+ $this->xmlTest($param, $xml, array(
337
+ 'foo' => array(
338
+ 'bar' => 15
339
+ )
340
+ ));
341
+ }
342
+
343
+ /**
344
+ * @group issue-399
345
+ * @link https://github.com/guzzle/guzzle/issues/399
346
+ */
347
+ public function testDiscardingUnknownPropertiesWithAliasing()
348
+ {
349
+ $param = new Parameter(array(
350
+ 'name' => 'foo',
351
+ 'type' => 'object',
352
+ 'additionalProperties' => false,
353
+ 'properties' => array(
354
+ 'bar' => array(
355
+ 'name' => 'bar',
356
+ 'sentAs' => 'baz',
357
+ ),
358
+ ),
359
+ ));
360
+
361
+ $xml = '
362
+ <xml>
363
+ <foo>
364
+ <baz>15</baz>
365
+ <unknown>discard me</unknown>
366
+ </foo>
367
+ </xml>
368
+ ';
369
+
370
+ $this->xmlTest($param, $xml, array(
371
+ 'foo' => array(
372
+ 'bar' => 15
373
+ )
374
+ ));
375
+ }
376
+
377
+ public function testProcessingOfNestedAdditionalProperties()
378
+ {
379
+ $param = new Parameter(array(
380
+ 'name' => 'foo',
381
+ 'type' => 'object',
382
+ 'additionalProperties' => true,
383
+ 'properties' => array(
384
+ 'bar' => array(
385
+ 'name' => 'bar',
386
+ 'sentAs' => 'baz',
387
+ ),
388
+ 'nestedNoAdditional' => array(
389
+ 'type' => 'object',
390
+ 'additionalProperties' => false,
391
+ 'properties' => array(
392
+ 'id' => array(
393
+ 'type' => 'integer'
394
+ )
395
+ )
396
+ ),
397
+ 'nestedWithAdditional' => array(
398
+ 'type' => 'object',
399
+ 'additionalProperties' => true,
400
+ ),
401
+ 'nestedWithAdditionalSchema' => array(
402
+ 'type' => 'object',
403
+ 'additionalProperties' => array(
404
+ 'type' => 'array',
405
+ 'items' => array(
406
+ 'type' => 'string'
407
+ )
408
+ ),
409
+ ),
410
+ ),
411
+ ));
412
+
413
+ $xml = '
414
+ <xml>
415
+ <foo>
416
+ <baz>15</baz>
417
+ <additional>include me</additional>
418
+ <nestedNoAdditional>
419
+ <id>15</id>
420
+ <unknown>discard me</unknown>
421
+ </nestedNoAdditional>
422
+ <nestedWithAdditional>
423
+ <id>15</id>
424
+ <additional>include me</additional>
425
+ </nestedWithAdditional>
426
+ <nestedWithAdditionalSchema>
427
+ <arrayA>
428
+ <item>1</item>
429
+ <item>2</item>
430
+ <item>3</item>
431
+ </arrayA>
432
+ <arrayB>
433
+ <item>A</item>
434
+ <item>B</item>
435
+ <item>C</item>
436
+ </arrayB>
437
+ </nestedWithAdditionalSchema>
438
+ </foo>
439
+ </xml>
440
+ ';
441
+
442
+ $this->xmlTest($param, $xml, array(
443
+ 'foo' => array(
444
+ 'bar' => '15',
445
+ 'additional' => 'include me',
446
+ 'nestedNoAdditional' => array(
447
+ 'id' => '15'
448
+ ),
449
+ 'nestedWithAdditional' => array(
450
+ 'id' => '15',
451
+ 'additional' => 'include me'
452
+ ),
453
+ 'nestedWithAdditionalSchema' => array(
454
+ 'arrayA' => array('1', '2', '3'),
455
+ 'arrayB' => array('A', 'B', 'C'),
456
+ )
457
+
458
+ )
459
+ ));
460
+ }
461
+
462
+ public function testConvertsMultipleAssociativeElementsToArray()
463
+ {
464
+ $param = new Parameter(array(
465
+ 'name' => 'foo',
466
+ 'type' => 'object',
467
+ 'additionalProperties' => true
468
+ ));
469
+
470
+ $xml = '
471
+ <xml>
472
+ <foo>
473
+ <baz>15</baz>
474
+ <baz>25</baz>
475
+ <bar>hi</bar>
476
+ <bam>test</bam>
477
+ <bam attr="hi" />
478
+ </foo>
479
+ </xml>
480
+ ';
481
+
482
+ $this->xmlTest($param, $xml, [
483
+ 'foo' => [
484
+ 'baz' => ['15', '25'],
485
+ 'bar' => 'hi',
486
+ 'bam' => [
487
+ 'test',
488
+ ['@attributes' => ['attr' => 'hi']]
489
+ ]
490
+ ]
491
+ ]);
492
+ }
493
+
494
+ public function testUnderstandsNamespaces()
495
+ {
496
+ $param = new Parameter(array(
497
+ 'name' => 'nstest',
498
+ 'type' => 'array',
499
+ 'location' => 'xml',
500
+ 'items' => array(
501
+ 'name' => 'item',
502
+ 'type' => 'object',
503
+ 'sentAs' => 'item',
504
+ 'properties' => array(
505
+ 'id' => array(
506
+ 'type' => 'string',
507
+ ),
508
+ 'isbn:number' => array(
509
+ 'type' => 'string',
510
+ ),
511
+ 'meta' => array(
512
+ 'type' => 'object',
513
+ 'sentAs' => 'abstract:meta',
514
+ 'properties' => array(
515
+ 'foo' => array(
516
+ 'type' => 'numeric',
517
+ ),
518
+ 'bar' => array(
519
+ 'type' => 'object',
520
+ 'properties' => array(
521
+ 'attribute' => array(
522
+ 'type' => 'string',
523
+ 'data' => array(
524
+ 'xmlAttribute' => true,
525
+ 'xmlNs' => 'abstract'
526
+ ),
527
+ )
528
+ )
529
+ ),
530
+ ),
531
+ ),
532
+ 'gamma' => array(
533
+ 'type' => 'object',
534
+ 'data' => array(
535
+ 'xmlNs' => 'abstract'
536
+ ),
537
+ 'additionalProperties' => true
538
+ ),
539
+ 'nonExistent' => array(
540
+ 'type' => 'object',
541
+ 'data' => array(
542
+ 'xmlNs' => 'abstract'
543
+ ),
544
+ 'additionalProperties' => true
545
+ ),
546
+ 'nonExistent2' => array(
547
+ 'type' => 'object',
548
+ 'additionalProperties' => true
549
+ ),
550
+ ),
551
+ )
552
+ ));
553
+
554
+ $xml = '
555
+ <xml>
556
+ <nstest xmlns:isbn="urn:ISBN:0-395-36341-6" xmlns:abstract="urn:my.org:abstract">
557
+ <item>
558
+ <id>101</id>
559
+ <isbn:number>1568491379</isbn:number>
560
+ <abstract:meta>
561
+ <foo>10</foo>
562
+ <bar abstract:attribute="foo"></bar>
563
+ </abstract:meta>
564
+ <abstract:gamma>
565
+ <foo>bar</foo>
566
+ </abstract:gamma>
567
+ </item>
568
+ <item>
569
+ <id>102</id>
570
+ <isbn:number>1568491999</isbn:number>
571
+ <abstract:meta>
572
+ <foo>20</foo>
573
+ <bar abstract:attribute="bar"></bar>
574
+ </abstract:meta>
575
+ <abstract:gamma>
576
+ <foo>baz</foo>
577
+ </abstract:gamma>
578
+ </item>
579
+ </nstest>
580
+ </xml>
581
+ ';
582
+
583
+ $this->xmlTest($param, $xml, array(
584
+ 'nstest' => array(
585
+ array(
586
+ 'id' => '101',
587
+ 'isbn:number' => 1568491379,
588
+ 'meta' => array(
589
+ 'foo' => 10,
590
+ 'bar' => array(
591
+ 'attribute' => 'foo'
592
+ ),
593
+ ),
594
+ 'gamma' => array(
595
+ 'foo' => 'bar'
596
+ )
597
+ ),
598
+ array(
599
+ 'id' => '102',
600
+ 'isbn:number' => 1568491999,
601
+ 'meta' => array(
602
+ 'foo' => 20,
603
+ 'bar' => array(
604
+ 'attribute' => 'bar'
605
+ ),
606
+ ),
607
+ 'gamma' => array(
608
+ 'foo' => 'baz'
609
+ )
610
+ ),
611
+ )
612
+ ));
613
+ }
614
+
615
+ public function testCanWalkUndefinedPropertiesWithNamespace()
616
+ {
617
+ $param = new Parameter(array(
618
+ 'name' => 'nstest',
619
+ 'type' => 'array',
620
+ 'location' => 'xml',
621
+ 'items' => array(
622
+ 'name' => 'item',
623
+ 'type' => 'object',
624
+ 'sentAs' => 'item',
625
+ 'additionalProperties' => array(
626
+ 'type' => 'object',
627
+ 'data' => array(
628
+ 'xmlNs' => 'abstract'
629
+ ),
630
+ ),
631
+ 'properties' => array(
632
+ 'id' => array(
633
+ 'type' => 'string',
634
+ ),
635
+ 'isbn:number' => array(
636
+ 'type' => 'string',
637
+ )
638
+ )
639
+ )
640
+ ));
641
+
642
+ $xml = '
643
+ <xml>
644
+ <nstest xmlns:isbn="urn:ISBN:0-395-36341-6" xmlns:abstract="urn:my.org:abstract">
645
+ <item>
646
+ <id>101</id>
647
+ <isbn:number>1568491379</isbn:number>
648
+ <abstract:meta>
649
+ <foo>10</foo>
650
+ <bar>baz</bar>
651
+ </abstract:meta>
652
+ </item>
653
+ <item>
654
+ <id>102</id>
655
+ <isbn:number>1568491999</isbn:number>
656
+ <abstract:meta>
657
+ <foo>20</foo>
658
+ <bar>foo</bar>
659
+ </abstract:meta>
660
+ </item>
661
+ </nstest>
662
+ </xml>
663
+ ';
664
+
665
+ $this->xmlTest($param, $xml, array(
666
+ 'nstest' => array(
667
+ array(
668
+ 'id' => '101',
669
+ 'isbn:number' => 1568491379,
670
+ 'meta' => array(
671
+ 'foo' => 10,
672
+ 'bar' => 'baz'
673
+ )
674
+ ),
675
+ array(
676
+ 'id' => '102',
677
+ 'isbn:number' => 1568491999,
678
+ 'meta' => array(
679
+ 'foo' => 20,
680
+ 'bar' => 'foo'
681
+ )
682
+ ),
683
+ )
684
+ ));
685
+ }
686
+
687
+ public function testCanWalkSimpleArrayWithNamespace()
688
+ {
689
+ $param = new Parameter(array(
690
+ 'name' => 'nstest',
691
+ 'type' => 'array',
692
+ 'location' => 'xml',
693
+ 'items' => array(
694
+ 'type' => 'string',
695
+ 'sentAs' => 'number',
696
+ 'data' => array(
697
+ 'xmlNs' => 'isbn'
698
+ )
699
+ )
700
+ ));
701
+
702
+ $xml = '
703
+ <xml>
704
+ <nstest xmlns:isbn="urn:ISBN:0-395-36341-6">
705
+ <isbn:number>1568491379</isbn:number>
706
+ <isbn:number>1568491999</isbn:number>
707
+ <isbn:number>1568492999</isbn:number>
708
+ </nstest>
709
+ </xml>
710
+ ';
711
+
712
+ $this->xmlTest($param, $xml, array(
713
+ 'nstest' => array(
714
+ 1568491379,
715
+ 1568491999,
716
+ 1568492999,
717
+ )
718
+ ));
719
+ }
720
+
721
+ public function testCanWalkSimpleArrayWithNamespace2()
722
+ {
723
+ $param = new Parameter(array(
724
+ 'name' => 'nstest',
725
+ 'type' => 'array',
726
+ 'location' => 'xml',
727
+ 'items' => array(
728
+ 'type' => 'string',
729
+ 'sentAs' => 'isbn:number',
730
+ )
731
+ ));
732
+
733
+ $xml = '
734
+ <xml>
735
+ <nstest xmlns:isbn="urn:ISBN:0-395-36341-6">
736
+ <isbn:number>1568491379</isbn:number>
737
+ <isbn:number>1568491999</isbn:number>
738
+ <isbn:number>1568492999</isbn:number>
739
+ </nstest>
740
+ </xml>
741
+ ';
742
+
743
+ $this->xmlTest($param, $xml, array(
744
+ 'nstest' => array(
745
+ 1568491379,
746
+ 1568491999,
747
+ 1568492999,
748
+ )
749
+ ));
750
+ }
751
+
752
+ private function xmlTest(Parameter $param, $xml, $expected)
753
+ {
754
+ $l = new XmlLocation('xml');
755
+ $command = new Command('foo', []);
756
+ $model = new Parameter();
757
+ $response = new Response(200, [], Stream::factory($xml));
758
+ $result = [];
759
+ $l->before($command, $response, $param, $result);
760
+ $l->visit($command, $response, $param, $result);
761
+ $l->after($command, $response, $model, $result);
762
+ $this->assertEquals($expected, $result);
763
+ }
764
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/SchemaFormatterTest.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Command\Guzzle;
3
+
4
+ use GuzzleHttp\Command\Guzzle\SchemaFormatter;
5
+
6
+ /**
7
+ * @covers \GuzzleHttp\Command\Guzzle\SchemaFormatter
8
+ */
9
+ class SchemaFormatterTest extends \PHPUnit_Framework_TestCase
10
+ {
11
+ public function dateTimeProvider()
12
+ {
13
+ $dateUtc = 'October 13, 2012 16:15:46 UTC';
14
+ $dateOffset = 'October 13, 2012 10:15:46 -06:00';
15
+ $expectedDateTime = '2012-10-13T16:15:46Z';
16
+
17
+ return array(
18
+ array('foo', 'does-not-exist', 'foo'),
19
+ array($dateUtc, 'date-time', $expectedDateTime),
20
+ array($dateUtc, 'date-time-http', 'Sat, 13 Oct 2012 16:15:46 GMT'),
21
+ array($dateUtc, 'date', '2012-10-13'),
22
+ array($dateUtc, 'timestamp', strtotime($dateUtc)),
23
+ array(new \DateTime($dateUtc), 'timestamp', strtotime($dateUtc)),
24
+ array($dateUtc, 'time', '16:15:46'),
25
+ array(strtotime($dateUtc), 'time', '16:15:46'),
26
+ array(strtotime($dateUtc), 'timestamp', strtotime($dateUtc)),
27
+ array('true', 'boolean-string', 'true'),
28
+ array(true, 'boolean-string', 'true'),
29
+ array('false', 'boolean-string', 'false'),
30
+ array(false, 'boolean-string', 'false'),
31
+ array('1350144946', 'date-time', $expectedDateTime),
32
+ array(1350144946, 'date-time', $expectedDateTime),
33
+ array($dateOffset, 'date-time', $expectedDateTime)
34
+ );
35
+ }
36
+
37
+ /**
38
+ * @dataProvider dateTimeProvider
39
+ */
40
+ public function testFilters($value, $format, $result)
41
+ {
42
+ $this->assertEquals($result, (new SchemaFormatter)->format($format, $value));
43
+ }
44
+
45
+ /**
46
+ * @expectedException \InvalidArgumentException
47
+ */
48
+ public function testValidatesDateTimeInput()
49
+ {
50
+ (new SchemaFormatter)->format('date-time', false);
51
+ }
52
+
53
+ public function testEnsuresTimestampsAreIntegers()
54
+ {
55
+ $t = time();
56
+ $result = (new SchemaFormatter)->format('timestamp', $t);
57
+ $this->assertSame($t, $result);
58
+ $this->assertInternalType('int', $result);
59
+ }
60
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/SchemaValidatorTest.php ADDED
@@ -0,0 +1,313 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Guzzle\Tests\Service\Description;
3
+
4
+ use GuzzleHttp\Command\Guzzle\Parameter;
5
+ use GuzzleHttp\Command\Guzzle\SchemaValidator;
6
+
7
+ /**
8
+ * @covers GuzzleHttp\Command\Guzzle\SchemaValidator
9
+ */
10
+ class SchemaValidatorTest extends \PHPUnit_Framework_TestCase
11
+ {
12
+ /** @var SchemaValidator */
13
+ protected $validator;
14
+
15
+ public function setUp()
16
+ {
17
+ $this->validator = new SchemaValidator();
18
+ }
19
+
20
+ public function testValidatesArrayListsAreNumericallyIndexed()
21
+ {
22
+ $value = array(array(1));
23
+ $this->assertFalse($this->validator->validate($this->getComplexParam(), $value));
24
+ $this->assertEquals(
25
+ array('[Foo][0] must be an array of properties. Got a numerically indexed array.'),
26
+ $this->validator->getErrors()
27
+ );
28
+ }
29
+
30
+ public function testValidatesArrayListsContainProperItems()
31
+ {
32
+ $value = array(true);
33
+ $this->assertFalse($this->validator->validate($this->getComplexParam(), $value));
34
+ $this->assertEquals(
35
+ array('[Foo][0] must be of type object'),
36
+ $this->validator->getErrors()
37
+ );
38
+ }
39
+
40
+ public function testAddsDefaultValuesInLists()
41
+ {
42
+ $value = array(array());
43
+ $this->assertTrue($this->validator->validate($this->getComplexParam(), $value));
44
+ $this->assertEquals(array(array('Bar' => true)), $value);
45
+ }
46
+
47
+ public function testMergesDefaultValuesInLists()
48
+ {
49
+ $value = array(
50
+ array('Baz' => 'hello!'),
51
+ array('Bar' => false)
52
+ );
53
+ $this->assertTrue($this->validator->validate($this->getComplexParam(), $value));
54
+ $this->assertEquals(array(
55
+ array(
56
+ 'Baz' => 'hello!',
57
+ 'Bar' => true
58
+ ),
59
+ array('Bar' => false)
60
+ ), $value);
61
+ }
62
+
63
+ public function testCorrectlyConvertsParametersToArrayWhenArraysArePresent()
64
+ {
65
+ $param = $this->getComplexParam();
66
+ $result = $param->toArray();
67
+ $this->assertInternalType('array', $result['items']);
68
+ $this->assertEquals('array', $result['type']);
69
+ $this->assertInstanceOf('GuzzleHttp\Command\Guzzle\Parameter', $param->getItems());
70
+ }
71
+
72
+ public function testEnforcesInstanceOfOnlyWhenObject()
73
+ {
74
+ $p = new Parameter(array(
75
+ 'name' => 'foo',
76
+ 'type' => array('object', 'string'),
77
+ 'instanceOf' => get_class($this)
78
+ ));
79
+ $this->assertTrue($this->validator->validate($p, $this));
80
+ $s = 'test';
81
+ $this->assertTrue($this->validator->validate($p, $s));
82
+ }
83
+
84
+ public function testConvertsObjectsToArraysWhenToArrayInterface()
85
+ {
86
+ $o = $this->getMockBuilder('GuzzleHttp\ToArrayInterface')
87
+ ->setMethods(array('toArray'))
88
+ ->getMockForAbstractClass();
89
+ $o->expects($this->once())
90
+ ->method('toArray')
91
+ ->will($this->returnValue(array(
92
+ 'foo' => 'bar'
93
+ )));
94
+ $p = new Parameter(array(
95
+ 'name' => 'test',
96
+ 'type' => 'object',
97
+ 'properties' => array(
98
+ 'foo' => array('required' => 'true')
99
+ )
100
+ ));
101
+ $this->assertTrue($this->validator->validate($p, $o));
102
+ }
103
+
104
+ public function testMergesValidationErrorsInPropertiesWithParent()
105
+ {
106
+ $p = new Parameter(array(
107
+ 'name' => 'foo',
108
+ 'type' => 'object',
109
+ 'properties' => array(
110
+ 'bar' => array('type' => 'string', 'required' => true, 'description' => 'This is what it does'),
111
+ 'test' => array('type' => 'string', 'minLength' => 2, 'maxLength' => 5),
112
+ 'test2' => array('type' => 'string', 'minLength' => 2, 'maxLength' => 2),
113
+ 'test3' => array('type' => 'integer', 'minimum' => 100),
114
+ 'test4' => array('type' => 'integer', 'maximum' => 10),
115
+ 'test5' => array('type' => 'array', 'maxItems' => 2),
116
+ 'test6' => array('type' => 'string', 'enum' => array('a', 'bc')),
117
+ 'test7' => array('type' => 'string', 'pattern' => '/[0-9]+/'),
118
+ 'test8' => array('type' => 'number'),
119
+ 'baz' => array(
120
+ 'type' => 'array',
121
+ 'minItems' => 2,
122
+ 'required' => true,
123
+ "items" => array("type" => "string")
124
+ )
125
+ )
126
+ ));
127
+
128
+ $value = array(
129
+ 'test' => 'a',
130
+ 'test2' => 'abc',
131
+ 'baz' => array(false),
132
+ 'test3' => 10,
133
+ 'test4' => 100,
134
+ 'test5' => array(1, 3, 4),
135
+ 'test6' => 'Foo',
136
+ 'test7' => 'abc',
137
+ 'test8' => 'abc'
138
+ );
139
+
140
+ $this->assertFalse($this->validator->validate($p, $value));
141
+ $this->assertEquals(array (
142
+ '[foo][bar] is a required string: This is what it does',
143
+ '[foo][baz] must contain 2 or more elements',
144
+ '[foo][baz][0] must be of type string',
145
+ '[foo][test2] length must be less than or equal to 2',
146
+ '[foo][test3] must be greater than or equal to 100',
147
+ '[foo][test4] must be less than or equal to 10',
148
+ '[foo][test5] must contain 2 or fewer elements',
149
+ '[foo][test6] must be one of "a" or "bc"',
150
+ '[foo][test7] must match the following regular expression: /[0-9]+/',
151
+ '[foo][test8] must be of type number',
152
+ '[foo][test] length must be greater than or equal to 2',
153
+ ), $this->validator->getErrors());
154
+ }
155
+
156
+ public function testHandlesNullValuesInArraysWithDefaults()
157
+ {
158
+ $p = new Parameter(array(
159
+ 'name' => 'foo',
160
+ 'type' => 'object',
161
+ 'required' => true,
162
+ 'properties' => array(
163
+ 'bar' => array(
164
+ 'type' => 'object',
165
+ 'required' => true,
166
+ 'properties' => array(
167
+ 'foo' => array('default' => 'hi')
168
+ )
169
+ )
170
+ )
171
+ ));
172
+ $value = array();
173
+ $this->assertTrue($this->validator->validate($p, $value));
174
+ $this->assertEquals(array('bar' => array('foo' => 'hi')), $value);
175
+ }
176
+
177
+ public function testFailsWhenNullValuesInArraysWithNoDefaults()
178
+ {
179
+ $p = new Parameter(array(
180
+ 'name' => 'foo',
181
+ 'type' => 'object',
182
+ 'required' => true,
183
+ 'properties' => array(
184
+ 'bar' => array(
185
+ 'type' => 'object',
186
+ 'required' => true,
187
+ 'properties' => array('foo' => array('type' => 'string'))
188
+ )
189
+ )
190
+ ));
191
+ $value = array();
192
+ $this->assertFalse($this->validator->validate($p, $value));
193
+ $this->assertEquals(array('[foo][bar] is a required object'), $this->validator->getErrors());
194
+ }
195
+
196
+ public function testChecksTypes()
197
+ {
198
+ $p = new SchemaValidator();
199
+ $r = new \ReflectionMethod($p, 'determineType');
200
+ $r->setAccessible(true);
201
+ $this->assertEquals('any', $r->invoke($p, 'any', 'hello'));
202
+ $this->assertEquals(false, $r->invoke($p, 'foo', 'foo'));
203
+ $this->assertEquals('string', $r->invoke($p, 'string', 'hello'));
204
+ $this->assertEquals(false, $r->invoke($p, 'string', false));
205
+ $this->assertEquals('integer', $r->invoke($p, 'integer', 1));
206
+ $this->assertEquals(false, $r->invoke($p, 'integer', 'abc'));
207
+ $this->assertEquals('numeric', $r->invoke($p, 'numeric', 1));
208
+ $this->assertEquals('numeric', $r->invoke($p, 'numeric', '1'));
209
+ $this->assertEquals('number', $r->invoke($p, 'number', 1));
210
+ $this->assertEquals('number', $r->invoke($p, 'number', '1'));
211
+ $this->assertEquals(false, $r->invoke($p, 'numeric', 'a'));
212
+ $this->assertEquals('boolean', $r->invoke($p, 'boolean', true));
213
+ $this->assertEquals('boolean', $r->invoke($p, 'boolean', false));
214
+ $this->assertEquals(false, $r->invoke($p, 'boolean', 'false'));
215
+ $this->assertEquals('null', $r->invoke($p, 'null', null));
216
+ $this->assertEquals(false, $r->invoke($p, 'null', 'abc'));
217
+ $this->assertEquals('array', $r->invoke($p, 'array', array()));
218
+ $this->assertEquals(false, $r->invoke($p, 'array', 'foo'));
219
+ }
220
+
221
+ public function testValidatesFalseAdditionalProperties()
222
+ {
223
+ $param = new Parameter(array(
224
+ 'name' => 'foo',
225
+ 'type' => 'object',
226
+ 'properties' => array('bar' => array('type' => 'string')),
227
+ 'additionalProperties' => false
228
+ ));
229
+ $value = array('test' => '123');
230
+ $this->assertFalse($this->validator->validate($param, $value));
231
+ $this->assertEquals(array('[foo][test] is not an allowed property'), $this->validator->getErrors());
232
+ $value = array('bar' => '123');
233
+ $this->assertTrue($this->validator->validate($param, $value));
234
+ }
235
+
236
+ public function testAllowsUndefinedAdditionalProperties()
237
+ {
238
+ $param = new Parameter(array(
239
+ 'name' => 'foo',
240
+ 'type' => 'object',
241
+ 'properties' => array('bar' => array('type' => 'string'))
242
+ ));
243
+ $value = array('test' => '123');
244
+ $this->assertTrue($this->validator->validate($param, $value));
245
+ }
246
+
247
+ public function testValidatesAdditionalProperties()
248
+ {
249
+ $param = new Parameter(array(
250
+ 'name' => 'foo',
251
+ 'type' => 'object',
252
+ 'properties' => array('bar' => array('type' => 'string')),
253
+ 'additionalProperties' => array('type' => 'integer')
254
+ ));
255
+ $value = array('test' => 'foo');
256
+ $this->assertFalse($this->validator->validate($param, $value));
257
+ $this->assertEquals(array('[foo][test] must be of type integer'), $this->validator->getErrors());
258
+ }
259
+
260
+ public function testValidatesAdditionalPropertiesThatArrayArrays()
261
+ {
262
+ $param = new Parameter(array(
263
+ 'name' => 'foo',
264
+ 'type' => 'object',
265
+ 'additionalProperties' => array(
266
+ 'type' => 'array',
267
+ 'items' => array('type' => 'string')
268
+ )
269
+ ));
270
+ $value = array('test' => array(true));
271
+ $this->assertFalse($this->validator->validate($param, $value));
272
+ $this->assertEquals(array('[foo][test][0] must be of type string'), $this->validator->getErrors());
273
+ }
274
+
275
+ public function testIntegersCastToStringWhenTypeMismatch()
276
+ {
277
+ $param = new Parameter(array('name' => 'test', 'type' => 'string'));
278
+ $value = 12;
279
+ $this->assertTrue($this->validator->validate($param, $value));
280
+ $this->assertEquals('12', $value);
281
+ }
282
+
283
+ public function testRequiredMessageIncludesType()
284
+ {
285
+ $param = new Parameter(array('name' => 'test', 'type' => array('string', 'boolean'), 'required' => true));
286
+ $value = null;
287
+ $this->assertFalse($this->validator->validate($param, $value));
288
+ $this->assertEquals(array('[test] is a required string or boolean'), $this->validator->getErrors());
289
+ }
290
+
291
+ protected function getComplexParam()
292
+ {
293
+ return new Parameter(array(
294
+ 'name' => 'Foo',
295
+ 'type' => 'array',
296
+ 'required' => true,
297
+ 'min' => 1,
298
+ 'items' => array(
299
+ 'type' => 'object',
300
+ 'properties' => array(
301
+ 'Baz' => array(
302
+ 'type' => 'string',
303
+ ),
304
+ 'Bar' => array(
305
+ 'required' => true,
306
+ 'type' => 'boolean',
307
+ 'default' => true
308
+ )
309
+ )
310
+ )
311
+ ));
312
+ }
313
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/SerializerTest.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Command\Guzzle;
3
+
4
+ use GuzzleHttp\Client;
5
+ use GuzzleHttp\Command\Command;
6
+ use GuzzleHttp\Command\CommandTransaction;
7
+ use GuzzleHttp\Command\Guzzle\Description;
8
+ use GuzzleHttp\Command\Guzzle\GuzzleClient;
9
+ use GuzzleHttp\Command\Guzzle\Serializer;
10
+
11
+ class SerializerTest extends \PHPUnit_Framework_TestCase
12
+ {
13
+ public function testAllowsUriTemplates()
14
+ {
15
+ $description = new Description([
16
+ 'baseUrl' => 'http://test.com',
17
+ 'operations' => [
18
+ 'test' => [
19
+ 'httpMethod' => 'GET',
20
+ 'uri' => '/api/{key}/foo',
21
+ 'parameters' => [
22
+ 'key' => [
23
+ 'required' => true,
24
+ 'type' => 'string',
25
+ 'location' => 'uri'
26
+ ],
27
+ ]
28
+ ]
29
+ ]
30
+ ]);
31
+
32
+ $client = new Client();
33
+ $guzzle = new GuzzleClient($client, $description);
34
+ $command = new Command('test', ['key' => 'bar']);
35
+ $trans = new CommandTransaction($guzzle, $command);
36
+ $s = new Serializer($description);
37
+ $request = $s($trans);
38
+ $this->assertEquals('http://test.com/api/bar/foo', $request->getUrl());
39
+ }
40
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/Subscriber/ProcessResponseTest.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Command\Guzzle\Subscriber;
3
+
4
+ use GuzzleHttp\Client;
5
+ use GuzzleHttp\Command\Guzzle\GuzzleClient;
6
+ use GuzzleHttp\Command\Guzzle\Description;
7
+ use GuzzleHttp\Message\Response;
8
+ use GuzzleHttp\Subscriber\Mock;
9
+
10
+ /**
11
+ * @covers GuzzleHttp\Command\Guzzle\Subscriber\ProcessResponse
12
+ */
13
+ class ProcessSubscriberTest extends \PHPUnit_Framework_TestCase
14
+ {
15
+ /**
16
+ * @expectedException \GuzzleHttp\Command\Exception\CommandException
17
+ * @expectedExceptionMessage 404
18
+ */
19
+ public function testDoesNotAddResultWhenExceptionIsPresent()
20
+ {
21
+ $description = new Description([
22
+ 'operations' => [
23
+ 'foo' => [
24
+ 'uri' => 'http://httpbin.org/{foo}',
25
+ 'httpMethod' => 'GET',
26
+ 'responseModel' => 'j',
27
+ 'parameters' => [
28
+ 'bar' => [
29
+ 'type' => 'string',
30
+ 'required' => true,
31
+ 'location' => 'uri'
32
+ ]
33
+ ]
34
+ ]
35
+ ]
36
+ ]);
37
+
38
+ $client = new GuzzleClient(new Client(), $description);
39
+ $client->getHttpClient()->getEmitter()->attach(new Mock([
40
+ new Response(404)
41
+ ]));
42
+
43
+ $client->foo(['bar' => 'baz']);
44
+ }
45
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle-services/tests/Subscriber/ValidateInputTest.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Command\Guzzle\Subscriber;
3
+
4
+ use GuzzleHttp\Client;
5
+ use GuzzleHttp\Command\Guzzle\GuzzleClient;
6
+ use GuzzleHttp\Command\CommandTransaction;
7
+ use GuzzleHttp\Command\Guzzle\Description;
8
+ use GuzzleHttp\Command\Guzzle\Subscriber\ValidateInput;
9
+ use GuzzleHttp\Command\Event\InitEvent;
10
+
11
+ /**
12
+ * @covers GuzzleHttp\Command\Guzzle\Subscriber\ValidateInput
13
+ */
14
+ class ValidateInputTest extends \PHPUnit_Framework_TestCase
15
+ {
16
+ /**
17
+ * @expectedException \GuzzleHttp\Command\Exception\CommandException
18
+ * @expectedExceptionMessage Validation errors: [bar] is a required string
19
+ */
20
+ public function testValidates()
21
+ {
22
+ $description = new Description([
23
+ 'operations' => [
24
+ 'foo' => [
25
+ 'uri' => 'http://httpbin.org',
26
+ 'httpMethod' => 'GET',
27
+ 'responseModel' => 'j',
28
+ 'parameters' => [
29
+ 'bar' => [
30
+ 'type' => 'string',
31
+ 'required' => true
32
+ ]
33
+ ]
34
+ ]
35
+ ]
36
+ ]);
37
+
38
+ $client = new GuzzleClient(new Client(), $description);
39
+ $val = new ValidateInput($description);
40
+ $event = new InitEvent(
41
+ new CommandTransaction(
42
+ $client,
43
+ $client->getCommand('foo')
44
+ )
45
+ );
46
+ $val->onInit($event);
47
+ }
48
+
49
+ public function testSuccessfulValidationDoesNotThrow()
50
+ {
51
+ $description = new Description([
52
+ 'operations' => [
53
+ 'foo' => [
54
+ 'uri' => 'http://httpbin.org',
55
+ 'httpMethod' => 'GET',
56
+ 'responseModel' => 'j',
57
+ 'parameters' => []
58
+ ]
59
+ ]
60
+ ]);
61
+
62
+ $client = new GuzzleClient(new Client(), $description);
63
+ $val = new ValidateInput($description);
64
+ $event = new InitEvent(
65
+ new CommandTransaction(
66
+ $client,
67
+ $client->getCommand('foo')
68
+ )
69
+ );
70
+ $val->onInit($event);
71
+ }
72
+
73
+ /**
74
+ * @expectedException \GuzzleHttp\Command\Exception\CommandException
75
+ * @expectedExceptionMessage Validation errors: [bar] must be of type string
76
+ */
77
+ public function testValidatesAdditionalParameters()
78
+ {
79
+ $description = new Description([
80
+ 'operations' => [
81
+ 'foo' => [
82
+ 'uri' => 'http://httpbin.org',
83
+ 'httpMethod' => 'GET',
84
+ 'responseModel' => 'j',
85
+ 'additionalParameters' => [
86
+ 'type' => 'string'
87
+ ]
88
+ ]
89
+ ]
90
+ ]);
91
+
92
+ $client = new GuzzleClient(new Client(), $description);
93
+ $val = new ValidateInput($description);
94
+ $event = new InitEvent(
95
+ new CommandTransaction(
96
+ $client,
97
+ $client->getCommand('foo', ['bar' => new \stdClass()])
98
+ )
99
+ );
100
+ $val->onInit($event);
101
+ }
102
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/.editorconfig ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ # EditorConfig is awesome: http://EditorConfig.org
2
+
3
+ # top-most EditorConfig file
4
+ root = true
5
+
6
+ # Unix-style newlines with a newline ending for every file
7
+ # Indent with 4 spaces
8
+ [php]
9
+ end_of_line = lf
10
+ indent_style = space
11
+ indent_size = 4
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/.gitignore ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ phpunit.xml
2
+ composer.phar
3
+ composer.lock
4
+ composer-test.lock
5
+ vendor/
6
+ build/artifacts/
7
+ artifacts/
8
+ docs/_build
9
+ docs/*.pyc
10
+ .idea
11
+ .DS_STORE
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/.travis.yml ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ language: php
2
+
3
+ php:
4
+ - 5.4
5
+ - 5.5
6
+ - 5.6
7
+ - 7.0
8
+ - hhvm
9
+
10
+ before_script:
11
+ - curl --version
12
+ - pear config-set php_ini ~/.phpenv/versions/`php -r 'echo phpversion();'`/etc/php.ini || echo 'Error modifying PEAR'
13
+ - pecl install uri_template || echo 'Error installing uri_template'
14
+ - composer self-update
15
+ - composer install --no-interaction --prefer-source --dev
16
+ - ~/.nvm/nvm.sh install v0.6.14
17
+ - ~/.nvm/nvm.sh run v0.6.14
18
+
19
+ script: make test
20
+
21
+ matrix:
22
+ allow_failures:
23
+ - php: hhvm
24
+ - php: 7.0
25
+ fast_finish: true
26
+
27
+ before_deploy:
28
+ - make package
29
+
30
+ deploy:
31
+ provider: releases
32
+ api_key:
33
+ secure: UpypqlYgsU68QT/x40YzhHXvzWjFwCNo9d+G8KAdm7U9+blFfcWhV1aMdzugvPMl6woXgvJj7qHq5tAL4v6oswCORhpSBfLgOQVFaica5LiHsvWlAedOhxGmnJqMTwuepjBCxXhs3+I8Kof1n4oUL9gKytXjOVCX/f7XU1HiinU=
34
+ file:
35
+ - build/artifacts/guzzle.phar
36
+ - build/artifacts/guzzle.zip
37
+ on:
38
+ repo: guzzle/guzzle
39
+ tags: true
40
+ all_branches: true
41
+ php: 5.4
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/CHANGELOG.md ADDED
@@ -0,0 +1,1053 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CHANGELOG
2
+
3
+ ## 5.3.0 - 2015-05-19
4
+
5
+ * Mock now supports `save_to`
6
+ * Marked `AbstractRequestEvent::getTransaction()` as public.
7
+ * Fixed a bug in which multiple headers using different casing would overwrite
8
+ previous headers in the associative array.
9
+ * Added `Utils::getDefaultHandler()`
10
+ * Marked `GuzzleHttp\Client::getDefaultUserAgent` as deprecated.
11
+ * URL scheme is now always lowercased.
12
+
13
+ ## 5.2.0 - 2015-01-27
14
+
15
+ * Added `AppliesHeadersInterface` to make applying headers to a request based
16
+ on the body more generic and not specific to `PostBodyInterface`.
17
+ * Reduced the number of stack frames needed to send requests.
18
+ * Nested futures are now resolved in the client rather than the RequestFsm
19
+ * Finishing state transitions is now handled in the RequestFsm rather than the
20
+ RingBridge.
21
+ * Added a guard in the Pool class to not use recursion for request retries.
22
+
23
+ ## 5.1.0 - 2014-12-19
24
+
25
+ * Pool class no longer uses recursion when a request is intercepted.
26
+ * The size of a Pool can now be dynamically adjusted using a callback.
27
+ See https://github.com/guzzle/guzzle/pull/943.
28
+ * Setting a request option to `null` when creating a request with a client will
29
+ ensure that the option is not set. This allows you to overwrite default
30
+ request options on a per-request basis.
31
+ See https://github.com/guzzle/guzzle/pull/937.
32
+ * Added the ability to limit which protocols are allowed for redirects by
33
+ specifying a `protocols` array in the `allow_redirects` request option.
34
+ * Nested futures due to retries are now resolved when waiting for synchronous
35
+ responses. See https://github.com/guzzle/guzzle/pull/947.
36
+ * `"0"` is now an allowed URI path. See
37
+ https://github.com/guzzle/guzzle/pull/935.
38
+ * `Query` no longer typehints on the `$query` argument in the constructor,
39
+ allowing for strings and arrays.
40
+ * Exceptions thrown in the `end` event are now correctly wrapped with Guzzle
41
+ specific exceptions if necessary.
42
+
43
+ ## 5.0.3 - 2014-11-03
44
+
45
+ This change updates query strings so that they are treated as un-encoded values
46
+ by default where the value represents an un-encoded value to send over the
47
+ wire. A Query object then encodes the value before sending over the wire. This
48
+ means that even value query string values (e.g., ":") are url encoded. This
49
+ makes the Query class match PHP's http_build_query function. However, if you
50
+ want to send requests over the wire using valid query string characters that do
51
+ not need to be encoded, then you can provide a string to Url::setQuery() and
52
+ pass true as the second argument to specify that the query string is a raw
53
+ string that should not be parsed or encoded (unless a call to getQuery() is
54
+ subsequently made, forcing the query-string to be converted into a Query
55
+ object).
56
+
57
+ ## 5.0.2 - 2014-10-30
58
+
59
+ * Added a trailing `\r\n` to multipart/form-data payloads. See
60
+ https://github.com/guzzle/guzzle/pull/871
61
+ * Added a `GuzzleHttp\Pool::send()` convenience method to match the docs.
62
+ * Status codes are now returned as integers. See
63
+ https://github.com/guzzle/guzzle/issues/881
64
+ * No longer overwriting an existing `application/x-www-form-urlencoded` header
65
+ when sending POST requests, allowing for customized headers. See
66
+ https://github.com/guzzle/guzzle/issues/877
67
+ * Improved path URL serialization.
68
+
69
+ * No longer double percent-encoding characters in the path or query string if
70
+ they are already encoded.
71
+ * Now properly encoding the supplied path to a URL object, instead of only
72
+ encoding ' ' and '?'.
73
+ * Note: This has been changed in 5.0.3 to now encode query string values by
74
+ default unless the `rawString` argument is provided when setting the query
75
+ string on a URL: Now allowing many more characters to be present in the
76
+ query string without being percent encoded. See http://tools.ietf.org/html/rfc3986#appendix-A
77
+
78
+ ## 5.0.1 - 2014-10-16
79
+
80
+ Bugfix release.
81
+
82
+ * Fixed an issue where connection errors still returned response object in
83
+ error and end events event though the response is unusable. This has been
84
+ corrected so that a response is not returned in the `getResponse` method of
85
+ these events if the response did not complete. https://github.com/guzzle/guzzle/issues/867
86
+ * Fixed an issue where transfer statistics were not being populated in the
87
+ RingBridge. https://github.com/guzzle/guzzle/issues/866
88
+
89
+ ## 5.0.0 - 2014-10-12
90
+
91
+ Adding support for non-blocking responses and some minor API cleanup.
92
+
93
+ ### New Features
94
+
95
+ * Added support for non-blocking responses based on `guzzlehttp/guzzle-ring`.
96
+ * Added a public API for creating a default HTTP adapter.
97
+ * Updated the redirect plugin to be non-blocking so that redirects are sent
98
+ concurrently. Other plugins like this can now be updated to be non-blocking.
99
+ * Added a "progress" event so that you can get upload and download progress
100
+ events.
101
+ * Added `GuzzleHttp\Pool` which implements FutureInterface and transfers
102
+ requests concurrently using a capped pool size as efficiently as possible.
103
+ * Added `hasListeners()` to EmitterInterface.
104
+ * Removed `GuzzleHttp\ClientInterface::sendAll` and marked
105
+ `GuzzleHttp\Client::sendAll` as deprecated (it's still there, just not the
106
+ recommended way).
107
+
108
+ ### Breaking changes
109
+
110
+ The breaking changes in this release are relatively minor. The biggest thing to
111
+ look out for is that request and response objects no longer implement fluent
112
+ interfaces.
113
+
114
+ * Removed the fluent interfaces (i.e., `return $this`) from requests,
115
+ responses, `GuzzleHttp\Collection`, `GuzzleHttp\Url`,
116
+ `GuzzleHttp\Query`, `GuzzleHttp\Post\PostBody`, and
117
+ `GuzzleHttp\Cookie\SetCookie`. This blog post provides a good outline of
118
+ why I did this: http://ocramius.github.io/blog/fluent-interfaces-are-evil/.
119
+ This also makes the Guzzle message interfaces compatible with the current
120
+ PSR-7 message proposal.
121
+ * Removed "functions.php", so that Guzzle is truly PSR-4 compliant. Except
122
+ for the HTTP request functions from function.php, these functions are now
123
+ implemented in `GuzzleHttp\Utils` using camelCase. `GuzzleHttp\json_decode`
124
+ moved to `GuzzleHttp\Utils::jsonDecode`. `GuzzleHttp\get_path` moved to
125
+ `GuzzleHttp\Utils::getPath`. `GuzzleHttp\set_path` moved to
126
+ `GuzzleHttp\Utils::setPath`. `GuzzleHttp\batch` should now be
127
+ `GuzzleHttp\Pool::batch`, which returns an `objectStorage`. Using functions.php
128
+ caused problems for many users: they aren't PSR-4 compliant, require an
129
+ explicit include, and needed an if-guard to ensure that the functions are not
130
+ declared multiple times.
131
+ * Rewrote adapter layer.
132
+ * Removing all classes from `GuzzleHttp\Adapter`, these are now
133
+ implemented as callables that are stored in `GuzzleHttp\Ring\Client`.
134
+ * Removed the concept of "parallel adapters". Sending requests serially or
135
+ concurrently is now handled using a single adapter.
136
+ * Moved `GuzzleHttp\Adapter\Transaction` to `GuzzleHttp\Transaction`. The
137
+ Transaction object now exposes the request, response, and client as public
138
+ properties. The getters and setters have been removed.
139
+ * Removed the "headers" event. This event was only useful for changing the
140
+ body a response once the headers of the response were known. You can implement
141
+ a similar behavior in a number of ways. One example might be to use a
142
+ FnStream that has access to the transaction being sent. For example, when the
143
+ first byte is written, you could check if the response headers match your
144
+ expectations, and if so, change the actual stream body that is being
145
+ written to.
146
+ * Removed the `asArray` parameter from
147
+ `GuzzleHttp\Message\MessageInterface::getHeader`. If you want to get a header
148
+ value as an array, then use the newly added `getHeaderAsArray()` method of
149
+ `MessageInterface`. This change makes the Guzzle interfaces compatible with
150
+ the PSR-7 interfaces.
151
+ * `GuzzleHttp\Message\MessageFactory` no longer allows subclasses to add
152
+ custom request options using double-dispatch (this was an implementation
153
+ detail). Instead, you should now provide an associative array to the
154
+ constructor which is a mapping of the request option name mapping to a
155
+ function that applies the option value to a request.
156
+ * Removed the concept of "throwImmediately" from exceptions and error events.
157
+ This control mechanism was used to stop a transfer of concurrent requests
158
+ from completing. This can now be handled by throwing the exception or by
159
+ cancelling a pool of requests or each outstanding future request individually.
160
+ * Updated to "GuzzleHttp\Streams" 3.0.
161
+ * `GuzzleHttp\Stream\StreamInterface::getContents()` no longer accepts a
162
+ `maxLen` parameter. This update makes the Guzzle streams project
163
+ compatible with the current PSR-7 proposal.
164
+ * `GuzzleHttp\Stream\Stream::__construct`,
165
+ `GuzzleHttp\Stream\Stream::factory`, and
166
+ `GuzzleHttp\Stream\Utils::create` no longer accept a size in the second
167
+ argument. They now accept an associative array of options, including the
168
+ "size" key and "metadata" key which can be used to provide custom metadata.
169
+
170
+ ## 4.2.2 - 2014-09-08
171
+
172
+ * Fixed a memory leak in the CurlAdapter when reusing cURL handles.
173
+ * No longer using `request_fulluri` in stream adapter proxies.
174
+ * Relative redirects are now based on the last response, not the first response.
175
+
176
+ ## 4.2.1 - 2014-08-19
177
+
178
+ * Ensuring that the StreamAdapter does not always add a Content-Type header
179
+ * Adding automated github releases with a phar and zip
180
+
181
+ ## 4.2.0 - 2014-08-17
182
+
183
+ * Now merging in default options using a case-insensitive comparison.
184
+ Closes https://github.com/guzzle/guzzle/issues/767
185
+ * Added the ability to automatically decode `Content-Encoding` response bodies
186
+ using the `decode_content` request option. This is set to `true` by default
187
+ to decode the response body if it comes over the wire with a
188
+ `Content-Encoding`. Set this value to `false` to disable decoding the
189
+ response content, and pass a string to provide a request `Accept-Encoding`
190
+ header and turn on automatic response decoding. This feature now allows you
191
+ to pass an `Accept-Encoding` header in the headers of a request but still
192
+ disable automatic response decoding.
193
+ Closes https://github.com/guzzle/guzzle/issues/764
194
+ * Added the ability to throw an exception immediately when transferring
195
+ requests in parallel. Closes https://github.com/guzzle/guzzle/issues/760
196
+ * Updating guzzlehttp/streams dependency to ~2.1
197
+ * No longer utilizing the now deprecated namespaced methods from the stream
198
+ package.
199
+
200
+ ## 4.1.8 - 2014-08-14
201
+
202
+ * Fixed an issue in the CurlFactory that caused setting the `stream=false`
203
+ request option to throw an exception.
204
+ See: https://github.com/guzzle/guzzle/issues/769
205
+ * TransactionIterator now calls rewind on the inner iterator.
206
+ See: https://github.com/guzzle/guzzle/pull/765
207
+ * You can now set the `Content-Type` header to `multipart/form-data`
208
+ when creating POST requests to force multipart bodies.
209
+ See https://github.com/guzzle/guzzle/issues/768
210
+
211
+ ## 4.1.7 - 2014-08-07
212
+
213
+ * Fixed an error in the HistoryPlugin that caused the same request and response
214
+ to be logged multiple times when an HTTP protocol error occurs.
215
+ * Ensuring that cURL does not add a default Content-Type when no Content-Type
216
+ has been supplied by the user. This prevents the adapter layer from modifying
217
+ the request that is sent over the wire after any listeners may have already
218
+ put the request in a desired state (e.g., signed the request).
219
+ * Throwing an exception when you attempt to send requests that have the
220
+ "stream" set to true in parallel using the MultiAdapter.
221
+ * Only calling curl_multi_select when there are active cURL handles. This was
222
+ previously changed and caused performance problems on some systems due to PHP
223
+ always selecting until the maximum select timeout.
224
+ * Fixed a bug where multipart/form-data POST fields were not correctly
225
+ aggregated (e.g., values with "&").
226
+
227
+ ## 4.1.6 - 2014-08-03
228
+
229
+ * Added helper methods to make it easier to represent messages as strings,
230
+ including getting the start line and getting headers as a string.
231
+
232
+ ## 4.1.5 - 2014-08-02
233
+
234
+ * Automatically retrying cURL "Connection died, retrying a fresh connect"
235
+ errors when possible.
236
+ * cURL implementation cleanup
237
+ * Allowing multiple event subscriber listeners to be registered per event by
238
+ passing an array of arrays of listener configuration.
239
+
240
+ ## 4.1.4 - 2014-07-22
241
+
242
+ * Fixed a bug that caused multi-part POST requests with more than one field to
243
+ serialize incorrectly.
244
+ * Paths can now be set to "0"
245
+ * `ResponseInterface::xml` now accepts a `libxml_options` option and added a
246
+ missing default argument that was required when parsing XML response bodies.
247
+ * A `save_to` stream is now created lazily, which means that files are not
248
+ created on disk unless a request succeeds.
249
+
250
+ ## 4.1.3 - 2014-07-15
251
+
252
+ * Various fixes to multipart/form-data POST uploads
253
+ * Wrapping function.php in an if-statement to ensure Guzzle can be used
254
+ globally and in a Composer install
255
+ * Fixed an issue with generating and merging in events to an event array
256
+ * POST headers are only applied before sending a request to allow you to change
257
+ the query aggregator used before uploading
258
+ * Added much more robust query string parsing
259
+ * Fixed various parsing and normalization issues with URLs
260
+ * Fixing an issue where multi-valued headers were not being utilized correctly
261
+ in the StreamAdapter
262
+
263
+ ## 4.1.2 - 2014-06-18
264
+
265
+ * Added support for sending payloads with GET requests
266
+
267
+ ## 4.1.1 - 2014-06-08
268
+
269
+ * Fixed an issue related to using custom message factory options in subclasses
270
+ * Fixed an issue with nested form fields in a multi-part POST
271
+ * Fixed an issue with using the `json` request option for POST requests
272
+ * Added `ToArrayInterface` to `GuzzleHttp\Cookie\CookieJar`
273
+
274
+ ## 4.1.0 - 2014-05-27
275
+
276
+ * Added a `json` request option to easily serialize JSON payloads.
277
+ * Added a `GuzzleHttp\json_decode()` wrapper to safely parse JSON.
278
+ * Added `setPort()` and `getPort()` to `GuzzleHttp\Message\RequestInterface`.
279
+ * Added the ability to provide an emitter to a client in the client constructor.
280
+ * Added the ability to persist a cookie session using $_SESSION.
281
+ * Added a trait that can be used to add event listeners to an iterator.
282
+ * Removed request method constants from RequestInterface.
283
+ * Fixed warning when invalid request start-lines are received.
284
+ * Updated MessageFactory to work with custom request option methods.
285
+ * Updated cacert bundle to latest build.
286
+
287
+ 4.0.2 (2014-04-16)
288
+ ------------------
289
+
290
+ * Proxy requests using the StreamAdapter now properly use request_fulluri (#632)
291
+ * Added the ability to set scalars as POST fields (#628)
292
+
293
+ ## 4.0.1 - 2014-04-04
294
+
295
+ * The HTTP status code of a response is now set as the exception code of
296
+ RequestException objects.
297
+ * 303 redirects will now correctly switch from POST to GET requests.
298
+ * The default parallel adapter of a client now correctly uses the MultiAdapter.
299
+ * HasDataTrait now initializes the internal data array as an empty array so
300
+ that the toArray() method always returns an array.
301
+
302
+ ## 4.0.0 - 2014-03-29
303
+
304
+ * For more information on the 4.0 transition, see:
305
+ http://mtdowling.com/blog/2014/03/15/guzzle-4-rc/
306
+ * For information on changes and upgrading, see:
307
+ https://github.com/guzzle/guzzle/blob/master/UPGRADING.md#3x-to-40
308
+ * Added `GuzzleHttp\batch()` as a convenience function for sending requests in
309
+ parallel without needing to write asynchronous code.
310
+ * Restructured how events are added to `GuzzleHttp\ClientInterface::sendAll()`.
311
+ You can now pass a callable or an array of associative arrays where each
312
+ associative array contains the "fn", "priority", and "once" keys.
313
+
314
+ ## 4.0.0.rc-2 - 2014-03-25
315
+
316
+ * Removed `getConfig()` and `setConfig()` from clients to avoid confusion
317
+ around whether things like base_url, message_factory, etc. should be able to
318
+ be retrieved or modified.
319
+ * Added `getDefaultOption()` and `setDefaultOption()` to ClientInterface
320
+ * functions.php functions were renamed using snake_case to match PHP idioms
321
+ * Added support for `HTTP_PROXY`, `HTTPS_PROXY`, and
322
+ `GUZZLE_CURL_SELECT_TIMEOUT` environment variables
323
+ * Added the ability to specify custom `sendAll()` event priorities
324
+ * Added the ability to specify custom stream context options to the stream
325
+ adapter.
326
+ * Added a functions.php function for `get_path()` and `set_path()`
327
+ * CurlAdapter and MultiAdapter now use a callable to generate curl resources
328
+ * MockAdapter now properly reads a body and emits a `headers` event
329
+ * Updated Url class to check if a scheme and host are set before adding ":"
330
+ and "//". This allows empty Url (e.g., "") to be serialized as "".
331
+ * Parsing invalid XML no longer emits warnings
332
+ * Curl classes now properly throw AdapterExceptions
333
+ * Various performance optimizations
334
+ * Streams are created with the faster `Stream\create()` function
335
+ * Marked deprecation_proxy() as internal
336
+ * Test server is now a collection of static methods on a class
337
+
338
+ ## 4.0.0-rc.1 - 2014-03-15
339
+
340
+ * See https://github.com/guzzle/guzzle/blob/master/UPGRADING.md#3x-to-40
341
+
342
+ ## 3.8.1 - 2014-01-28
343
+
344
+ * Bug: Always using GET requests when redirecting from a 303 response
345
+ * Bug: CURLOPT_SSL_VERIFYHOST is now correctly set to false when setting `$certificateAuthority` to false in
346
+ `Guzzle\Http\ClientInterface::setSslVerification()`
347
+ * Bug: RedirectPlugin now uses strict RFC 3986 compliance when combining a base URL with a relative URL
348
+ * Bug: The body of a request can now be set to `"0"`
349
+ * Sending PHP stream requests no longer forces `HTTP/1.0`
350
+ * Adding more information to ExceptionCollection exceptions so that users have more context, including a stack trace of
351
+ each sub-exception
352
+ * Updated the `$ref` attribute in service descriptions to merge over any existing parameters of a schema (rather than
353
+ clobbering everything).
354
+ * Merging URLs will now use the query string object from the relative URL (thus allowing custom query aggregators)
355
+ * Query strings are now parsed in a way that they do no convert empty keys with no value to have a dangling `=`.
356
+ For example `foo&bar=baz` is now correctly parsed and recognized as `foo&bar=baz` rather than `foo=&bar=baz`.
357
+ * Now properly escaping the regular expression delimiter when matching Cookie domains.
358
+ * Network access is now disabled when loading XML documents
359
+
360
+ ## 3.8.0 - 2013-12-05
361
+
362
+ * Added the ability to define a POST name for a file
363
+ * JSON response parsing now properly walks additionalProperties
364
+ * cURL error code 18 is now retried automatically in the BackoffPlugin
365
+ * Fixed a cURL error when URLs contain fragments
366
+ * Fixed an issue in the BackoffPlugin retry event where it was trying to access all exceptions as if they were
367
+ CurlExceptions
368
+ * CURLOPT_PROGRESS function fix for PHP 5.5 (69fcc1e)
369
+ * Added the ability for Guzzle to work with older versions of cURL that do not support `CURLOPT_TIMEOUT_MS`
370
+ * Fixed a bug that was encountered when parsing empty header parameters
371
+ * UriTemplate now has a `setRegex()` method to match the docs
372
+ * The `debug` request parameter now checks if it is truthy rather than if it exists
373
+ * Setting the `debug` request parameter to true shows verbose cURL output instead of using the LogPlugin
374
+ * Added the ability to combine URLs using strict RFC 3986 compliance
375
+ * Command objects can now return the validation errors encountered by the command
376
+ * Various fixes to cache revalidation (#437 and 29797e5)
377
+ * Various fixes to the AsyncPlugin
378
+ * Cleaned up build scripts
379
+
380
+ ## 3.7.4 - 2013-10-02
381
+
382
+ * Bug fix: 0 is now an allowed value in a description parameter that has a default value (#430)
383
+ * Bug fix: SchemaFormatter now returns an integer when formatting to a Unix timestamp
384
+ (see https://github.com/aws/aws-sdk-php/issues/147)
385
+ * Bug fix: Cleaned up and fixed URL dot segment removal to properly resolve internal dots
386
+ * Minimum PHP version is now properly specified as 5.3.3 (up from 5.3.2) (#420)
387
+ * Updated the bundled cacert.pem (#419)
388
+ * OauthPlugin now supports adding authentication to headers or query string (#425)
389
+
390
+ ## 3.7.3 - 2013-09-08
391
+
392
+ * Added the ability to get the exception associated with a request/command when using `MultiTransferException` and
393
+ `CommandTransferException`.
394
+ * Setting `additionalParameters` of a response to false is now honored when parsing responses with a service description
395
+ * Schemas are only injected into response models when explicitly configured.
396
+ * No longer guessing Content-Type based on the path of a request. Content-Type is now only guessed based on the path of
397
+ an EntityBody.
398
+ * Bug fix: ChunkedIterator can now properly chunk a \Traversable as well as an \Iterator.
399
+ * Bug fix: FilterIterator now relies on `\Iterator` instead of `\Traversable`.
400
+ * Bug fix: Gracefully handling malformed responses in RequestMediator::writeResponseBody()
401
+ * Bug fix: Replaced call to canCache with canCacheRequest in the CallbackCanCacheStrategy of the CachePlugin
402
+ * Bug fix: Visiting XML attributes first before visiting XML children when serializing requests
403
+ * Bug fix: Properly parsing headers that contain commas contained in quotes
404
+ * Bug fix: mimetype guessing based on a filename is now case-insensitive
405
+
406
+ ## 3.7.2 - 2013-08-02
407
+
408
+ * Bug fix: Properly URL encoding paths when using the PHP-only version of the UriTemplate expander
409
+ See https://github.com/guzzle/guzzle/issues/371
410
+ * Bug fix: Cookie domains are now matched correctly according to RFC 6265
411
+ See https://github.com/guzzle/guzzle/issues/377
412
+ * Bug fix: GET parameters are now used when calculating an OAuth signature
413
+ * Bug fix: Fixed an issue with cache revalidation where the If-None-Match header was being double quoted
414
+ * `Guzzle\Common\AbstractHasDispatcher::dispatch()` now returns the event that was dispatched
415
+ * `Guzzle\Http\QueryString::factory()` now guesses the most appropriate query aggregator to used based on the input.
416
+ See https://github.com/guzzle/guzzle/issues/379
417
+ * Added a way to add custom domain objects to service description parsing using the `operation.parse_class` event. See
418
+ https://github.com/guzzle/guzzle/pull/380
419
+ * cURL multi cleanup and optimizations
420
+
421
+ ## 3.7.1 - 2013-07-05
422
+
423
+ * Bug fix: Setting default options on a client now works
424
+ * Bug fix: Setting options on HEAD requests now works. See #352
425
+ * Bug fix: Moving stream factory before send event to before building the stream. See #353
426
+ * Bug fix: Cookies no longer match on IP addresses per RFC 6265
427
+ * Bug fix: Correctly parsing header parameters that are in `<>` and quotes
428
+ * Added `cert` and `ssl_key` as request options
429
+ * `Host` header can now diverge from the host part of a URL if the header is set manually
430
+ * `Guzzle\Service\Command\LocationVisitor\Request\XmlVisitor` was rewritten to change from using SimpleXML to XMLWriter
431
+ * OAuth parameters are only added via the plugin if they aren't already set
432
+ * Exceptions are now thrown when a URL cannot be parsed
433
+ * Returning `false` if `Guzzle\Http\EntityBody::getContentMd5()` fails
434
+ * Not setting a `Content-MD5` on a command if calculating the Content-MD5 fails via the CommandContentMd5Plugin
435
+
436
+ ## 3.7.0 - 2013-06-10
437
+
438
+ * See UPGRADING.md for more information on how to upgrade.
439
+ * Requests now support the ability to specify an array of $options when creating a request to more easily modify a
440
+ request. You can pass a 'request.options' configuration setting to a client to apply default request options to
441
+ every request created by a client (e.g. default query string variables, headers, curl options, etc.).
442
+ * Added a static facade class that allows you to use Guzzle with static methods and mount the class to `\Guzzle`.
443
+ See `Guzzle\Http\StaticClient::mount`.
444
+ * Added `command.request_options` to `Guzzle\Service\Command\AbstractCommand` to pass request options to requests
445
+ created by a command (e.g. custom headers, query string variables, timeout settings, etc.).
446
+ * Stream size in `Guzzle\Stream\PhpStreamRequestFactory` will now be set if Content-Length is returned in the
447
+ headers of a response
448
+ * Added `Guzzle\Common\Collection::setPath($path, $value)` to set a value into an array using a nested key
449
+ (e.g. `$collection->setPath('foo/baz/bar', 'test'); echo $collection['foo']['bar']['bar'];`)
450
+ * ServiceBuilders now support storing and retrieving arbitrary data
451
+ * CachePlugin can now purge all resources for a given URI
452
+ * CachePlugin can automatically purge matching cached items when a non-idempotent request is sent to a resource
453
+ * CachePlugin now uses the Vary header to determine if a resource is a cache hit
454
+ * `Guzzle\Http\Message\Response` now implements `\Serializable`
455
+ * Added `Guzzle\Cache\CacheAdapterFactory::fromCache()` to more easily create cache adapters
456
+ * `Guzzle\Service\ClientInterface::execute()` now accepts an array, single command, or Traversable
457
+ * Fixed a bug in `Guzzle\Http\Message\Header\Link::addLink()`
458
+ * Better handling of calculating the size of a stream in `Guzzle\Stream\Stream` using fstat() and caching the size
459
+ * `Guzzle\Common\Exception\ExceptionCollection` now creates a more readable exception message
460
+ * Fixing BC break: Added back the MonologLogAdapter implementation rather than extending from PsrLog so that older
461
+ Symfony users can still use the old version of Monolog.
462
+ * Fixing BC break: Added the implementation back in for `Guzzle\Http\Message\AbstractMessage::getTokenizedHeader()`.
463
+ Now triggering an E_USER_DEPRECATED warning when used. Use `$message->getHeader()->parseParams()`.
464
+ * Several performance improvements to `Guzzle\Common\Collection`
465
+ * Added an `$options` argument to the end of the following methods of `Guzzle\Http\ClientInterface`:
466
+ createRequest, head, delete, put, patch, post, options, prepareRequest
467
+ * Added an `$options` argument to the end of `Guzzle\Http\Message\Request\RequestFactoryInterface::createRequest()`
468
+ * Added an `applyOptions()` method to `Guzzle\Http\Message\Request\RequestFactoryInterface`
469
+ * Changed `Guzzle\Http\ClientInterface::get($uri = null, $headers = null, $body = null)` to
470
+ `Guzzle\Http\ClientInterface::get($uri = null, $headers = null, $options = array())`. You can still pass in a
471
+ resource, string, or EntityBody into the $options parameter to specify the download location of the response.
472
+ * Changed `Guzzle\Common\Collection::__construct($data)` to no longer accepts a null value for `$data` but a
473
+ default `array()`
474
+ * Added `Guzzle\Stream\StreamInterface::isRepeatable`
475
+ * Removed `Guzzle\Http\ClientInterface::setDefaultHeaders(). Use
476
+ $client->getConfig()->setPath('request.options/headers/{header_name}', 'value')`. or
477
+ $client->getConfig()->setPath('request.options/headers', array('header_name' => 'value'))`.
478
+ * Removed `Guzzle\Http\ClientInterface::getDefaultHeaders(). Use $client->getConfig()->getPath('request.options/headers')`.
479
+ * Removed `Guzzle\Http\ClientInterface::expandTemplate()`
480
+ * Removed `Guzzle\Http\ClientInterface::setRequestFactory()`
481
+ * Removed `Guzzle\Http\ClientInterface::getCurlMulti()`
482
+ * Removed `Guzzle\Http\Message\RequestInterface::canCache`
483
+ * Removed `Guzzle\Http\Message\RequestInterface::setIsRedirect`
484
+ * Removed `Guzzle\Http\Message\RequestInterface::isRedirect`
485
+ * Made `Guzzle\Http\Client::expandTemplate` and `getUriTemplate` protected methods.
486
+ * You can now enable E_USER_DEPRECATED warnings to see if you are using a deprecated method by setting
487
+ `Guzzle\Common\Version::$emitWarnings` to true.
488
+ * Marked `Guzzle\Http\Message\Request::isResponseBodyRepeatable()` as deprecated. Use
489
+ `$request->getResponseBody()->isRepeatable()` instead.
490
+ * Marked `Guzzle\Http\Message\Request::canCache()` as deprecated. Use
491
+ `Guzzle\Plugin\Cache\DefaultCanCacheStrategy->canCacheRequest()` instead.
492
+ * Marked `Guzzle\Http\Message\Request::canCache()` as deprecated. Use
493
+ `Guzzle\Plugin\Cache\DefaultCanCacheStrategy->canCacheRequest()` instead.
494
+ * Marked `Guzzle\Http\Message\Request::setIsRedirect()` as deprecated. Use the HistoryPlugin instead.
495
+ * Marked `Guzzle\Http\Message\Request::isRedirect()` as deprecated. Use the HistoryPlugin instead.
496
+ * Marked `Guzzle\Cache\CacheAdapterFactory::factory()` as deprecated
497
+ * Marked 'command.headers', 'command.response_body' and 'command.on_complete' as deprecated for AbstractCommand.
498
+ These will work through Guzzle 4.0
499
+ * Marked 'request.params' for `Guzzle\Http\Client` as deprecated. Use [request.options][params].
500
+ * Marked `Guzzle\Service\Client::enableMagicMethods()` as deprecated. Magic methods can no longer be disabled on a Guzzle\Service\Client.
501
+ * Marked `Guzzle\Service\Client::getDefaultHeaders()` as deprecated. Use $client->getConfig()->getPath('request.options/headers')`.
502
+ * Marked `Guzzle\Service\Client::setDefaultHeaders()` as deprecated. Use $client->getConfig()->setPath('request.options/headers/{header_name}', 'value')`.
503
+ * Marked `Guzzle\Parser\Url\UrlParser` as deprecated. Just use PHP's `parse_url()` and percent encode your UTF-8.
504
+ * Marked `Guzzle\Common\Collection::inject()` as deprecated.
505
+ * Marked `Guzzle\Plugin\CurlAuth\CurlAuthPlugin` as deprecated. Use `$client->getConfig()->setPath('request.options/auth', array('user', 'pass', 'Basic|Digest');`
506
+ * CacheKeyProviderInterface and DefaultCacheKeyProvider are no longer used. All of this logic is handled in a
507
+ CacheStorageInterface. These two objects and interface will be removed in a future version.
508
+ * Always setting X-cache headers on cached responses
509
+ * Default cache TTLs are now handled by the CacheStorageInterface of a CachePlugin
510
+ * `CacheStorageInterface::cache($key, Response $response, $ttl = null)` has changed to `cache(RequestInterface
511
+ $request, Response $response);`
512
+ * `CacheStorageInterface::fetch($key)` has changed to `fetch(RequestInterface $request);`
513
+ * `CacheStorageInterface::delete($key)` has changed to `delete(RequestInterface $request);`
514
+ * Added `CacheStorageInterface::purge($url)`
515
+ * `DefaultRevalidation::__construct(CacheKeyProviderInterface $cacheKey, CacheStorageInterface $cache, CachePlugin
516
+ $plugin)` has changed to `DefaultRevalidation::__construct(CacheStorageInterface $cache,
517
+ CanCacheStrategyInterface $canCache = null)`
518
+ * Added `RevalidationInterface::shouldRevalidate(RequestInterface $request, Response $response)`
519
+
520
+ ## 3.6.0 - 2013-05-29
521
+
522
+ * ServiceDescription now implements ToArrayInterface
523
+ * Added command.hidden_params to blacklist certain headers from being treated as additionalParameters
524
+ * Guzzle can now correctly parse incomplete URLs
525
+ * Mixed casing of headers are now forced to be a single consistent casing across all values for that header.
526
+ * Messages internally use a HeaderCollection object to delegate handling case-insensitive header resolution
527
+ * Removed the whole changedHeader() function system of messages because all header changes now go through addHeader().
528
+ * Specific header implementations can be created for complex headers. When a message creates a header, it uses a
529
+ HeaderFactory which can map specific headers to specific header classes. There is now a Link header and
530
+ CacheControl header implementation.
531
+ * Removed from interface: Guzzle\Http\ClientInterface::setUriTemplate
532
+ * Removed from interface: Guzzle\Http\ClientInterface::setCurlMulti()
533
+ * Removed Guzzle\Http\Message\Request::receivedRequestHeader() and implemented this functionality in
534
+ Guzzle\Http\Curl\RequestMediator
535
+ * Removed the optional $asString parameter from MessageInterface::getHeader(). Just cast the header to a string.
536
+ * Removed the optional $tryChunkedTransfer option from Guzzle\Http\Message\EntityEnclosingRequestInterface
537
+ * Removed the $asObjects argument from Guzzle\Http\Message\MessageInterface::getHeaders()
538
+ * Removed Guzzle\Parser\ParserRegister::get(). Use getParser()
539
+ * Removed Guzzle\Parser\ParserRegister::set(). Use registerParser().
540
+ * All response header helper functions return a string rather than mixing Header objects and strings inconsistently
541
+ * Removed cURL blacklist support. This is no longer necessary now that Expect, Accept, etc. are managed by Guzzle
542
+ directly via interfaces
543
+ * Removed the injecting of a request object onto a response object. The methods to get and set a request still exist
544
+ but are a no-op until removed.
545
+ * Most classes that used to require a `Guzzle\Service\Command\CommandInterface` typehint now request a
546
+ `Guzzle\Service\Command\ArrayCommandInterface`.
547
+ * Added `Guzzle\Http\Message\RequestInterface::startResponse()` to the RequestInterface to handle injecting a response
548
+ on a request while the request is still being transferred
549
+ * The ability to case-insensitively search for header values
550
+ * Guzzle\Http\Message\Header::hasExactHeader
551
+ * Guzzle\Http\Message\Header::raw. Use getAll()
552
+ * Deprecated cache control specific methods on Guzzle\Http\Message\AbstractMessage. Use the CacheControl header object
553
+ instead.
554
+ * `Guzzle\Service\Command\CommandInterface` now extends from ToArrayInterface and ArrayAccess
555
+ * Added the ability to cast Model objects to a string to view debug information.
556
+
557
+ ## 3.5.0 - 2013-05-13
558
+
559
+ * Bug: Fixed a regression so that request responses are parsed only once per oncomplete event rather than multiple times
560
+ * Bug: Better cleanup of one-time events across the board (when an event is meant to fire once, it will now remove
561
+ itself from the EventDispatcher)
562
+ * Bug: `Guzzle\Log\MessageFormatter` now properly writes "total_time" and "connect_time" values
563
+ * Bug: Cloning an EntityEnclosingRequest now clones the EntityBody too
564
+ * Bug: Fixed an undefined index error when parsing nested JSON responses with a sentAs parameter that reference a
565
+ non-existent key
566
+ * Bug: All __call() method arguments are now required (helps with mocking frameworks)
567
+ * Deprecating Response::getRequest() and now using a shallow clone of a request object to remove a circular reference
568
+ to help with refcount based garbage collection of resources created by sending a request
569
+ * Deprecating ZF1 cache and log adapters. These will be removed in the next major version.
570
+ * Deprecating `Response::getPreviousResponse()` (method signature still exists, but it'sdeprecated). Use the
571
+ HistoryPlugin for a history.
572
+ * Added a `responseBody` alias for the `response_body` location
573
+ * Refactored internals to no longer rely on Response::getRequest()
574
+ * HistoryPlugin can now be cast to a string
575
+ * HistoryPlugin now logs transactions rather than requests and responses to more accurately keep track of the requests
576
+ and responses that are sent over the wire
577
+ * Added `getEffectiveUrl()` and `getRedirectCount()` to Response objects
578
+
579
+ ## 3.4.3 - 2013-04-30
580
+
581
+ * Bug fix: Fixing bug introduced in 3.4.2 where redirect responses are duplicated on the final redirected response
582
+ * Added a check to re-extract the temp cacert bundle from the phar before sending each request
583
+
584
+ ## 3.4.2 - 2013-04-29
585
+
586
+ * Bug fix: Stream objects now work correctly with "a" and "a+" modes
587
+ * Bug fix: Removing `Transfer-Encoding: chunked` header when a Content-Length is present
588
+ * Bug fix: AsyncPlugin no longer forces HEAD requests
589
+ * Bug fix: DateTime timezones are now properly handled when using the service description schema formatter
590
+ * Bug fix: CachePlugin now properly handles stale-if-error directives when a request to the origin server fails
591
+ * Setting a response on a request will write to the custom request body from the response body if one is specified
592
+ * LogPlugin now writes to php://output when STDERR is undefined
593
+ * Added the ability to set multiple POST files for the same key in a single call
594
+ * application/x-www-form-urlencoded POSTs now use the utf-8 charset by default
595
+ * Added the ability to queue CurlExceptions to the MockPlugin
596
+ * Cleaned up how manual responses are queued on requests (removed "queued_response" and now using request.before_send)
597
+ * Configuration loading now allows remote files
598
+
599
+ ## 3.4.1 - 2013-04-16
600
+
601
+ * Large refactoring to how CurlMulti handles work. There is now a proxy that sits in front of a pool of CurlMulti
602
+ handles. This greatly simplifies the implementation, fixes a couple bugs, and provides a small performance boost.
603
+ * Exceptions are now properly grouped when sending requests in parallel
604
+ * Redirects are now properly aggregated when a multi transaction fails
605
+ * Redirects now set the response on the original object even in the event of a failure
606
+ * Bug fix: Model names are now properly set even when using $refs
607
+ * Added support for PHP 5.5's CurlFile to prevent warnings with the deprecated @ syntax
608
+ * Added support for oauth_callback in OAuth signatures
609
+ * Added support for oauth_verifier in OAuth signatures
610
+ * Added support to attempt to retrieve a command first literally, then ucfirst, the with inflection
611
+
612
+ ## 3.4.0 - 2013-04-11
613
+
614
+ * Bug fix: URLs are now resolved correctly based on http://tools.ietf.org/html/rfc3986#section-5.2. #289
615
+ * Bug fix: Absolute URLs with a path in a service description will now properly override the base URL. #289
616
+ * Bug fix: Parsing a query string with a single PHP array value will now result in an array. #263
617
+ * Bug fix: Better normalization of the User-Agent header to prevent duplicate headers. #264.
618
+ * Bug fix: Added `number` type to service descriptions.
619
+ * Bug fix: empty parameters are removed from an OAuth signature
620
+ * Bug fix: Revalidating a cache entry prefers the Last-Modified over the Date header
621
+ * Bug fix: Fixed "array to string" error when validating a union of types in a service description
622
+ * Bug fix: Removed code that attempted to determine the size of a stream when data is written to the stream
623
+ * Bug fix: Not including an `oauth_token` if the value is null in the OauthPlugin.
624
+ * Bug fix: Now correctly aggregating successful requests and failed requests in CurlMulti when a redirect occurs.
625
+ * The new default CURLOPT_TIMEOUT setting has been increased to 150 seconds so that Guzzle works on poor connections.
626
+ * Added a feature to EntityEnclosingRequest::setBody() that will automatically set the Content-Type of the request if
627
+ the Content-Type can be determined based on the entity body or the path of the request.
628
+ * Added the ability to overwrite configuration settings in a client when grabbing a throwaway client from a builder.
629
+ * Added support for a PSR-3 LogAdapter.
630
+ * Added a `command.after_prepare` event
631
+ * Added `oauth_callback` parameter to the OauthPlugin
632
+ * Added the ability to create a custom stream class when using a stream factory
633
+ * Added a CachingEntityBody decorator
634
+ * Added support for `additionalParameters` in service descriptions to define how custom parameters are serialized.
635
+ * The bundled SSL certificate is now provided in the phar file and extracted when running Guzzle from a phar.
636
+ * You can now send any EntityEnclosingRequest with POST fields or POST files and cURL will handle creating bodies
637
+ * POST requests using a custom entity body are now treated exactly like PUT requests but with a custom cURL method. This
638
+ means that the redirect behavior of POST requests with custom bodies will not be the same as POST requests that use
639
+ POST fields or files (the latter is only used when emulating a form POST in the browser).
640
+ * Lots of cleanup to CurlHandle::factory and RequestFactory::createRequest
641
+
642
+ ## 3.3.1 - 2013-03-10
643
+
644
+ * Added the ability to create PHP streaming responses from HTTP requests
645
+ * Bug fix: Running any filters when parsing response headers with service descriptions
646
+ * Bug fix: OauthPlugin fixes to allow for multi-dimensional array signing, and sorting parameters before signing
647
+ * Bug fix: Removed the adding of default empty arrays and false Booleans to responses in order to be consistent across
648
+ response location visitors.
649
+ * Bug fix: Removed the possibility of creating configuration files with circular dependencies
650
+ * RequestFactory::create() now uses the key of a POST file when setting the POST file name
651
+ * Added xmlAllowEmpty to serialize an XML body even if no XML specific parameters are set
652
+
653
+ ## 3.3.0 - 2013-03-03
654
+
655
+ * A large number of performance optimizations have been made
656
+ * Bug fix: Added 'wb' as a valid write mode for streams
657
+ * Bug fix: `Guzzle\Http\Message\Response::json()` now allows scalar values to be returned
658
+ * Bug fix: Fixed bug in `Guzzle\Http\Message\Response` where wrapping quotes were stripped from `getEtag()`
659
+ * BC: Removed `Guzzle\Http\Utils` class
660
+ * BC: Setting a service description on a client will no longer modify the client's command factories.
661
+ * BC: Emitting IO events from a RequestMediator is now a parameter that must be set in a request's curl options using
662
+ the 'emit_io' key. This was previously set under a request's parameters using 'curl.emit_io'
663
+ * BC: `Guzzle\Stream\Stream::getWrapper()` and `Guzzle\Stream\Stream::getSteamType()` are no longer converted to
664
+ lowercase
665
+ * Operation parameter objects are now lazy loaded internally
666
+ * Added ErrorResponsePlugin that can throw errors for responses defined in service description operations' errorResponses
667
+ * Added support for instantiating responseType=class responseClass classes. Classes must implement
668
+ `Guzzle\Service\Command\ResponseClassInterface`
669
+ * Added support for additionalProperties for top-level parameters in responseType=model responseClasses. These
670
+ additional properties also support locations and can be used to parse JSON responses where the outermost part of the
671
+ JSON is an array
672
+ * Added support for nested renaming of JSON models (rename sentAs to name)
673
+ * CachePlugin
674
+ * Added support for stale-if-error so that the CachePlugin can now serve stale content from the cache on error
675
+ * Debug headers can now added to cached response in the CachePlugin
676
+
677
+ ## 3.2.0 - 2013-02-14
678
+
679
+ * CurlMulti is no longer reused globally. A new multi object is created per-client. This helps to isolate clients.
680
+ * URLs with no path no longer contain a "/" by default
681
+ * Guzzle\Http\QueryString does no longer manages the leading "?". This is now handled in Guzzle\Http\Url.
682
+ * BadResponseException no longer includes the full request and response message
683
+ * Adding setData() to Guzzle\Service\Description\ServiceDescriptionInterface
684
+ * Adding getResponseBody() to Guzzle\Http\Message\RequestInterface
685
+ * Various updates to classes to use ServiceDescriptionInterface type hints rather than ServiceDescription
686
+ * Header values can now be normalized into distinct values when multiple headers are combined with a comma separated list
687
+ * xmlEncoding can now be customized for the XML declaration of a XML service description operation
688
+ * Guzzle\Http\QueryString now uses Guzzle\Http\QueryAggregator\QueryAggregatorInterface objects to add custom value
689
+ aggregation and no longer uses callbacks
690
+ * The URL encoding implementation of Guzzle\Http\QueryString can now be customized
691
+ * Bug fix: Filters were not always invoked for array service description parameters
692
+ * Bug fix: Redirects now use a target response body rather than a temporary response body
693
+ * Bug fix: The default exponential backoff BackoffPlugin was not giving when the request threshold was exceeded
694
+ * Bug fix: Guzzle now takes the first found value when grabbing Cache-Control directives
695
+
696
+ ## 3.1.2 - 2013-01-27
697
+
698
+ * Refactored how operation responses are parsed. Visitors now include a before() method responsible for parsing the
699
+ response body. For example, the XmlVisitor now parses the XML response into an array in the before() method.
700
+ * Fixed an issue where cURL would not automatically decompress responses when the Accept-Encoding header was sent
701
+ * CURLOPT_SSL_VERIFYHOST is never set to 1 because it is deprecated (see 5e0ff2ef20f839e19d1eeb298f90ba3598784444)
702
+ * Fixed a bug where redirect responses were not chained correctly using getPreviousResponse()
703
+ * Setting default headers on a client after setting the user-agent will not erase the user-agent setting
704
+
705
+ ## 3.1.1 - 2013-01-20
706
+
707
+ * Adding wildcard support to Guzzle\Common\Collection::getPath()
708
+ * Adding alias support to ServiceBuilder configs
709
+ * Adding Guzzle\Service\Resource\CompositeResourceIteratorFactory and cleaning up factory interface
710
+
711
+ ## 3.1.0 - 2013-01-12
712
+
713
+ * BC: CurlException now extends from RequestException rather than BadResponseException
714
+ * BC: Renamed Guzzle\Plugin\Cache\CanCacheStrategyInterface::canCache() to canCacheRequest() and added CanCacheResponse()
715
+ * Added getData to ServiceDescriptionInterface
716
+ * Added context array to RequestInterface::setState()
717
+ * Bug: Removing hard dependency on the BackoffPlugin from Guzzle\Http
718
+ * Bug: Adding required content-type when JSON request visitor adds JSON to a command
719
+ * Bug: Fixing the serialization of a service description with custom data
720
+ * Made it easier to deal with exceptions thrown when transferring commands or requests in parallel by providing
721
+ an array of successful and failed responses
722
+ * Moved getPath from Guzzle\Service\Resource\Model to Guzzle\Common\Collection
723
+ * Added Guzzle\Http\IoEmittingEntityBody
724
+ * Moved command filtration from validators to location visitors
725
+ * Added `extends` attributes to service description parameters
726
+ * Added getModels to ServiceDescriptionInterface
727
+
728
+ ## 3.0.7 - 2012-12-19
729
+
730
+ * Fixing phar detection when forcing a cacert to system if null or true
731
+ * Allowing filename to be passed to `Guzzle\Http\Message\Request::setResponseBody()`
732
+ * Cleaning up `Guzzle\Common\Collection::inject` method
733
+ * Adding a response_body location to service descriptions
734
+
735
+ ## 3.0.6 - 2012-12-09
736
+
737
+ * CurlMulti performance improvements
738
+ * Adding setErrorResponses() to Operation
739
+ * composer.json tweaks
740
+
741
+ ## 3.0.5 - 2012-11-18
742
+
743
+ * Bug: Fixing an infinite recursion bug caused from revalidating with the CachePlugin
744
+ * Bug: Response body can now be a string containing "0"
745
+ * Bug: Using Guzzle inside of a phar uses system by default but now allows for a custom cacert
746
+ * Bug: QueryString::fromString now properly parses query string parameters that contain equal signs
747
+ * Added support for XML attributes in service description responses
748
+ * DefaultRequestSerializer now supports array URI parameter values for URI template expansion
749
+ * Added better mimetype guessing to requests and post files
750
+
751
+ ## 3.0.4 - 2012-11-11
752
+
753
+ * Bug: Fixed a bug when adding multiple cookies to a request to use the correct glue value
754
+ * Bug: Cookies can now be added that have a name, domain, or value set to "0"
755
+ * Bug: Using the system cacert bundle when using the Phar
756
+ * Added json and xml methods to Response to make it easier to parse JSON and XML response data into data structures
757
+ * Enhanced cookie jar de-duplication
758
+ * Added the ability to enable strict cookie jars that throw exceptions when invalid cookies are added
759
+ * Added setStream to StreamInterface to actually make it possible to implement custom rewind behavior for entity bodies
760
+ * Added the ability to create any sort of hash for a stream rather than just an MD5 hash
761
+
762
+ ## 3.0.3 - 2012-11-04
763
+
764
+ * Implementing redirects in PHP rather than cURL
765
+ * Added PECL URI template extension and using as default parser if available
766
+ * Bug: Fixed Content-Length parsing of Response factory
767
+ * Adding rewind() method to entity bodies and streams. Allows for custom rewinding of non-repeatable streams.
768
+ * Adding ToArrayInterface throughout library
769
+ * Fixing OauthPlugin to create unique nonce values per request
770
+
771
+ ## 3.0.2 - 2012-10-25
772
+
773
+ * Magic methods are enabled by default on clients
774
+ * Magic methods return the result of a command
775
+ * Service clients no longer require a base_url option in the factory
776
+ * Bug: Fixed an issue with URI templates where null template variables were being expanded
777
+
778
+ ## 3.0.1 - 2012-10-22
779
+
780
+ * Models can now be used like regular collection objects by calling filter, map, etc.
781
+ * Models no longer require a Parameter structure or initial data in the constructor
782
+ * Added a custom AppendIterator to get around a PHP bug with the `\AppendIterator`
783
+
784
+ ## 3.0.0 - 2012-10-15
785
+
786
+ * Rewrote service description format to be based on Swagger
787
+ * Now based on JSON schema
788
+ * Added nested input structures and nested response models
789
+ * Support for JSON and XML input and output models
790
+ * Renamed `commands` to `operations`
791
+ * Removed dot class notation
792
+ * Removed custom types
793
+ * Broke the project into smaller top-level namespaces to be more component friendly
794
+ * Removed support for XML configs and descriptions. Use arrays or JSON files.
795
+ * Removed the Validation component and Inspector
796
+ * Moved all cookie code to Guzzle\Plugin\Cookie
797
+ * Magic methods on a Guzzle\Service\Client now return the command un-executed.
798
+ * Calling getResult() or getResponse() on a command will lazily execute the command if needed.
799
+ * Now shipping with cURL's CA certs and using it by default
800
+ * Added previousResponse() method to response objects
801
+ * No longer sending Accept and Accept-Encoding headers on every request
802
+ * Only sending an Expect header by default when a payload is greater than 1MB
803
+ * Added/moved client options:
804
+ * curl.blacklist to curl.option.blacklist
805
+ * Added ssl.certificate_authority
806
+ * Added a Guzzle\Iterator component
807
+ * Moved plugins from Guzzle\Http\Plugin to Guzzle\Plugin
808
+ * Added a more robust backoff retry strategy (replaced the ExponentialBackoffPlugin)
809
+ * Added a more robust caching plugin
810
+ * Added setBody to response objects
811
+ * Updating LogPlugin to use a more flexible MessageFormatter
812
+ * Added a completely revamped build process
813
+ * Cleaning up Collection class and removing default values from the get method
814
+ * Fixed ZF2 cache adapters
815
+
816
+ ## 2.8.8 - 2012-10-15
817
+
818
+ * Bug: Fixed a cookie issue that caused dot prefixed domains to not match where popular browsers did
819
+
820
+ ## 2.8.7 - 2012-09-30
821
+
822
+ * Bug: Fixed config file aliases for JSON includes
823
+ * Bug: Fixed cookie bug on a request object by using CookieParser to parse cookies on requests
824
+ * Bug: Removing the path to a file when sending a Content-Disposition header on a POST upload
825
+ * Bug: Hardening request and response parsing to account for missing parts
826
+ * Bug: Fixed PEAR packaging
827
+ * Bug: Fixed Request::getInfo
828
+ * Bug: Fixed cases where CURLM_CALL_MULTI_PERFORM return codes were causing curl transactions to fail
829
+ * Adding the ability for the namespace Iterator factory to look in multiple directories
830
+ * Added more getters/setters/removers from service descriptions
831
+ * Added the ability to remove POST fields from OAuth signatures
832
+ * OAuth plugin now supports 2-legged OAuth
833
+
834
+ ## 2.8.6 - 2012-09-05
835
+
836
+ * Added the ability to modify and build service descriptions
837
+ * Added the use of visitors to apply parameters to locations in service descriptions using the dynamic command
838
+ * Added a `json` parameter location
839
+ * Now allowing dot notation for classes in the CacheAdapterFactory
840
+ * Using the union of two arrays rather than an array_merge when extending service builder services and service params
841
+ * Ensuring that a service is a string before doing strpos() checks on it when substituting services for references
842
+ in service builder config files.
843
+ * Services defined in two different config files that include one another will by default replace the previously
844
+ defined service, but you can now create services that extend themselves and merge their settings over the previous
845
+ * The JsonLoader now supports aliasing filenames with different filenames. This allows you to alias something like
846
+ '_default' with a default JSON configuration file.
847
+
848
+ ## 2.8.5 - 2012-08-29
849
+
850
+ * Bug: Suppressed empty arrays from URI templates
851
+ * Bug: Added the missing $options argument from ServiceDescription::factory to enable caching
852
+ * Added support for HTTP responses that do not contain a reason phrase in the start-line
853
+ * AbstractCommand commands are now invokable
854
+ * Added a way to get the data used when signing an Oauth request before a request is sent
855
+
856
+ ## 2.8.4 - 2012-08-15
857
+
858
+ * Bug: Custom delay time calculations are no longer ignored in the ExponentialBackoffPlugin
859
+ * Added the ability to transfer entity bodies as a string rather than streamed. This gets around curl error 65. Set `body_as_string` in a request's curl options to enable.
860
+ * Added a StreamInterface, EntityBodyInterface, and added ftell() to Guzzle\Common\Stream
861
+ * Added an AbstractEntityBodyDecorator and a ReadLimitEntityBody decorator to transfer only a subset of a decorated stream
862
+ * Stream and EntityBody objects will now return the file position to the previous position after a read required operation (e.g. getContentMd5())
863
+ * Added additional response status codes
864
+ * Removed SSL information from the default User-Agent header
865
+ * DELETE requests can now send an entity body
866
+ * Added an EventDispatcher to the ExponentialBackoffPlugin and added an ExponentialBackoffLogger to log backoff retries
867
+ * Added the ability of the MockPlugin to consume mocked request bodies
868
+ * LogPlugin now exposes request and response objects in the extras array
869
+
870
+ ## 2.8.3 - 2012-07-30
871
+
872
+ * Bug: Fixed a case where empty POST requests were sent as GET requests
873
+ * Bug: Fixed a bug in ExponentialBackoffPlugin that caused fatal errors when retrying an EntityEnclosingRequest that does not have a body
874
+ * Bug: Setting the response body of a request to null after completing a request, not when setting the state of a request to new
875
+ * Added multiple inheritance to service description commands
876
+ * Added an ApiCommandInterface and added `getParamNames()` and `hasParam()`
877
+ * Removed the default 2mb size cutoff from the Md5ValidatorPlugin so that it now defaults to validating everything
878
+ * Changed CurlMulti::perform to pass a smaller timeout to CurlMulti::executeHandles
879
+
880
+ ## 2.8.2 - 2012-07-24
881
+
882
+ * Bug: Query string values set to 0 are no longer dropped from the query string
883
+ * Bug: A Collection object is no longer created each time a call is made to `Guzzle\Service\Command\AbstractCommand::getRequestHeaders()`
884
+ * Bug: `+` is now treated as an encoded space when parsing query strings
885
+ * QueryString and Collection performance improvements
886
+ * Allowing dot notation for class paths in filters attribute of a service descriptions
887
+
888
+ ## 2.8.1 - 2012-07-16
889
+
890
+ * Loosening Event Dispatcher dependency
891
+ * POST redirects can now be customized using CURLOPT_POSTREDIR
892
+
893
+ ## 2.8.0 - 2012-07-15
894
+
895
+ * BC: Guzzle\Http\Query
896
+ * Query strings with empty variables will always show an equal sign unless the variable is set to QueryString::BLANK (e.g. ?acl= vs ?acl)
897
+ * Changed isEncodingValues() and isEncodingFields() to isUrlEncoding()
898
+ * Changed setEncodeValues(bool) and setEncodeFields(bool) to useUrlEncoding(bool)
899
+ * Changed the aggregation functions of QueryString to be static methods
900
+ * Can now use fromString() with querystrings that have a leading ?
901
+ * cURL configuration values can be specified in service descriptions using `curl.` prefixed parameters
902
+ * Content-Length is set to 0 before emitting the request.before_send event when sending an empty request body
903
+ * Cookies are no longer URL decoded by default
904
+ * Bug: URI template variables set to null are no longer expanded
905
+
906
+ ## 2.7.2 - 2012-07-02
907
+
908
+ * BC: Moving things to get ready for subtree splits. Moving Inflection into Common. Moving Guzzle\Http\Parser to Guzzle\Parser.
909
+ * BC: Removing Guzzle\Common\Batch\Batch::count() and replacing it with isEmpty()
910
+ * CachePlugin now allows for a custom request parameter function to check if a request can be cached
911
+ * Bug fix: CachePlugin now only caches GET and HEAD requests by default
912
+ * Bug fix: Using header glue when transferring headers over the wire
913
+ * Allowing deeply nested arrays for composite variables in URI templates
914
+ * Batch divisors can now return iterators or arrays
915
+
916
+ ## 2.7.1 - 2012-06-26
917
+
918
+ * Minor patch to update version number in UA string
919
+ * Updating build process
920
+
921
+ ## 2.7.0 - 2012-06-25
922
+
923
+ * BC: Inflection classes moved to Guzzle\Inflection. No longer static methods. Can now inject custom inflectors into classes.
924
+ * BC: Removed magic setX methods from commands
925
+ * BC: Magic methods mapped to service description commands are now inflected in the command factory rather than the client __call() method
926
+ * Verbose cURL options are no longer enabled by default. Set curl.debug to true on a client to enable.
927
+ * Bug: Now allowing colons in a response start-line (e.g. HTTP/1.1 503 Service Unavailable: Back-end server is at capacity)
928
+ * Guzzle\Service\Resource\ResourceIteratorApplyBatched now internally uses the Guzzle\Common\Batch namespace
929
+ * Added Guzzle\Service\Plugin namespace and a PluginCollectionPlugin
930
+ * Added the ability to set POST fields and files in a service description
931
+ * Guzzle\Http\EntityBody::factory() now accepts objects with a __toString() method
932
+ * Adding a command.before_prepare event to clients
933
+ * Added BatchClosureTransfer and BatchClosureDivisor
934
+ * BatchTransferException now includes references to the batch divisor and transfer strategies
935
+ * Fixed some tests so that they pass more reliably
936
+ * Added Guzzle\Common\Log\ArrayLogAdapter
937
+
938
+ ## 2.6.6 - 2012-06-10
939
+
940
+ * BC: Removing Guzzle\Http\Plugin\BatchQueuePlugin
941
+ * BC: Removing Guzzle\Service\Command\CommandSet
942
+ * Adding generic batching system (replaces the batch queue plugin and command set)
943
+ * Updating ZF cache and log adapters and now using ZF's composer repository
944
+ * Bug: Setting the name of each ApiParam when creating through an ApiCommand
945
+ * Adding result_type, result_doc, deprecated, and doc_url to service descriptions
946
+ * Bug: Changed the default cookie header casing back to 'Cookie'
947
+
948
+ ## 2.6.5 - 2012-06-03
949
+
950
+ * BC: Renaming Guzzle\Http\Message\RequestInterface::getResourceUri() to getResource()
951
+ * BC: Removing unused AUTH_BASIC and AUTH_DIGEST constants from
952
+ * BC: Guzzle\Http\Cookie is now used to manage Set-Cookie data, not Cookie data
953
+ * BC: Renaming methods in the CookieJarInterface
954
+ * Moving almost all cookie logic out of the CookiePlugin and into the Cookie or CookieJar implementations
955
+ * Making the default glue for HTTP headers ';' instead of ','
956
+ * Adding a removeValue to Guzzle\Http\Message\Header
957
+ * Adding getCookies() to request interface.
958
+ * Making it easier to add event subscribers to HasDispatcherInterface classes. Can now directly call addSubscriber()
959
+
960
+ ## 2.6.4 - 2012-05-30
961
+
962
+ * BC: Cleaning up how POST files are stored in EntityEnclosingRequest objects. Adding PostFile class.
963
+ * BC: Moving ApiCommand specific functionality from the Inspector and on to the ApiCommand
964
+ * Bug: Fixing magic method command calls on clients
965
+ * Bug: Email constraint only validates strings
966
+ * Bug: Aggregate POST fields when POST files are present in curl handle
967
+ * Bug: Fixing default User-Agent header
968
+ * Bug: Only appending or prepending parameters in commands if they are specified
969
+ * Bug: Not requiring response reason phrases or status codes to match a predefined list of codes
970
+ * Allowing the use of dot notation for class namespaces when using instance_of constraint
971
+ * Added any_match validation constraint
972
+ * Added an AsyncPlugin
973
+ * Passing request object to the calculateWait method of the ExponentialBackoffPlugin
974
+ * Allowing the result of a command object to be changed
975
+ * Parsing location and type sub values when instantiating a service description rather than over and over at runtime
976
+
977
+ ## 2.6.3 - 2012-05-23
978
+
979
+ * [BC] Guzzle\Common\FromConfigInterface no longer requires any config options.
980
+ * [BC] Refactoring how POST files are stored on an EntityEnclosingRequest. They are now separate from POST fields.
981
+ * You can now use an array of data when creating PUT request bodies in the request factory.
982
+ * Removing the requirement that HTTPS requests needed a Cache-Control: public directive to be cacheable.
983
+ * [Http] Adding support for Content-Type in multipart POST uploads per upload
984
+ * [Http] Added support for uploading multiple files using the same name (foo[0], foo[1])
985
+ * Adding more POST data operations for easier manipulation of POST data.
986
+ * You can now set empty POST fields.
987
+ * The body of a request is only shown on EntityEnclosingRequest objects that do not use POST files.
988
+ * Split the Guzzle\Service\Inspector::validateConfig method into two methods. One to initialize when a command is created, and one to validate.
989
+ * CS updates
990
+
991
+ ## 2.6.2 - 2012-05-19
992
+
993
+ * [Http] Better handling of nested scope requests in CurlMulti. Requests are now always prepares in the send() method rather than the addRequest() method.
994
+
995
+ ## 2.6.1 - 2012-05-19
996
+
997
+ * [BC] Removing 'path' support in service descriptions. Use 'uri'.
998
+ * [BC] Guzzle\Service\Inspector::parseDocBlock is now protected. Adding getApiParamsForClass() with cache.
999
+ * [BC] Removing Guzzle\Common\NullObject. Use https://github.com/mtdowling/NullObject if you need it.
1000
+ * [BC] Removing Guzzle\Common\XmlElement.
1001
+ * All commands, both dynamic and concrete, have ApiCommand objects.
1002
+ * Adding a fix for CurlMulti so that if all of the connections encounter some sort of curl error, then the loop exits.
1003
+ * Adding checks to EntityEnclosingRequest so that empty POST files and fields are ignored.
1004
+ * Making the method signature of Guzzle\Service\Builder\ServiceBuilder::factory more flexible.
1005
+
1006
+ ## 2.6.0 - 2012-05-15
1007
+
1008
+ * [BC] Moving Guzzle\Service\Builder to Guzzle\Service\Builder\ServiceBuilder
1009
+ * [BC] Executing a Command returns the result of the command rather than the command
1010
+ * [BC] Moving all HTTP parsing logic to Guzzle\Http\Parsers. Allows for faster C implementations if needed.
1011
+ * [BC] Changing the Guzzle\Http\Message\Response::setProtocol() method to accept a protocol and version in separate args.
1012
+ * [BC] Moving ResourceIterator* to Guzzle\Service\Resource
1013
+ * [BC] Completely refactored ResourceIterators to iterate over a cloned command object
1014
+ * [BC] Moved Guzzle\Http\UriTemplate to Guzzle\Http\Parser\UriTemplate\UriTemplate
1015
+ * [BC] Guzzle\Guzzle is now deprecated
1016
+ * Moving Guzzle\Common\Guzzle::inject to Guzzle\Common\Collection::inject
1017
+ * Adding Guzzle\Version class to give version information about Guzzle
1018
+ * Adding Guzzle\Http\Utils class to provide getDefaultUserAgent() and getHttpDate()
1019
+ * Adding Guzzle\Curl\CurlVersion to manage caching curl_version() data
1020
+ * ServiceDescription and ServiceBuilder are now cacheable using similar configs
1021
+ * Changing the format of XML and JSON service builder configs. Backwards compatible.
1022
+ * Cleaned up Cookie parsing
1023
+ * Trimming the default Guzzle User-Agent header
1024
+ * Adding a setOnComplete() method to Commands that is called when a command completes
1025
+ * Keeping track of requests that were mocked in the MockPlugin
1026
+ * Fixed a caching bug in the CacheAdapterFactory
1027
+ * Inspector objects can be injected into a Command object
1028
+ * Refactoring a lot of code and tests to be case insensitive when dealing with headers
1029
+ * Adding Guzzle\Http\Message\HeaderComparison for easy comparison of HTTP headers using a DSL
1030
+ * Adding the ability to set global option overrides to service builder configs
1031
+ * Adding the ability to include other service builder config files from within XML and JSON files
1032
+ * Moving the parseQuery method out of Url and on to QueryString::fromString() as a static factory method.
1033
+
1034
+ ## 2.5.0 - 2012-05-08
1035
+
1036
+ * Major performance improvements
1037
+ * [BC] Simplifying Guzzle\Common\Collection. Please check to see if you are using features that are now deprecated.
1038
+ * [BC] Using a custom validation system that allows a flyweight implementation for much faster validation. No longer using Symfony2 Validation component.
1039
+ * [BC] No longer supporting "{{ }}" for injecting into command or UriTemplates. Use "{}"
1040
+ * Added the ability to passed parameters to all requests created by a client
1041
+ * Added callback functionality to the ExponentialBackoffPlugin
1042
+ * Using microtime in ExponentialBackoffPlugin to allow more granular backoff strategies.
1043
+ * Rewinding request stream bodies when retrying requests
1044
+ * Exception is thrown when JSON response body cannot be decoded
1045
+ * Added configurable magic method calls to clients and commands. This is off by default.
1046
+ * Fixed a defect that added a hash to every parsed URL part
1047
+ * Fixed duplicate none generation for OauthPlugin.
1048
+ * Emitting an event each time a client is generated by a ServiceBuilder
1049
+ * Using an ApiParams object instead of a Collection for parameters of an ApiCommand
1050
+ * cache.* request parameters should be renamed to params.cache.*
1051
+ * Added the ability to set arbitrary curl options on requests (disable_wire, progress, etc.). See CurlHandle.
1052
+ * Added the ability to disable type validation of service descriptions
1053
+ * ServiceDescriptions and ServiceBuilders are now Serializable
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/LICENSE ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright (c) 2014 Michael Dowling, https://github.com/mtdowling <mtdowling@gmail.com>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/Makefile ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ all: clean coverage docs
2
+
3
+ start-server:
4
+ cd vendor/guzzlehttp/ringphp && make start-server
5
+
6
+ stop-server:
7
+ cd vendor/guzzlehttp/ringphp && make stop-server
8
+
9
+ test: start-server
10
+ vendor/bin/phpunit
11
+ $(MAKE) stop-server
12
+
13
+ coverage: start-server
14
+ vendor/bin/phpunit --coverage-html=artifacts/coverage
15
+ $(MAKE) stop-server
16
+
17
+ view-coverage:
18
+ open artifacts/coverage/index.html
19
+
20
+ clean:
21
+ rm -rf artifacts/*
22
+
23
+ docs:
24
+ cd docs && make html && cd ..
25
+
26
+ view-docs:
27
+ open docs/_build/html/index.html
28
+
29
+ tag:
30
+ $(if $(TAG),,$(error TAG is not defined. Pass via "make tag TAG=4.2.1"))
31
+ @echo Tagging $(TAG)
32
+ chag update $(TAG)
33
+ sed -i '' -e "s/VERSION = '.*'/VERSION = '$(TAG)'/" src/ClientInterface.php
34
+ php -l src/ClientInterface.php
35
+ git add -A
36
+ git commit -m '$(TAG) release'
37
+ chag tag
38
+
39
+ perf: start-server
40
+ php tests/perf.php
41
+ $(MAKE) stop-server
42
+
43
+ package: burgomaster
44
+ php build/packager.php
45
+
46
+ burgomaster:
47
+ mkdir -p build/artifacts
48
+ curl -s https://raw.githubusercontent.com/mtdowling/Burgomaster/0.0.2/src/Burgomaster.php > build/artifacts/Burgomaster.php
49
+
50
+ .PHONY: docs burgomaster
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/README.md ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Guzzle, PHP HTTP client and webservice framework
2
+ ================================================
3
+
4
+ [![Build Status](https://secure.travis-ci.org/guzzle/guzzle.svg?branch=master)](http://travis-ci.org/guzzle/guzzle)
5
+
6
+ Guzzle is a PHP HTTP client that makes it easy to send HTTP requests and
7
+ trivial to integrate with web services.
8
+
9
+ - Manages things like persistent connections, represents query strings as
10
+ collections, simplifies sending streaming POST requests with fields and
11
+ files, and abstracts away the underlying HTTP transport layer.
12
+ - Can send both synchronous and asynchronous requests using the same interface
13
+ without requiring a dependency on a specific event loop.
14
+ - Pluggable HTTP adapters allows Guzzle to integrate with any method you choose
15
+ for sending HTTP requests over the wire (e.g., cURL, sockets, PHP's stream
16
+ wrapper, non-blocking event loops like ReactPHP.
17
+ - Guzzle makes it so that you no longer need to fool around with cURL options,
18
+ stream contexts, or sockets.
19
+
20
+ ```php
21
+ $client = new GuzzleHttp\Client();
22
+ $response = $client->get('http://guzzlephp.org');
23
+ $res = $client->get('https://api.github.com/user', ['auth' => ['user', 'pass']]);
24
+ echo $res->getStatusCode();
25
+ // "200"
26
+ echo $res->getHeader('content-type');
27
+ // 'application/json; charset=utf8'
28
+ echo $res->getBody();
29
+ // {"type":"User"...'
30
+ var_export($res->json());
31
+ // Outputs the JSON decoded data
32
+
33
+ // Send an asynchronous request.
34
+ $req = $client->createRequest('GET', 'http://httpbin.org', ['future' => true]);
35
+ $client->send($req)->then(function ($response) {
36
+ echo 'I completed! ' . $response;
37
+ });
38
+ ```
39
+
40
+ Get more information and answers with the
41
+ [Documentation](http://guzzlephp.org/),
42
+ [Forums](https://groups.google.com/forum/?hl=en#!forum/guzzle),
43
+ and [Gitter](https://gitter.im/guzzle/guzzle).
44
+
45
+ ### Installing via Composer
46
+
47
+ The recommended way to install Guzzle is through
48
+ [Composer](http://getcomposer.org).
49
+
50
+ ```bash
51
+ # Install Composer
52
+ curl -sS https://getcomposer.org/installer | php
53
+ ```
54
+
55
+ Next, run the Composer command to install the latest stable version of Guzzle:
56
+
57
+ ```bash
58
+ composer.phar require guzzlehttp/guzzle
59
+ ```
60
+
61
+ After installing, you need to require Composer's autoloader:
62
+
63
+ ```php
64
+ require 'vendor/autoload.php';
65
+ ```
66
+
67
+ ### Documentation
68
+
69
+ More information can be found in the online documentation at
70
+ http://guzzlephp.org/.
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/UPGRADING.md ADDED
@@ -0,0 +1,1050 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Guzzle Upgrade Guide
2
+ ====================
3
+
4
+ 4.x to 5.0
5
+ ----------
6
+
7
+ ## Rewritten Adapter Layer
8
+
9
+ Guzzle now uses [RingPHP](http://ringphp.readthedocs.org/en/latest) to send
10
+ HTTP requests. The `adapter` option in a `GuzzleHttp\Client` constructor
11
+ is still supported, but it has now been renamed to `handler`. Instead of
12
+ passing a `GuzzleHttp\Adapter\AdapterInterface`, you must now pass a PHP
13
+ `callable` that follows the RingPHP specification.
14
+
15
+ ## Removed Fluent Interfaces
16
+
17
+ [Fluent interfaces were removed](http://ocramius.github.io/blog/fluent-interfaces-are-evil)
18
+ from the following classes:
19
+
20
+ - `GuzzleHttp\Collection`
21
+ - `GuzzleHttp\Url`
22
+ - `GuzzleHttp\Query`
23
+ - `GuzzleHttp\Post\PostBody`
24
+ - `GuzzleHttp\Cookie\SetCookie`
25
+
26
+ ## Removed functions.php
27
+
28
+ Removed "functions.php", so that Guzzle is truly PSR-4 compliant. The following
29
+ functions can be used as replacements.
30
+
31
+ - `GuzzleHttp\json_decode` -> `GuzzleHttp\Utils::jsonDecode`
32
+ - `GuzzleHttp\get_path` -> `GuzzleHttp\Utils::getPath`
33
+ - `GuzzleHttp\Utils::setPath` -> `GuzzleHttp\set_path`
34
+ - `GuzzleHttp\Pool::batch` -> `GuzzleHttp\batch`. This function is, however,
35
+ deprecated in favor of using `GuzzleHttp\Pool::batch()`.
36
+
37
+ The "procedural" global client has been removed with no replacement (e.g.,
38
+ `GuzzleHttp\get()`, `GuzzleHttp\post()`, etc.). Use a `GuzzleHttp\Client`
39
+ object as a replacement.
40
+
41
+ ## `throwImmediately` has been removed
42
+
43
+ The concept of "throwImmediately" has been removed from exceptions and error
44
+ events. This control mechanism was used to stop a transfer of concurrent
45
+ requests from completing. This can now be handled by throwing the exception or
46
+ by cancelling a pool of requests or each outstanding future request
47
+ individually.
48
+
49
+ ## headers event has been removed
50
+
51
+ Removed the "headers" event. This event was only useful for changing the
52
+ body a response once the headers of the response were known. You can implement
53
+ a similar behavior in a number of ways. One example might be to use a
54
+ FnStream that has access to the transaction being sent. For example, when the
55
+ first byte is written, you could check if the response headers match your
56
+ expectations, and if so, change the actual stream body that is being
57
+ written to.
58
+
59
+ ## Updates to HTTP Messages
60
+
61
+ Removed the `asArray` parameter from
62
+ `GuzzleHttp\Message\MessageInterface::getHeader`. If you want to get a header
63
+ value as an array, then use the newly added `getHeaderAsArray()` method of
64
+ `MessageInterface`. This change makes the Guzzle interfaces compatible with
65
+ the PSR-7 interfaces.
66
+
67
+ 3.x to 4.0
68
+ ----------
69
+
70
+ ## Overarching changes:
71
+
72
+ - Now requires PHP 5.4 or greater.
73
+ - No longer requires cURL to send requests.
74
+ - Guzzle no longer wraps every exception it throws. Only exceptions that are
75
+ recoverable are now wrapped by Guzzle.
76
+ - Various namespaces have been removed or renamed.
77
+ - No longer requiring the Symfony EventDispatcher. A custom event dispatcher
78
+ based on the Symfony EventDispatcher is
79
+ now utilized in `GuzzleHttp\Event\EmitterInterface` (resulting in significant
80
+ speed and functionality improvements).
81
+
82
+ Changes per Guzzle 3.x namespace are described below.
83
+
84
+ ## Batch
85
+
86
+ The `Guzzle\Batch` namespace has been removed. This is best left to
87
+ third-parties to implement on top of Guzzle's core HTTP library.
88
+
89
+ ## Cache
90
+
91
+ The `Guzzle\Cache` namespace has been removed. (Todo: No suitable replacement
92
+ has been implemented yet, but hoping to utilize a PSR cache interface).
93
+
94
+ ## Common
95
+
96
+ - Removed all of the wrapped exceptions. It's better to use the standard PHP
97
+ library for unrecoverable exceptions.
98
+ - `FromConfigInterface` has been removed.
99
+ - `Guzzle\Common\Version` has been removed. The VERSION constant can be found
100
+ at `GuzzleHttp\ClientInterface::VERSION`.
101
+
102
+ ### Collection
103
+
104
+ - `getAll` has been removed. Use `toArray` to convert a collection to an array.
105
+ - `inject` has been removed.
106
+ - `keySearch` has been removed.
107
+ - `getPath` no longer supports wildcard expressions. Use something better like
108
+ JMESPath for this.
109
+ - `setPath` now supports appending to an existing array via the `[]` notation.
110
+
111
+ ### Events
112
+
113
+ Guzzle no longer requires Symfony's EventDispatcher component. Guzzle now uses
114
+ `GuzzleHttp\Event\Emitter`.
115
+
116
+ - `Symfony\Component\EventDispatcher\EventDispatcherInterface` is replaced by
117
+ `GuzzleHttp\Event\EmitterInterface`.
118
+ - `Symfony\Component\EventDispatcher\EventDispatcher` is replaced by
119
+ `GuzzleHttp\Event\Emitter`.
120
+ - `Symfony\Component\EventDispatcher\Event` is replaced by
121
+ `GuzzleHttp\Event\Event`, and Guzzle now has an EventInterface in
122
+ `GuzzleHttp\Event\EventInterface`.
123
+ - `AbstractHasDispatcher` has moved to a trait, `HasEmitterTrait`, and
124
+ `HasDispatcherInterface` has moved to `HasEmitterInterface`. Retrieving the
125
+ event emitter of a request, client, etc. now uses the `getEmitter` method
126
+ rather than the `getDispatcher` method.
127
+
128
+ #### Emitter
129
+
130
+ - Use the `once()` method to add a listener that automatically removes itself
131
+ the first time it is invoked.
132
+ - Use the `listeners()` method to retrieve a list of event listeners rather than
133
+ the `getListeners()` method.
134
+ - Use `emit()` instead of `dispatch()` to emit an event from an emitter.
135
+ - Use `attach()` instead of `addSubscriber()` and `detach()` instead of
136
+ `removeSubscriber()`.
137
+
138
+ ```php
139
+ $mock = new Mock();
140
+ // 3.x
141
+ $request->getEventDispatcher()->addSubscriber($mock);
142
+ $request->getEventDispatcher()->removeSubscriber($mock);
143
+ // 4.x
144
+ $request->getEmitter()->attach($mock);
145
+ $request->getEmitter()->detach($mock);
146
+ ```
147
+
148
+ Use the `on()` method to add a listener rather than the `addListener()` method.
149
+
150
+ ```php
151
+ // 3.x
152
+ $request->getEventDispatcher()->addListener('foo', function (Event $event) { /* ... */ } );
153
+ // 4.x
154
+ $request->getEmitter()->on('foo', function (Event $event, $name) { /* ... */ } );
155
+ ```
156
+
157
+ ## Http
158
+
159
+ ### General changes
160
+
161
+ - The cacert.pem certificate has been moved to `src/cacert.pem`.
162
+ - Added the concept of adapters that are used to transfer requests over the
163
+ wire.
164
+ - Simplified the event system.
165
+ - Sending requests in parallel is still possible, but batching is no longer a
166
+ concept of the HTTP layer. Instead, you must use the `complete` and `error`
167
+ events to asynchronously manage parallel request transfers.
168
+ - `Guzzle\Http\Url` has moved to `GuzzleHttp\Url`.
169
+ - `Guzzle\Http\QueryString` has moved to `GuzzleHttp\Query`.
170
+ - QueryAggregators have been rewritten so that they are simply callable
171
+ functions.
172
+ - `GuzzleHttp\StaticClient` has been removed. Use the functions provided in
173
+ `functions.php` for an easy to use static client instance.
174
+ - Exceptions in `GuzzleHttp\Exception` have been updated to all extend from
175
+ `GuzzleHttp\Exception\TransferException`.
176
+
177
+ ### Client
178
+
179
+ Calling methods like `get()`, `post()`, `head()`, etc. no longer create and
180
+ return a request, but rather creates a request, sends the request, and returns
181
+ the response.
182
+
183
+ ```php
184
+ // 3.0
185
+ $request = $client->get('/');
186
+ $response = $request->send();
187
+
188
+ // 4.0
189
+ $response = $client->get('/');
190
+
191
+ // or, to mirror the previous behavior
192
+ $request = $client->createRequest('GET', '/');
193
+ $response = $client->send($request);
194
+ ```
195
+
196
+ `GuzzleHttp\ClientInterface` has changed.
197
+
198
+ - The `send` method no longer accepts more than one request. Use `sendAll` to
199
+ send multiple requests in parallel.
200
+ - `setUserAgent()` has been removed. Use a default request option instead. You
201
+ could, for example, do something like:
202
+ `$client->setConfig('defaults/headers/User-Agent', 'Foo/Bar ' . $client::getDefaultUserAgent())`.
203
+ - `setSslVerification()` has been removed. Use default request options instead,
204
+ like `$client->setConfig('defaults/verify', true)`.
205
+
206
+ `GuzzleHttp\Client` has changed.
207
+
208
+ - The constructor now accepts only an associative array. You can include a
209
+ `base_url` string or array to use a URI template as the base URL of a client.
210
+ You can also specify a `defaults` key that is an associative array of default
211
+ request options. You can pass an `adapter` to use a custom adapter,
212
+ `batch_adapter` to use a custom adapter for sending requests in parallel, or
213
+ a `message_factory` to change the factory used to create HTTP requests and
214
+ responses.
215
+ - The client no longer emits a `client.create_request` event.
216
+ - Creating requests with a client no longer automatically utilize a URI
217
+ template. You must pass an array into a creational method (e.g.,
218
+ `createRequest`, `get`, `put`, etc.) in order to expand a URI template.
219
+
220
+ ### Messages
221
+
222
+ Messages no longer have references to their counterparts (i.e., a request no
223
+ longer has a reference to it's response, and a response no loger has a
224
+ reference to its request). This association is now managed through a
225
+ `GuzzleHttp\Adapter\TransactionInterface` object. You can get references to
226
+ these transaction objects using request events that are emitted over the
227
+ lifecycle of a request.
228
+
229
+ #### Requests with a body
230
+
231
+ - `GuzzleHttp\Message\EntityEnclosingRequest` and
232
+ `GuzzleHttp\Message\EntityEnclosingRequestInterface` have been removed. The
233
+ separation between requests that contain a body and requests that do not
234
+ contain a body has been removed, and now `GuzzleHttp\Message\RequestInterface`
235
+ handles both use cases.
236
+ - Any method that previously accepts a `GuzzleHttp\Response` object now accept a
237
+ `GuzzleHttp\Message\ResponseInterface`.
238
+ - `GuzzleHttp\Message\RequestFactoryInterface` has been renamed to
239
+ `GuzzleHttp\Message\MessageFactoryInterface`. This interface is used to create
240
+ both requests and responses and is implemented in
241
+ `GuzzleHttp\Message\MessageFactory`.
242
+ - POST field and file methods have been removed from the request object. You
243
+ must now use the methods made available to `GuzzleHttp\Post\PostBodyInterface`
244
+ to control the format of a POST body. Requests that are created using a
245
+ standard `GuzzleHttp\Message\MessageFactoryInterface` will automatically use
246
+ a `GuzzleHttp\Post\PostBody` body if the body was passed as an array or if
247
+ the method is POST and no body is provided.
248
+
249
+ ```php
250
+ $request = $client->createRequest('POST', '/');
251
+ $request->getBody()->setField('foo', 'bar');
252
+ $request->getBody()->addFile(new PostFile('file_key', fopen('/path/to/content', 'r')));
253
+ ```
254
+
255
+ #### Headers
256
+
257
+ - `GuzzleHttp\Message\Header` has been removed. Header values are now simply
258
+ represented by an array of values or as a string. Header values are returned
259
+ as a string by default when retrieving a header value from a message. You can
260
+ pass an optional argument of `true` to retrieve a header value as an array
261
+ of strings instead of a single concatenated string.
262
+ - `GuzzleHttp\PostFile` and `GuzzleHttp\PostFileInterface` have been moved to
263
+ `GuzzleHttp\Post`. This interface has been simplified and now allows the
264
+ addition of arbitrary headers.
265
+ - Custom headers like `GuzzleHttp\Message\Header\Link` have been removed. Most
266
+ of the custom headers are now handled separately in specific
267
+ subscribers/plugins, and `GuzzleHttp\Message\HeaderValues::parseParams()` has
268
+ been updated to properly handle headers that contain parameters (like the
269
+ `Link` header).
270
+
271
+ #### Responses
272
+
273
+ - `GuzzleHttp\Message\Response::getInfo()` and
274
+ `GuzzleHttp\Message\Response::setInfo()` have been removed. Use the event
275
+ system to retrieve this type of information.
276
+ - `GuzzleHttp\Message\Response::getRawHeaders()` has been removed.
277
+ - `GuzzleHttp\Message\Response::getMessage()` has been removed.
278
+ - `GuzzleHttp\Message\Response::calculateAge()` and other cache specific
279
+ methods have moved to the CacheSubscriber.
280
+ - Header specific helper functions like `getContentMd5()` have been removed.
281
+ Just use `getHeader('Content-MD5')` instead.
282
+ - `GuzzleHttp\Message\Response::setRequest()` and
283
+ `GuzzleHttp\Message\Response::getRequest()` have been removed. Use the event
284
+ system to work with request and response objects as a transaction.
285
+ - `GuzzleHttp\Message\Response::getRedirectCount()` has been removed. Use the
286
+ Redirect subscriber instead.
287
+ - `GuzzleHttp\Message\Response::isSuccessful()` and other related methods have
288
+ been removed. Use `getStatusCode()` instead.
289
+
290
+ #### Streaming responses
291
+
292
+ Streaming requests can now be created by a client directly, returning a
293
+ `GuzzleHttp\Message\ResponseInterface` object that contains a body stream
294
+ referencing an open PHP HTTP stream.
295
+
296
+ ```php
297
+ // 3.0
298
+ use Guzzle\Stream\PhpStreamRequestFactory;
299
+ $request = $client->get('/');
300
+ $factory = new PhpStreamRequestFactory();
301
+ $stream = $factory->fromRequest($request);
302
+ $data = $stream->read(1024);
303
+
304
+ // 4.0
305
+ $response = $client->get('/', ['stream' => true]);
306
+ // Read some data off of the stream in the response body
307
+ $data = $response->getBody()->read(1024);
308
+ ```
309
+
310
+ #### Redirects
311
+
312
+ The `configureRedirects()` method has been removed in favor of a
313
+ `allow_redirects` request option.
314
+
315
+ ```php
316
+ // Standard redirects with a default of a max of 5 redirects
317
+ $request = $client->createRequest('GET', '/', ['allow_redirects' => true]);
318
+
319
+ // Strict redirects with a custom number of redirects
320
+ $request = $client->createRequest('GET', '/', [
321
+ 'allow_redirects' => ['max' => 5, 'strict' => true]
322
+ ]);
323
+ ```
324
+
325
+ #### EntityBody
326
+
327
+ EntityBody interfaces and classes have been removed or moved to
328
+ `GuzzleHttp\Stream`. All classes and interfaces that once required
329
+ `GuzzleHttp\EntityBodyInterface` now require
330
+ `GuzzleHttp\Stream\StreamInterface`. Creating a new body for a request no
331
+ longer uses `GuzzleHttp\EntityBody::factory` but now uses
332
+ `GuzzleHttp\Stream\Stream::factory` or even better:
333
+ `GuzzleHttp\Stream\create()`.
334
+
335
+ - `Guzzle\Http\EntityBodyInterface` is now `GuzzleHttp\Stream\StreamInterface`
336
+ - `Guzzle\Http\EntityBody` is now `GuzzleHttp\Stream\Stream`
337
+ - `Guzzle\Http\CachingEntityBody` is now `GuzzleHttp\Stream\CachingStream`
338
+ - `Guzzle\Http\ReadLimitEntityBody` is now `GuzzleHttp\Stream\LimitStream`
339
+ - `Guzzle\Http\IoEmittyinEntityBody` has been removed.
340
+
341
+ #### Request lifecycle events
342
+
343
+ Requests previously submitted a large number of requests. The number of events
344
+ emitted over the lifecycle of a request has been significantly reduced to make
345
+ it easier to understand how to extend the behavior of a request. All events
346
+ emitted during the lifecycle of a request now emit a custom
347
+ `GuzzleHttp\Event\EventInterface` object that contains context providing
348
+ methods and a way in which to modify the transaction at that specific point in
349
+ time (e.g., intercept the request and set a response on the transaction).
350
+
351
+ - `request.before_send` has been renamed to `before` and now emits a
352
+ `GuzzleHttp\Event\BeforeEvent`
353
+ - `request.complete` has been renamed to `complete` and now emits a
354
+ `GuzzleHttp\Event\CompleteEvent`.
355
+ - `request.sent` has been removed. Use `complete`.
356
+ - `request.success` has been removed. Use `complete`.
357
+ - `error` is now an event that emits a `GuzzleHttp\Event\ErrorEvent`.
358
+ - `request.exception` has been removed. Use `error`.
359
+ - `request.receive.status_line` has been removed.
360
+ - `curl.callback.progress` has been removed. Use a custom `StreamInterface` to
361
+ maintain a status update.
362
+ - `curl.callback.write` has been removed. Use a custom `StreamInterface` to
363
+ intercept writes.
364
+ - `curl.callback.read` has been removed. Use a custom `StreamInterface` to
365
+ intercept reads.
366
+
367
+ `headers` is a new event that is emitted after the response headers of a
368
+ request have been received before the body of the response is downloaded. This
369
+ event emits a `GuzzleHttp\Event\HeadersEvent`.
370
+
371
+ You can intercept a request and inject a response using the `intercept()` event
372
+ of a `GuzzleHttp\Event\BeforeEvent`, `GuzzleHttp\Event\CompleteEvent`, and
373
+ `GuzzleHttp\Event\ErrorEvent` event.
374
+
375
+ See: http://docs.guzzlephp.org/en/latest/events.html
376
+
377
+ ## Inflection
378
+
379
+ The `Guzzle\Inflection` namespace has been removed. This is not a core concern
380
+ of Guzzle.
381
+
382
+ ## Iterator
383
+
384
+ The `Guzzle\Iterator` namespace has been removed.
385
+
386
+ - `Guzzle\Iterator\AppendIterator`, `Guzzle\Iterator\ChunkedIterator`, and
387
+ `Guzzle\Iterator\MethodProxyIterator` are nice, but not a core requirement of
388
+ Guzzle itself.
389
+ - `Guzzle\Iterator\FilterIterator` is no longer needed because an equivalent
390
+ class is shipped with PHP 5.4.
391
+ - `Guzzle\Iterator\MapIterator` is not really needed when using PHP 5.5 because
392
+ it's easier to just wrap an iterator in a generator that maps values.
393
+
394
+ For a replacement of these iterators, see https://github.com/nikic/iter
395
+
396
+ ## Log
397
+
398
+ The LogPlugin has moved to https://github.com/guzzle/log-subscriber. The
399
+ `Guzzle\Log` namespace has been removed. Guzzle now relies on
400
+ `Psr\Log\LoggerInterface` for all logging. The MessageFormatter class has been
401
+ moved to `GuzzleHttp\Subscriber\Log\Formatter`.
402
+
403
+ ## Parser
404
+
405
+ The `Guzzle\Parser` namespace has been removed. This was previously used to
406
+ make it possible to plug in custom parsers for cookies, messages, URI
407
+ templates, and URLs; however, this level of complexity is not needed in Guzzle
408
+ so it has been removed.
409
+
410
+ - Cookie: Cookie parsing logic has been moved to
411
+ `GuzzleHttp\Cookie\SetCookie::fromString`.
412
+ - Message: Message parsing logic for both requests and responses has been moved
413
+ to `GuzzleHttp\Message\MessageFactory::fromMessage`. Message parsing is only
414
+ used in debugging or deserializing messages, so it doesn't make sense for
415
+ Guzzle as a library to add this level of complexity to parsing messages.
416
+ - UriTemplate: URI template parsing has been moved to
417
+ `GuzzleHttp\UriTemplate`. The Guzzle library will automatically use the PECL
418
+ URI template library if it is installed.
419
+ - Url: URL parsing is now performed in `GuzzleHttp\Url::fromString` (previously
420
+ it was `Guzzle\Http\Url::factory()`). If custom URL parsing is necessary,
421
+ then developers are free to subclass `GuzzleHttp\Url`.
422
+
423
+ ## Plugin
424
+
425
+ The `Guzzle\Plugin` namespace has been renamed to `GuzzleHttp\Subscriber`.
426
+ Several plugins are shipping with the core Guzzle library under this namespace.
427
+
428
+ - `GuzzleHttp\Subscriber\Cookie`: Replaces the old CookiePlugin. Cookie jar
429
+ code has moved to `GuzzleHttp\Cookie`.
430
+ - `GuzzleHttp\Subscriber\History`: Replaces the old HistoryPlugin.
431
+ - `GuzzleHttp\Subscriber\HttpError`: Throws errors when a bad HTTP response is
432
+ received.
433
+ - `GuzzleHttp\Subscriber\Mock`: Replaces the old MockPlugin.
434
+ - `GuzzleHttp\Subscriber\Prepare`: Prepares the body of a request just before
435
+ sending. This subscriber is attached to all requests by default.
436
+ - `GuzzleHttp\Subscriber\Redirect`: Replaces the RedirectPlugin.
437
+
438
+ The following plugins have been removed (third-parties are free to re-implement
439
+ these if needed):
440
+
441
+ - `GuzzleHttp\Plugin\Async` has been removed.
442
+ - `GuzzleHttp\Plugin\CurlAuth` has been removed.
443
+ - `GuzzleHttp\Plugin\ErrorResponse\ErrorResponsePlugin` has been removed. This
444
+ functionality should instead be implemented with event listeners that occur
445
+ after normal response parsing occurs in the guzzle/command package.
446
+
447
+ The following plugins are not part of the core Guzzle package, but are provided
448
+ in separate repositories:
449
+
450
+ - `Guzzle\Http\Plugin\BackoffPlugin` has been rewritten to be muchs simpler
451
+ to build custom retry policies using simple functions rather than various
452
+ chained classes. See: https://github.com/guzzle/retry-subscriber
453
+ - `Guzzle\Http\Plugin\Cache\CachePlugin` has moved to
454
+ https://github.com/guzzle/cache-subscriber
455
+ - `Guzzle\Http\Plugin\Log\LogPlugin` has moved to
456
+ https://github.com/guzzle/log-subscriber
457
+ - `Guzzle\Http\Plugin\Md5\Md5Plugin` has moved to
458
+ https://github.com/guzzle/message-integrity-subscriber
459
+ - `Guzzle\Http\Plugin\Mock\MockPlugin` has moved to
460
+ `GuzzleHttp\Subscriber\MockSubscriber`.
461
+ - `Guzzle\Http\Plugin\Oauth\OauthPlugin` has moved to
462
+ https://github.com/guzzle/oauth-subscriber
463
+
464
+ ## Service
465
+
466
+ The service description layer of Guzzle has moved into two separate packages:
467
+
468
+ - http://github.com/guzzle/command Provides a high level abstraction over web
469
+ services by representing web service operations using commands.
470
+ - http://github.com/guzzle/guzzle-services Provides an implementation of
471
+ guzzle/command that provides request serialization and response parsing using
472
+ Guzzle service descriptions.
473
+
474
+ ## Stream
475
+
476
+ Stream have moved to a separate package available at
477
+ https://github.com/guzzle/streams.
478
+
479
+ `Guzzle\Stream\StreamInterface` has been given a large update to cleanly take
480
+ on the responsibilities of `Guzzle\Http\EntityBody` and
481
+ `Guzzle\Http\EntityBodyInterface` now that they have been removed. The number
482
+ of methods implemented by the `StreamInterface` has been drastically reduced to
483
+ allow developers to more easily extend and decorate stream behavior.
484
+
485
+ ## Removed methods from StreamInterface
486
+
487
+ - `getStream` and `setStream` have been removed to better encapsulate streams.
488
+ - `getMetadata` and `setMetadata` have been removed in favor of
489
+ `GuzzleHttp\Stream\MetadataStreamInterface`.
490
+ - `getWrapper`, `getWrapperData`, `getStreamType`, and `getUri` have all been
491
+ removed. This data is accessible when
492
+ using streams that implement `GuzzleHttp\Stream\MetadataStreamInterface`.
493
+ - `rewind` has been removed. Use `seek(0)` for a similar behavior.
494
+
495
+ ## Renamed methods
496
+
497
+ - `detachStream` has been renamed to `detach`.
498
+ - `feof` has been renamed to `eof`.
499
+ - `ftell` has been renamed to `tell`.
500
+ - `readLine` has moved from an instance method to a static class method of
501
+ `GuzzleHttp\Stream\Stream`.
502
+
503
+ ## Metadata streams
504
+
505
+ `GuzzleHttp\Stream\MetadataStreamInterface` has been added to denote streams
506
+ that contain additional metadata accessible via `getMetadata()`.
507
+ `GuzzleHttp\Stream\StreamInterface::getMetadata` and
508
+ `GuzzleHttp\Stream\StreamInterface::setMetadata` have been removed.
509
+
510
+ ## StreamRequestFactory
511
+
512
+ The entire concept of the StreamRequestFactory has been removed. The way this
513
+ was used in Guzzle 3 broke the actual interface of sending streaming requests
514
+ (instead of getting back a Response, you got a StreamInterface). Streeaming
515
+ PHP requests are now implemented throught the `GuzzleHttp\Adapter\StreamAdapter`.
516
+
517
+ 3.6 to 3.7
518
+ ----------
519
+
520
+ ### Deprecations
521
+
522
+ - You can now enable E_USER_DEPRECATED warnings to see if you are using any deprecated methods.:
523
+
524
+ ```php
525
+ \Guzzle\Common\Version::$emitWarnings = true;
526
+ ```
527
+
528
+ The following APIs and options have been marked as deprecated:
529
+
530
+ - Marked `Guzzle\Http\Message\Request::isResponseBodyRepeatable()` as deprecated. Use `$request->getResponseBody()->isRepeatable()` instead.
531
+ - Marked `Guzzle\Http\Message\Request::canCache()` as deprecated. Use `Guzzle\Plugin\Cache\DefaultCanCacheStrategy->canCacheRequest()` instead.
532
+ - Marked `Guzzle\Http\Message\Request::canCache()` as deprecated. Use `Guzzle\Plugin\Cache\DefaultCanCacheStrategy->canCacheRequest()` instead.
533
+ - Marked `Guzzle\Http\Message\Request::setIsRedirect()` as deprecated. Use the HistoryPlugin instead.
534
+ - Marked `Guzzle\Http\Message\Request::isRedirect()` as deprecated. Use the HistoryPlugin instead.
535
+ - Marked `Guzzle\Cache\CacheAdapterFactory::factory()` as deprecated
536
+ - Marked `Guzzle\Service\Client::enableMagicMethods()` as deprecated. Magic methods can no longer be disabled on a Guzzle\Service\Client.
537
+ - Marked `Guzzle\Parser\Url\UrlParser` as deprecated. Just use PHP's `parse_url()` and percent encode your UTF-8.
538
+ - Marked `Guzzle\Common\Collection::inject()` as deprecated.
539
+ - Marked `Guzzle\Plugin\CurlAuth\CurlAuthPlugin` as deprecated. Use
540
+ `$client->getConfig()->setPath('request.options/auth', array('user', 'pass', 'Basic|Digest|NTLM|Any'));` or
541
+ `$client->setDefaultOption('auth', array('user', 'pass', 'Basic|Digest|NTLM|Any'));`
542
+
543
+ 3.7 introduces `request.options` as a parameter for a client configuration and as an optional argument to all creational
544
+ request methods. When paired with a client's configuration settings, these options allow you to specify default settings
545
+ for various aspects of a request. Because these options make other previous configuration options redundant, several
546
+ configuration options and methods of a client and AbstractCommand have been deprecated.
547
+
548
+ - Marked `Guzzle\Service\Client::getDefaultHeaders()` as deprecated. Use `$client->getDefaultOption('headers')`.
549
+ - Marked `Guzzle\Service\Client::setDefaultHeaders()` as deprecated. Use `$client->setDefaultOption('headers/{header_name}', 'value')`.
550
+ - Marked 'request.params' for `Guzzle\Http\Client` as deprecated. Use `$client->setDefaultOption('params/{param_name}', 'value')`
551
+ - Marked 'command.headers', 'command.response_body' and 'command.on_complete' as deprecated for AbstractCommand. These will work through Guzzle 4.0
552
+
553
+ $command = $client->getCommand('foo', array(
554
+ 'command.headers' => array('Test' => '123'),
555
+ 'command.response_body' => '/path/to/file'
556
+ ));
557
+
558
+ // Should be changed to:
559
+
560
+ $command = $client->getCommand('foo', array(
561
+ 'command.request_options' => array(
562
+ 'headers' => array('Test' => '123'),
563
+ 'save_as' => '/path/to/file'
564
+ )
565
+ ));
566
+
567
+ ### Interface changes
568
+
569
+ Additions and changes (you will need to update any implementations or subclasses you may have created):
570
+
571
+ - Added an `$options` argument to the end of the following methods of `Guzzle\Http\ClientInterface`:
572
+ createRequest, head, delete, put, patch, post, options, prepareRequest
573
+ - Added an `$options` argument to the end of `Guzzle\Http\Message\Request\RequestFactoryInterface::createRequest()`
574
+ - Added an `applyOptions()` method to `Guzzle\Http\Message\Request\RequestFactoryInterface`
575
+ - Changed `Guzzle\Http\ClientInterface::get($uri = null, $headers = null, $body = null)` to
576
+ `Guzzle\Http\ClientInterface::get($uri = null, $headers = null, $options = array())`. You can still pass in a
577
+ resource, string, or EntityBody into the $options parameter to specify the download location of the response.
578
+ - Changed `Guzzle\Common\Collection::__construct($data)` to no longer accepts a null value for `$data` but a
579
+ default `array()`
580
+ - Added `Guzzle\Stream\StreamInterface::isRepeatable`
581
+ - Made `Guzzle\Http\Client::expandTemplate` and `getUriTemplate` protected methods.
582
+
583
+ The following methods were removed from interfaces. All of these methods are still available in the concrete classes
584
+ that implement them, but you should update your code to use alternative methods:
585
+
586
+ - Removed `Guzzle\Http\ClientInterface::setDefaultHeaders(). Use
587
+ `$client->getConfig()->setPath('request.options/headers/{header_name}', 'value')`. or
588
+ `$client->getConfig()->setPath('request.options/headers', array('header_name' => 'value'))` or
589
+ `$client->setDefaultOption('headers/{header_name}', 'value')`. or
590
+ `$client->setDefaultOption('headers', array('header_name' => 'value'))`.
591
+ - Removed `Guzzle\Http\ClientInterface::getDefaultHeaders(). Use `$client->getConfig()->getPath('request.options/headers')`.
592
+ - Removed `Guzzle\Http\ClientInterface::expandTemplate()`. This is an implementation detail.
593
+ - Removed `Guzzle\Http\ClientInterface::setRequestFactory()`. This is an implementation detail.
594
+ - Removed `Guzzle\Http\ClientInterface::getCurlMulti()`. This is a very specific implementation detail.
595
+ - Removed `Guzzle\Http\Message\RequestInterface::canCache`. Use the CachePlugin.
596
+ - Removed `Guzzle\Http\Message\RequestInterface::setIsRedirect`. Use the HistoryPlugin.
597
+ - Removed `Guzzle\Http\Message\RequestInterface::isRedirect`. Use the HistoryPlugin.
598
+
599
+ ### Cache plugin breaking changes
600
+
601
+ - CacheKeyProviderInterface and DefaultCacheKeyProvider are no longer used. All of this logic is handled in a
602
+ CacheStorageInterface. These two objects and interface will be removed in a future version.
603
+ - Always setting X-cache headers on cached responses
604
+ - Default cache TTLs are now handled by the CacheStorageInterface of a CachePlugin
605
+ - `CacheStorageInterface::cache($key, Response $response, $ttl = null)` has changed to `cache(RequestInterface
606
+ $request, Response $response);`
607
+ - `CacheStorageInterface::fetch($key)` has changed to `fetch(RequestInterface $request);`
608
+ - `CacheStorageInterface::delete($key)` has changed to `delete(RequestInterface $request);`
609
+ - Added `CacheStorageInterface::purge($url)`
610
+ - `DefaultRevalidation::__construct(CacheKeyProviderInterface $cacheKey, CacheStorageInterface $cache, CachePlugin
611
+ $plugin)` has changed to `DefaultRevalidation::__construct(CacheStorageInterface $cache,
612
+ CanCacheStrategyInterface $canCache = null)`
613
+ - Added `RevalidationInterface::shouldRevalidate(RequestInterface $request, Response $response)`
614
+
615
+ 3.5 to 3.6
616
+ ----------
617
+
618
+ * Mixed casing of headers are now forced to be a single consistent casing across all values for that header.
619
+ * Messages internally use a HeaderCollection object to delegate handling case-insensitive header resolution
620
+ * Removed the whole changedHeader() function system of messages because all header changes now go through addHeader().
621
+ For example, setHeader() first removes the header using unset on a HeaderCollection and then calls addHeader().
622
+ Keeping the Host header and URL host in sync is now handled by overriding the addHeader method in Request.
623
+ * Specific header implementations can be created for complex headers. When a message creates a header, it uses a
624
+ HeaderFactory which can map specific headers to specific header classes. There is now a Link header and
625
+ CacheControl header implementation.
626
+ * Moved getLinks() from Response to just be used on a Link header object.
627
+
628
+ If you previously relied on Guzzle\Http\Message\Header::raw(), then you will need to update your code to use the
629
+ HeaderInterface (e.g. toArray(), getAll(), etc.).
630
+
631
+ ### Interface changes
632
+
633
+ * Removed from interface: Guzzle\Http\ClientInterface::setUriTemplate
634
+ * Removed from interface: Guzzle\Http\ClientInterface::setCurlMulti()
635
+ * Removed Guzzle\Http\Message\Request::receivedRequestHeader() and implemented this functionality in
636
+ Guzzle\Http\Curl\RequestMediator
637
+ * Removed the optional $asString parameter from MessageInterface::getHeader(). Just cast the header to a string.
638
+ * Removed the optional $tryChunkedTransfer option from Guzzle\Http\Message\EntityEnclosingRequestInterface
639
+ * Removed the $asObjects argument from Guzzle\Http\Message\MessageInterface::getHeaders()
640
+
641
+ ### Removed deprecated functions
642
+
643
+ * Removed Guzzle\Parser\ParserRegister::get(). Use getParser()
644
+ * Removed Guzzle\Parser\ParserRegister::set(). Use registerParser().
645
+
646
+ ### Deprecations
647
+
648
+ * The ability to case-insensitively search for header values
649
+ * Guzzle\Http\Message\Header::hasExactHeader
650
+ * Guzzle\Http\Message\Header::raw. Use getAll()
651
+ * Deprecated cache control specific methods on Guzzle\Http\Message\AbstractMessage. Use the CacheControl header object
652
+ instead.
653
+
654
+ ### Other changes
655
+
656
+ * All response header helper functions return a string rather than mixing Header objects and strings inconsistently
657
+ * Removed cURL blacklist support. This is no longer necessary now that Expect, Accept, etc. are managed by Guzzle
658
+ directly via interfaces
659
+ * Removed the injecting of a request object onto a response object. The methods to get and set a request still exist
660
+ but are a no-op until removed.
661
+ * Most classes that used to require a `Guzzle\Service\Command\CommandInterface` typehint now request a
662
+ `Guzzle\Service\Command\ArrayCommandInterface`.
663
+ * Added `Guzzle\Http\Message\RequestInterface::startResponse()` to the RequestInterface to handle injecting a response
664
+ on a request while the request is still being transferred
665
+ * `Guzzle\Service\Command\CommandInterface` now extends from ToArrayInterface and ArrayAccess
666
+
667
+ 3.3 to 3.4
668
+ ----------
669
+
670
+ Base URLs of a client now follow the rules of http://tools.ietf.org/html/rfc3986#section-5.2.2 when merging URLs.
671
+
672
+ 3.2 to 3.3
673
+ ----------
674
+
675
+ ### Response::getEtag() quote stripping removed
676
+
677
+ `Guzzle\Http\Message\Response::getEtag()` no longer strips quotes around the ETag response header
678
+
679
+ ### Removed `Guzzle\Http\Utils`
680
+
681
+ The `Guzzle\Http\Utils` class was removed. This class was only used for testing.
682
+
683
+ ### Stream wrapper and type
684
+
685
+ `Guzzle\Stream\Stream::getWrapper()` and `Guzzle\Stream\Stream::getStreamType()` are no longer converted to lowercase.
686
+
687
+ ### curl.emit_io became emit_io
688
+
689
+ Emitting IO events from a RequestMediator is now a parameter that must be set in a request's curl options using the
690
+ 'emit_io' key. This was previously set under a request's parameters using 'curl.emit_io'
691
+
692
+ 3.1 to 3.2
693
+ ----------
694
+
695
+ ### CurlMulti is no longer reused globally
696
+
697
+ Before 3.2, the same CurlMulti object was reused globally for each client. This can cause issue where plugins added
698
+ to a single client can pollute requests dispatched from other clients.
699
+
700
+ If you still wish to reuse the same CurlMulti object with each client, then you can add a listener to the
701
+ ServiceBuilder's `service_builder.create_client` event to inject a custom CurlMulti object into each client as it is
702
+ created.
703
+
704
+ ```php
705
+ $multi = new Guzzle\Http\Curl\CurlMulti();
706
+ $builder = Guzzle\Service\Builder\ServiceBuilder::factory('/path/to/config.json');
707
+ $builder->addListener('service_builder.create_client', function ($event) use ($multi) {
708
+ $event['client']->setCurlMulti($multi);
709
+ }
710
+ });
711
+ ```
712
+
713
+ ### No default path
714
+
715
+ URLs no longer have a default path value of '/' if no path was specified.
716
+
717
+ Before:
718
+
719
+ ```php
720
+ $request = $client->get('http://www.foo.com');
721
+ echo $request->getUrl();
722
+ // >> http://www.foo.com/
723
+ ```
724
+
725
+ After:
726
+
727
+ ```php
728
+ $request = $client->get('http://www.foo.com');
729
+ echo $request->getUrl();
730
+ // >> http://www.foo.com
731
+ ```
732
+
733
+ ### Less verbose BadResponseException
734
+
735
+ The exception message for `Guzzle\Http\Exception\BadResponseException` no longer contains the full HTTP request and
736
+ response information. You can, however, get access to the request and response object by calling `getRequest()` or
737
+ `getResponse()` on the exception object.
738
+
739
+ ### Query parameter aggregation
740
+
741
+ Multi-valued query parameters are no longer aggregated using a callback function. `Guzzle\Http\Query` now has a
742
+ setAggregator() method that accepts a `Guzzle\Http\QueryAggregator\QueryAggregatorInterface` object. This object is
743
+ responsible for handling the aggregation of multi-valued query string variables into a flattened hash.
744
+
745
+ 2.8 to 3.x
746
+ ----------
747
+
748
+ ### Guzzle\Service\Inspector
749
+
750
+ Change `\Guzzle\Service\Inspector::fromConfig` to `\Guzzle\Common\Collection::fromConfig`
751
+
752
+ **Before**
753
+
754
+ ```php
755
+ use Guzzle\Service\Inspector;
756
+
757
+ class YourClient extends \Guzzle\Service\Client
758
+ {
759
+ public static function factory($config = array())
760
+ {
761
+ $default = array();
762
+ $required = array('base_url', 'username', 'api_key');
763
+ $config = Inspector::fromConfig($config, $default, $required);
764
+
765
+ $client = new self(
766
+ $config->get('base_url'),
767
+ $config->get('username'),
768
+ $config->get('api_key')
769
+ );
770
+ $client->setConfig($config);
771
+
772
+ $client->setDescription(ServiceDescription::factory(__DIR__ . DIRECTORY_SEPARATOR . 'client.json'));
773
+
774
+ return $client;
775
+ }
776
+ ```
777
+
778
+ **After**
779
+
780
+ ```php
781
+ use Guzzle\Common\Collection;
782
+
783
+ class YourClient extends \Guzzle\Service\Client
784
+ {
785
+ public static function factory($config = array())
786
+ {
787
+ $default = array();
788
+ $required = array('base_url', 'username', 'api_key');
789
+ $config = Collection::fromConfig($config, $default, $required);
790
+
791
+ $client = new self(
792
+ $config->get('base_url'),
793
+ $config->get('username'),
794
+ $config->get('api_key')
795
+ );
796
+ $client->setConfig($config);
797
+
798
+ $client->setDescription(ServiceDescription::factory(__DIR__ . DIRECTORY_SEPARATOR . 'client.json'));
799
+
800
+ return $client;
801
+ }
802
+ ```
803
+
804
+ ### Convert XML Service Descriptions to JSON
805
+
806
+ **Before**
807
+
808
+ ```xml
809
+ <?xml version="1.0" encoding="UTF-8"?>
810
+ <client>
811
+ <commands>
812
+ <!-- Groups -->
813
+ <command name="list_groups" method="GET" uri="groups.json">
814
+ <doc>Get a list of groups</doc>
815
+ </command>
816
+ <command name="search_groups" method="GET" uri='search.json?query="{{query}} type:group"'>
817
+ <doc>Uses a search query to get a list of groups</doc>
818
+ <param name="query" type="string" required="true" />
819
+ </command>
820
+ <command name="create_group" method="POST" uri="groups.json">
821
+ <doc>Create a group</doc>
822
+ <param name="data" type="array" location="body" filters="json_encode" doc="Group JSON"/>
823
+ <param name="Content-Type" location="header" static="application/json"/>
824
+ </command>
825
+ <command name="delete_group" method="DELETE" uri="groups/{{id}}.json">
826
+ <doc>Delete a group by ID</doc>
827
+ <param name="id" type="integer" required="true"/>
828
+ </command>
829
+ <command name="get_group" method="GET" uri="groups/{{id}}.json">
830
+ <param name="id" type="integer" required="true"/>
831
+ </command>
832
+ <command name="update_group" method="PUT" uri="groups/{{id}}.json">
833
+ <doc>Update a group</doc>
834
+ <param name="id" type="integer" required="true"/>
835
+ <param name="data" type="array" location="body" filters="json_encode" doc="Group JSON"/>
836
+ <param name="Content-Type" location="header" static="application/json"/>
837
+ </command>
838
+ </commands>
839
+ </client>
840
+ ```
841
+
842
+ **After**
843
+
844
+ ```json
845
+ {
846
+ "name": "Zendesk REST API v2",
847
+ "apiVersion": "2012-12-31",
848
+ "description":"Provides access to Zendesk views, groups, tickets, ticket fields, and users",
849
+ "operations": {
850
+ "list_groups": {
851
+ "httpMethod":"GET",
852
+ "uri": "groups.json",
853
+ "summary": "Get a list of groups"
854
+ },
855
+ "search_groups":{
856
+ "httpMethod":"GET",
857
+ "uri": "search.json?query=\"{query} type:group\"",
858
+ "summary": "Uses a search query to get a list of groups",
859
+ "parameters":{
860
+ "query":{
861
+ "location": "uri",
862
+ "description":"Zendesk Search Query",
863
+ "type": "string",
864
+ "required": true
865
+ }
866
+ }
867
+ },
868
+ "create_group": {
869
+ "httpMethod":"POST",
870
+ "uri": "groups.json",
871
+ "summary": "Create a group",
872
+ "parameters":{
873
+ "data": {
874
+ "type": "array",
875
+ "location": "body",
876
+ "description":"Group JSON",
877
+ "filters": "json_encode",
878
+ "required": true
879
+ },
880
+ "Content-Type":{
881
+ "type": "string",
882
+ "location":"header",
883
+ "static": "application/json"
884
+ }
885
+ }
886
+ },
887
+ "delete_group": {
888
+ "httpMethod":"DELETE",
889
+ "uri": "groups/{id}.json",
890
+ "summary": "Delete a group",
891
+ "parameters":{
892
+ "id":{
893
+ "location": "uri",
894
+ "description":"Group to delete by ID",
895
+ "type": "integer",
896
+ "required": true
897
+ }
898
+ }
899
+ },
900
+ "get_group": {
901
+ "httpMethod":"GET",
902
+ "uri": "groups/{id}.json",
903
+ "summary": "Get a ticket",
904
+ "parameters":{
905
+ "id":{
906
+ "location": "uri",
907
+ "description":"Group to get by ID",
908
+ "type": "integer",
909
+ "required": true
910
+ }
911
+ }
912
+ },
913
+ "update_group": {
914
+ "httpMethod":"PUT",
915
+ "uri": "groups/{id}.json",
916
+ "summary": "Update a group",
917
+ "parameters":{
918
+ "id": {
919
+ "location": "uri",
920
+ "description":"Group to update by ID",
921
+ "type": "integer",
922
+ "required": true
923
+ },
924
+ "data": {
925
+ "type": "array",
926
+ "location": "body",
927
+ "description":"Group JSON",
928
+ "filters": "json_encode",
929
+ "required": true
930
+ },
931
+ "Content-Type":{
932
+ "type": "string",
933
+ "location":"header",
934
+ "static": "application/json"
935
+ }
936
+ }
937
+ }
938
+ }
939
+ ```
940
+
941
+ ### Guzzle\Service\Description\ServiceDescription
942
+
943
+ Commands are now called Operations
944
+
945
+ **Before**
946
+
947
+ ```php
948
+ use Guzzle\Service\Description\ServiceDescription;
949
+
950
+ $sd = new ServiceDescription();
951
+ $sd->getCommands(); // @returns ApiCommandInterface[]
952
+ $sd->hasCommand($name);
953
+ $sd->getCommand($name); // @returns ApiCommandInterface|null
954
+ $sd->addCommand($command); // @param ApiCommandInterface $command
955
+ ```
956
+
957
+ **After**
958
+
959
+ ```php
960
+ use Guzzle\Service\Description\ServiceDescription;
961
+
962
+ $sd = new ServiceDescription();
963
+ $sd->getOperations(); // @returns OperationInterface[]
964
+ $sd->hasOperation($name);
965
+ $sd->getOperation($name); // @returns OperationInterface|null
966
+ $sd->addOperation($operation); // @param OperationInterface $operation
967
+ ```
968
+
969
+ ### Guzzle\Common\Inflection\Inflector
970
+
971
+ Namespace is now `Guzzle\Inflection\Inflector`
972
+
973
+ ### Guzzle\Http\Plugin
974
+
975
+ Namespace is now `Guzzle\Plugin`. Many other changes occur within this namespace and are detailed in their own sections below.
976
+
977
+ ### Guzzle\Http\Plugin\LogPlugin and Guzzle\Common\Log
978
+
979
+ Now `Guzzle\Plugin\Log\LogPlugin` and `Guzzle\Log` respectively.
980
+
981
+ **Before**
982
+
983
+ ```php
984
+ use Guzzle\Common\Log\ClosureLogAdapter;
985
+ use Guzzle\Http\Plugin\LogPlugin;
986
+
987
+ /** @var \Guzzle\Http\Client */
988
+ $client;
989
+
990
+ // $verbosity is an integer indicating desired message verbosity level
991
+ $client->addSubscriber(new LogPlugin(new ClosureLogAdapter(function($m) { echo $m; }, $verbosity = LogPlugin::LOG_VERBOSE);
992
+ ```
993
+
994
+ **After**
995
+
996
+ ```php
997
+ use Guzzle\Log\ClosureLogAdapter;
998
+ use Guzzle\Log\MessageFormatter;
999
+ use Guzzle\Plugin\Log\LogPlugin;
1000
+
1001
+ /** @var \Guzzle\Http\Client */
1002
+ $client;
1003
+
1004
+ // $format is a string indicating desired message format -- @see MessageFormatter
1005
+ $client->addSubscriber(new LogPlugin(new ClosureLogAdapter(function($m) { echo $m; }, $format = MessageFormatter::DEBUG_FORMAT);
1006
+ ```
1007
+
1008
+ ### Guzzle\Http\Plugin\CurlAuthPlugin
1009
+
1010
+ Now `Guzzle\Plugin\CurlAuth\CurlAuthPlugin`.
1011
+
1012
+ ### Guzzle\Http\Plugin\ExponentialBackoffPlugin
1013
+
1014
+ Now `Guzzle\Plugin\Backoff\BackoffPlugin`, and other changes.
1015
+
1016
+ **Before**
1017
+
1018
+ ```php
1019
+ use Guzzle\Http\Plugin\ExponentialBackoffPlugin;
1020
+
1021
+ $backoffPlugin = new ExponentialBackoffPlugin($maxRetries, array_merge(
1022
+ ExponentialBackoffPlugin::getDefaultFailureCodes(), array(429)
1023
+ ));
1024
+
1025
+ $client->addSubscriber($backoffPlugin);
1026
+ ```
1027
+
1028
+ **After**
1029
+
1030
+ ```php
1031
+ use Guzzle\Plugin\Backoff\BackoffPlugin;
1032
+ use Guzzle\Plugin\Backoff\HttpBackoffStrategy;
1033
+
1034
+ // Use convenient factory method instead -- see implementation for ideas of what
1035
+ // you can do with chaining backoff strategies
1036
+ $backoffPlugin = BackoffPlugin::getExponentialBackoff($maxRetries, array_merge(
1037
+ HttpBackoffStrategy::getDefaultFailureCodes(), array(429)
1038
+ ));
1039
+ $client->addSubscriber($backoffPlugin);
1040
+ ```
1041
+
1042
+ ### Known Issues
1043
+
1044
+ #### [BUG] Accept-Encoding header behavior changed unintentionally.
1045
+
1046
+ (See #217) (Fixed in 09daeb8c666fb44499a0646d655a8ae36456575e)
1047
+
1048
+ In version 2.8 setting the `Accept-Encoding` header would set the CURLOPT_ENCODING option, which permitted cURL to
1049
+ properly handle gzip/deflate compressed responses from the server. In versions affected by this bug this does not happen.
1050
+ See issue #217 for a workaround, or use a version containing the fix.
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/build/packager.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require __DIR__ . '/artifacts/Burgomaster.php';
3
+
4
+ $stageDirectory = __DIR__ . '/artifacts/staging';
5
+ $projectRoot = __DIR__ . '/../';
6
+ $packager = new \Burgomaster($stageDirectory, $projectRoot);
7
+
8
+ // Copy basic files to the stage directory. Note that we have chdir'd onto
9
+ // the $projectRoot directory, so use relative paths.
10
+ foreach (['README.md', 'LICENSE'] as $file) {
11
+ $packager->deepCopy($file, $file);
12
+ }
13
+
14
+ // Copy each dependency to the staging directory. Copy *.php and *.pem files.
15
+ $packager->recursiveCopy('src', 'GuzzleHttp', ['php']);
16
+ $packager->recursiveCopy('vendor/react/promise/src', 'React/Promise');
17
+ $packager->recursiveCopy('vendor/guzzlehttp/ringphp/src', 'GuzzleHttp/Ring');
18
+ $packager->recursiveCopy('vendor/guzzlehttp/streams/src', 'GuzzleHttp/Stream');
19
+ $packager->createAutoloader(['React/Promise/functions.php']);
20
+ $packager->createPhar(__DIR__ . '/artifacts/guzzle.phar');
21
+ $packager->createZip(__DIR__ . '/artifacts/guzzle.zip');
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/composer.json ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "guzzlehttp/guzzle",
3
+ "type": "library",
4
+ "description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients",
5
+ "keywords": ["framework", "http", "rest", "web service", "curl", "client", "HTTP client"],
6
+ "homepage": "http://guzzlephp.org/",
7
+ "license": "MIT",
8
+ "authors": [
9
+ {
10
+ "name": "Michael Dowling",
11
+ "email": "mtdowling@gmail.com",
12
+ "homepage": "https://github.com/mtdowling"
13
+ }
14
+ ],
15
+ "require": {
16
+ "php": ">=5.4.0",
17
+ "guzzlehttp/ringphp": "^1.1"
18
+ },
19
+ "require-dev": {
20
+ "ext-curl": "*",
21
+ "psr/log": "^1.0",
22
+ "phpunit/phpunit": "^4.0"
23
+ },
24
+ "autoload": {
25
+ "psr-4": {
26
+ "GuzzleHttp\\": "src/"
27
+ }
28
+ },
29
+ "autoload-dev": {
30
+ "psr-4": {
31
+ "GuzzleHttp\\Tests\\": "tests/"
32
+ }
33
+ },
34
+ "extra": {
35
+ "branch-alias": {
36
+ "dev-master": "5.0-dev"
37
+ }
38
+ }
39
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/docs/Makefile ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Makefile for Sphinx documentation
2
+ #
3
+
4
+ # You can set these variables from the command line.
5
+ SPHINXOPTS =
6
+ SPHINXBUILD = sphinx-build
7
+ PAPER =
8
+ BUILDDIR = _build
9
+
10
+ # Internal variables.
11
+ PAPEROPT_a4 = -D latex_paper_size=a4
12
+ PAPEROPT_letter = -D latex_paper_size=letter
13
+ ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
14
+ # the i18n builder cannot share the environment and doctrees with the others
15
+ I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
16
+
17
+ .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
18
+
19
+ help:
20
+ @echo "Please use \`make <target>' where <target> is one of"
21
+ @echo " html to make standalone HTML files"
22
+ @echo " dirhtml to make HTML files named index.html in directories"
23
+ @echo " singlehtml to make a single large HTML file"
24
+ @echo " pickle to make pickle files"
25
+ @echo " json to make JSON files"
26
+ @echo " htmlhelp to make HTML files and a HTML help project"
27
+ @echo " qthelp to make HTML files and a qthelp project"
28
+ @echo " devhelp to make HTML files and a Devhelp project"
29
+ @echo " epub to make an epub"
30
+ @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
31
+ @echo " latexpdf to make LaTeX files and run them through pdflatex"
32
+ @echo " text to make text files"
33
+ @echo " man to make manual pages"
34
+ @echo " texinfo to make Texinfo files"
35
+ @echo " info to make Texinfo files and run them through makeinfo"
36
+ @echo " gettext to make PO message catalogs"
37
+ @echo " changes to make an overview of all changed/added/deprecated items"
38
+ @echo " linkcheck to check all external links for integrity"
39
+ @echo " doctest to run all doctests embedded in the documentation (if enabled)"
40
+
41
+ clean:
42
+ -rm -rf $(BUILDDIR)/*
43
+
44
+ html:
45
+ $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
46
+ @echo
47
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
48
+
49
+ dirhtml:
50
+ $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
51
+ @echo
52
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
53
+
54
+ singlehtml:
55
+ $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
56
+ @echo
57
+ @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
58
+
59
+ pickle:
60
+ $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
61
+ @echo
62
+ @echo "Build finished; now you can process the pickle files."
63
+
64
+ json:
65
+ $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
66
+ @echo
67
+ @echo "Build finished; now you can process the JSON files."
68
+
69
+ htmlhelp:
70
+ $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
71
+ @echo
72
+ @echo "Build finished; now you can run HTML Help Workshop with the" \
73
+ ".hhp project file in $(BUILDDIR)/htmlhelp."
74
+
75
+ qthelp:
76
+ $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
77
+ @echo
78
+ @echo "Build finished; now you can run "qcollectiongenerator" with the" \
79
+ ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
80
+ @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Guzzle.qhcp"
81
+ @echo "To view the help file:"
82
+ @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Guzzle.qhc"
83
+
84
+ devhelp:
85
+ $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
86
+ @echo
87
+ @echo "Build finished."
88
+ @echo "To view the help file:"
89
+ @echo "# mkdir -p $$HOME/.local/share/devhelp/Guzzle"
90
+ @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Guzzle"
91
+ @echo "# devhelp"
92
+
93
+ epub:
94
+ $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
95
+ @echo
96
+ @echo "Build finished. The epub file is in $(BUILDDIR)/epub."
97
+
98
+ latex:
99
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
100
+ @echo
101
+ @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
102
+ @echo "Run \`make' in that directory to run these through (pdf)latex" \
103
+ "(use \`make latexpdf' here to do that automatically)."
104
+
105
+ latexpdf:
106
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
107
+ @echo "Running LaTeX files through pdflatex..."
108
+ $(MAKE) -C $(BUILDDIR)/latex all-pdf
109
+ @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
110
+
111
+ text:
112
+ $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
113
+ @echo
114
+ @echo "Build finished. The text files are in $(BUILDDIR)/text."
115
+
116
+ man:
117
+ $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
118
+ @echo
119
+ @echo "Build finished. The manual pages are in $(BUILDDIR)/man."
120
+
121
+ texinfo:
122
+ $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
123
+ @echo
124
+ @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
125
+ @echo "Run \`make' in that directory to run these through makeinfo" \
126
+ "(use \`make info' here to do that automatically)."
127
+
128
+ info:
129
+ $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
130
+ @echo "Running Texinfo files through makeinfo..."
131
+ make -C $(BUILDDIR)/texinfo info
132
+ @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
133
+
134
+ gettext:
135
+ $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
136
+ @echo
137
+ @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
138
+
139
+ changes:
140
+ $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
141
+ @echo
142
+ @echo "The overview file is in $(BUILDDIR)/changes."
143
+
144
+ linkcheck:
145
+ $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
146
+ @echo
147
+ @echo "Link check complete; look for any errors in the above output " \
148
+ "or in $(BUILDDIR)/linkcheck/output.txt."
149
+
150
+ doctest:
151
+ $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
152
+ @echo "Testing of doctests in the sources finished, look at the " \
153
+ "results in $(BUILDDIR)/doctest/output.txt."
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/docs/_static/guzzle-icon.png ADDED
Binary file
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/docs/_static/logo.png ADDED
Binary file
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/docs/_templates/nav_links.html ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <li><a href="https://github.com/guzzle/guzzle">GitHub</a></li>
2
+ <li><a href="https://groups.google.com/forum/?hl=en#!forum/guzzle">Forum</a></li>
3
+ <li><a href="irc:irc.freenode.com/#guzzlephp">IRC</a></li>
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/docs/clients.rst ADDED
@@ -0,0 +1,1326 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ =======
2
+ Clients
3
+ =======
4
+
5
+ Clients are used to create requests, create transactions, send requests
6
+ through an HTTP handler, and return a response. You can add default request
7
+ options to a client that are applied to every request (e.g., default headers,
8
+ default query string parameters, etc.), and you can add event listeners and
9
+ subscribers to every request created by a client.
10
+
11
+ Creating a client
12
+ =================
13
+
14
+ The constructor of a client accepts an associative array of configuration
15
+ options.
16
+
17
+ base_url
18
+ Configures a base URL for the client so that requests created
19
+ using a relative URL are combined with the ``base_url`` of the client
20
+ according to section `5.2 of RFC 3986 <http://tools.ietf.org/html/rfc3986#section-5.2>`_.
21
+
22
+ .. code-block:: php
23
+
24
+ // Create a client with a base URL
25
+ $client = new GuzzleHttp\Client(['base_url' => 'https://github.com']);
26
+ // Send a request to https://github.com/notifications
27
+ $response = $client->get('/notifications');
28
+
29
+ Don't feel like reading RFC 3986? Here are some quick examples on how a
30
+ ``base_url`` is resolved with another URI.
31
+
32
+ ======================= ================== ===============================
33
+ base_url URI Result
34
+ ======================= ================== ===============================
35
+ ``http://foo.com`` ``/bar`` ``http://foo.com/bar``
36
+ ``http://foo.com/foo`` ``/bar`` ``http://foo.com/bar``
37
+ ``http://foo.com/foo`` ``bar`` ``http://foo.com/bar``
38
+ ``http://foo.com/foo/`` ``bar`` ``http://foo.com/foo/bar``
39
+ ``http://foo.com`` ``http://baz.com`` ``http://baz.com``
40
+ ``http://foo.com/?bar`` ``bar`` ``http://foo.com/bar``
41
+ ======================= ================== ===============================
42
+
43
+ handler
44
+ Configures the `RingPHP handler <http://ringphp.readthedocs.org>`_
45
+ used to transfer the HTTP requests of a client. Guzzle will, by default,
46
+ utilize a stacked handlers that chooses the best handler to use based on the
47
+ provided request options and based on the extensions available in the
48
+ environment.
49
+
50
+ message_factory
51
+ Specifies the factory used to create HTTP requests and responses
52
+ (``GuzzleHttp\Message\MessageFactoryInterface``).
53
+
54
+ defaults
55
+ Associative array of :ref:`request-options` that are applied to every
56
+ request created by the client. This allows you to specify things like
57
+ default headers (e.g., User-Agent), default query string parameters, SSL
58
+ configurations, and any other supported request options.
59
+
60
+ emitter
61
+ Specifies an event emitter (``GuzzleHttp\Event\EmitterInterface``) instance
62
+ to be used by the client to emit request events. This option is useful if
63
+ you need to inject an emitter with listeners/subscribers already attached.
64
+
65
+ Here's an example of creating a client with various options.
66
+
67
+ .. code-block:: php
68
+
69
+ use GuzzleHttp\Client;
70
+
71
+ $client = new Client([
72
+ 'base_url' => ['https://api.twitter.com/{version}/', ['version' => 'v1.1']],
73
+ 'defaults' => [
74
+ 'headers' => ['Foo' => 'Bar'],
75
+ 'query' => ['testing' => '123'],
76
+ 'auth' => ['username', 'password'],
77
+ 'proxy' => 'tcp://localhost:80'
78
+ ]
79
+ ]);
80
+
81
+ Sending Requests
82
+ ================
83
+
84
+ Requests can be created using various methods of a client. You can create
85
+ **and** send requests using one of the following methods:
86
+
87
+ - ``GuzzleHttp\Client::get``: Sends a GET request.
88
+ - ``GuzzleHttp\Client::head``: Sends a HEAD request
89
+ - ``GuzzleHttp\Client::post``: Sends a POST request
90
+ - ``GuzzleHttp\Client::put``: Sends a PUT request
91
+ - ``GuzzleHttp\Client::delete``: Sends a DELETE request
92
+ - ``GuzzleHttp\Client::options``: Sends an OPTIONS request
93
+
94
+ Each of the above methods accepts a URL as the first argument and an optional
95
+ associative array of :ref:`request-options` as the second argument.
96
+
97
+ Synchronous Requests
98
+ --------------------
99
+
100
+ Guzzle sends synchronous (blocking) requests when the ``future`` request option
101
+ is not specified. This means that the request will complete immediately, and if
102
+ an error is encountered, a ``GuzzleHttp\Exception\RequestException`` will be
103
+ thrown.
104
+
105
+ .. code-block:: php
106
+
107
+ $client = new GuzzleHttp\Client();
108
+
109
+ $client->put('http://httpbin.org', [
110
+ 'headers' => ['X-Foo' => 'Bar'],
111
+ 'body' => 'this is the body!',
112
+ 'save_to' => '/path/to/local/file',
113
+ 'allow_redirects' => false,
114
+ 'timeout' => 5
115
+ ]);
116
+
117
+ Synchronous Error Handling
118
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
119
+
120
+ When a recoverable error is encountered while calling the ``send()`` method of
121
+ a client, a ``GuzzleHttp\Exception\RequestException`` is thrown.
122
+
123
+ .. code-block:: php
124
+
125
+ use GuzzleHttp\Client;
126
+ use GuzzleHttp\Exception\RequestException;
127
+
128
+ $client = new Client();
129
+
130
+ try {
131
+ $client->get('http://httpbin.org');
132
+ } catch (RequestException $e) {
133
+ echo $e->getRequest() . "\n";
134
+ if ($e->hasResponse()) {
135
+ echo $e->getResponse() . "\n";
136
+ }
137
+ }
138
+
139
+ ``GuzzleHttp\Exception\RequestException`` always contains a
140
+ ``GuzzleHttp\Message\RequestInterface`` object that can be accessed using the
141
+ exception's ``getRequest()`` method.
142
+
143
+ A response might be present in the exception. In the event of a networking
144
+ error, no response will be received. You can check if a ``RequestException``
145
+ has a response using the ``hasResponse()`` method. If the exception has a
146
+ response, then you can access the associated
147
+ ``GuzzleHttp\Message\ResponseInterface`` using the ``getResponse()`` method of
148
+ the exception.
149
+
150
+ Asynchronous Requests
151
+ ---------------------
152
+
153
+ You can send asynchronous requests by setting the ``future`` request option
154
+ to ``true`` (or a string that your handler understands). This creates a
155
+ ``GuzzleHttp\Message\FutureResponse`` object that has not yet completed. Once
156
+ you have a future response, you can use a promise object obtained by calling
157
+ the ``then`` method of the response to take an action when the response has
158
+ completed or encounters an error.
159
+
160
+ .. code-block:: php
161
+
162
+ $response = $client->put('http://httpbin.org/get', ['future' => true]);
163
+
164
+ // Call the function when the response completes
165
+ $response->then(function ($response) {
166
+ echo $response->getStatusCode();
167
+ });
168
+
169
+ You can call the ``wait()`` method of a future response to block until it has
170
+ completed. You also use a future response object just like a normal response
171
+ object by accessing the methods of the response. Using a future response like a
172
+ normal response object, also known as *dereferencing*, will block until the
173
+ response has completed.
174
+
175
+ .. code-block:: php
176
+
177
+ $response = $client->put('http://httpbin.org/get', ['future' => true]);
178
+
179
+ // Block until the response has completed
180
+ echo $response->getStatusCode();
181
+
182
+ .. important::
183
+
184
+ If an exception occurred while transferring the future response, then the
185
+ exception encountered will be thrown when dereferencing.
186
+
187
+ .. note::
188
+
189
+ It depends on the RingPHP handler used by a client, but you typically need
190
+ to use the same RingPHP handler in order to utilize asynchronous requests
191
+ across multiple clients.
192
+
193
+ Asynchronous Error Handling
194
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
195
+
196
+ Handling errors with future response object promises is a bit different. When
197
+ using a promise, exceptions are forwarded to the ``$onError`` function provided
198
+ to the second argument of the ``then()`` function.
199
+
200
+ .. code-block:: php
201
+
202
+ $response = $client->put('http://httpbin.org/get', ['future' => true]);
203
+
204
+ $response
205
+ ->then(
206
+ function ($response) {
207
+ // This is called when the request succeeded
208
+ echo 'Success: ' . $response->getStatusCode();
209
+ // Returning a value will forward the value to the next promise
210
+ // in the chain.
211
+ return $response;
212
+ },
213
+ function ($error) {
214
+ // This is called when the exception failed.
215
+ echo 'Exception: ' . $error->getMessage();
216
+ // Throwing will "forward" the exception to the next promise
217
+ // in the chain.
218
+ throw $error;
219
+ }
220
+ )
221
+ ->then(
222
+ function($response) {
223
+ // This is called after the first promise in the chain. It
224
+ // receives the value returned from the first promise.
225
+ echo $response->getReasonPhrase();
226
+ },
227
+ function ($error) {
228
+ // This is called if the first promise error handler in the
229
+ // chain rethrows the exception.
230
+ echo 'Error: ' . $error->getMessage();
231
+ }
232
+ );
233
+
234
+ Please see the `React/Promises project documentation <https://github.com/reactphp/promise>`_
235
+ for more information on how promise resolution and rejection forwarding works.
236
+
237
+ HTTP Errors
238
+ -----------
239
+
240
+ If the ``exceptions`` request option is not set to ``false``, then exceptions
241
+ are thrown for HTTP protocol errors as well:
242
+ ``GuzzleHttp\Exception\ClientErrorResponseException`` for 4xx level HTTP
243
+ responses and ``GuzzleHttp\Exception\ServerException`` for 5xx level responses,
244
+ both of which extend from ``GuzzleHttp\Exception\BadResponseException``.
245
+
246
+ Creating Requests
247
+ -----------------
248
+
249
+ You can create a request without sending it. This is useful for building up
250
+ requests over time or sending requests in concurrently.
251
+
252
+ .. code-block:: php
253
+
254
+ $request = $client->createRequest('GET', 'http://httpbin.org', [
255
+ 'headers' => ['X-Foo' => 'Bar']
256
+ ]);
257
+
258
+ // Modify the request as needed
259
+ $request->setHeader('Baz', 'bar');
260
+
261
+ After creating a request, you can send it with the client's ``send()`` method.
262
+
263
+ .. code-block:: php
264
+
265
+ $response = $client->send($request);
266
+
267
+ Sending Requests With a Pool
268
+ ============================
269
+
270
+ You can send requests concurrently using a fixed size pool via the
271
+ ``GuzzleHttp\Pool`` class. The Pool class is an implementation of
272
+ ``GuzzleHttp\Ring\Future\FutureInterface``, meaning it can be dereferenced at a
273
+ later time or cancelled before sending. The Pool constructor accepts a client
274
+ object, iterator or array that yields ``GuzzleHttp\Message\RequestInterface``
275
+ objects, and an optional associative array of options that can be used to
276
+ affect the transfer.
277
+
278
+ .. code-block:: php
279
+
280
+ use GuzzleHttp\Pool;
281
+
282
+ $requests = [
283
+ $client->createRequest('GET', 'http://httpbin.org'),
284
+ $client->createRequest('DELETE', 'http://httpbin.org/delete'),
285
+ $client->createRequest('PUT', 'http://httpbin.org/put', ['body' => 'test'])
286
+ ];
287
+
288
+ $options = [];
289
+
290
+ // Create a pool. Note: the options array is optional.
291
+ $pool = new Pool($client, $requests, $options);
292
+
293
+ // Send the requests
294
+ $pool->wait();
295
+
296
+ The Pool constructor accepts the following associative array of options:
297
+
298
+ - **pool_size**: Integer representing the maximum number of requests that are
299
+ allowed to be sent concurrently.
300
+ - **before**: Callable or array representing the event listeners to add to
301
+ each request's :ref:`before_event` event.
302
+ - **complete**: Callable or array representing the event listeners to add to
303
+ each request's :ref:`complete_event` event.
304
+ - **error**: Callable or array representing the event listeners to add to
305
+ each request's :ref:`error_event` event.
306
+ - **end**: Callable or array representing the event listeners to add to
307
+ each request's :ref:`end_event` event.
308
+
309
+ The "before", "complete", "error", and "end" event options accept a callable or
310
+ an array of associative arrays where each associative array contains a "fn" key
311
+ with a callable value, an optional "priority" key representing the event
312
+ priority (with a default value of 0), and an optional "once" key that can be
313
+ set to true so that the event listener will be removed from the request after
314
+ it is first triggered.
315
+
316
+ .. code-block:: php
317
+
318
+ use GuzzleHttp\Pool;
319
+ use GuzzleHttp\Event\CompleteEvent;
320
+
321
+ // Add a single event listener using a callable.
322
+ Pool::send($client, $requests, [
323
+ 'complete' => function (CompleteEvent $event) {
324
+ echo 'Completed request to ' . $event->getRequest()->getUrl() . "\n";
325
+ echo 'Response: ' . $event->getResponse()->getBody() . "\n\n";
326
+ }
327
+ ]);
328
+
329
+ // The above is equivalent to the following, but the following structure
330
+ // allows you to add multiple event listeners to the same event name.
331
+ Pool::send($client, $requests, [
332
+ 'complete' => [
333
+ [
334
+ 'fn' => function (CompleteEvent $event) { /* ... */ },
335
+ 'priority' => 0, // Optional
336
+ 'once' => false // Optional
337
+ ]
338
+ ]
339
+ ]);
340
+
341
+ Asynchronous Response Handling
342
+ ------------------------------
343
+
344
+ When sending requests concurrently using a pool, the request/response/error
345
+ lifecycle must be handled asynchronously. This means that you give the Pool
346
+ multiple requests and handle the response or errors that is associated with the
347
+ request using event callbacks.
348
+
349
+ .. code-block:: php
350
+
351
+ use GuzzleHttp\Pool;
352
+ use GuzzleHttp\Event\ErrorEvent;
353
+
354
+ Pool::send($client, $requests, [
355
+ 'complete' => function (CompleteEvent $event) {
356
+ echo 'Completed request to ' . $event->getRequest()->getUrl() . "\n";
357
+ echo 'Response: ' . $event->getResponse()->getBody() . "\n\n";
358
+ // Do something with the completion of the request...
359
+ },
360
+ 'error' => function (ErrorEvent $event) {
361
+ echo 'Request failed: ' . $event->getRequest()->getUrl() . "\n";
362
+ echo $event->getException();
363
+ // Do something to handle the error...
364
+ }
365
+ ]);
366
+
367
+ The ``GuzzleHttp\Event\ErrorEvent`` event object is emitted when an error
368
+ occurs during a transfer. With this event, you have access to the request that
369
+ was sent, the response that was received (if one was received), access to
370
+ transfer statistics, and the ability to intercept the exception with a
371
+ different ``GuzzleHttp\Message\ResponseInterface`` object. See :doc:`events`
372
+ for more information.
373
+
374
+ Handling Errors After Transferring
375
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
376
+
377
+ It sometimes might be easier to handle all of the errors that occurred during a
378
+ transfer after all of the requests have been sent. Here we are adding each
379
+ failed request to an array that we can use to process errors later.
380
+
381
+ .. code-block:: php
382
+
383
+ use GuzzleHttp\Pool;
384
+ use GuzzleHttp\Event\ErrorEvent;
385
+
386
+ $errors = [];
387
+ Pool::send($client, $requests, [
388
+ 'error' => function (ErrorEvent $event) use (&$errors) {
389
+ $errors[] = $event;
390
+ }
391
+ ]);
392
+
393
+ foreach ($errors as $error) {
394
+ // Handle the error...
395
+ }
396
+
397
+ .. _batch-requests:
398
+
399
+ Batching Requests
400
+ -----------------
401
+
402
+ Sometimes you just want to send a few requests concurrently and then process
403
+ the results all at once after they've been sent. Guzzle provides a convenience
404
+ function ``GuzzleHttp\Pool::batch()`` that makes this very simple:
405
+
406
+ .. code-block:: php
407
+
408
+ use GuzzleHttp\Pool;
409
+ use GuzzleHttp\Client;
410
+
411
+ $client = new Client();
412
+
413
+ $requests = [
414
+ $client->createRequest('GET', 'http://httpbin.org/get'),
415
+ $client->createRequest('HEAD', 'http://httpbin.org/get'),
416
+ $client->createRequest('PUT', 'http://httpbin.org/put'),
417
+ ];
418
+
419
+ // Results is a GuzzleHttp\BatchResults object.
420
+ $results = Pool::batch($client, $requests);
421
+
422
+ // Can be accessed by index.
423
+ echo $results[0]->getStatusCode();
424
+
425
+ // Can be accessed by request.
426
+ echo $results->getResult($requests[0])->getStatusCode();
427
+
428
+ // Retrieve all successful responses
429
+ foreach ($results->getSuccessful() as $response) {
430
+ echo $response->getStatusCode() . "\n";
431
+ }
432
+
433
+ // Retrieve all failures.
434
+ foreach ($results->getFailures() as $requestException) {
435
+ echo $requestException->getMessage() . "\n";
436
+ }
437
+
438
+ ``GuzzleHttp\Pool::batch()`` accepts an optional associative array of options
439
+ in the third argument that allows you to specify the 'before', 'complete',
440
+ 'error', and 'end' events as well as specify the maximum number of requests to
441
+ send concurrently using the 'pool_size' option key.
442
+
443
+ .. _request-options:
444
+
445
+ Request Options
446
+ ===============
447
+
448
+ You can customize requests created by a client using **request options**.
449
+ Request options control various aspects of a request including, headers,
450
+ query string parameters, timeout settings, the body of a request, and much
451
+ more.
452
+
453
+ All of the following examples use the following client:
454
+
455
+ .. code-block:: php
456
+
457
+ $client = new GuzzleHttp\Client(['base_url' => 'http://httpbin.org']);
458
+
459
+ headers
460
+ -------
461
+
462
+ :Summary: Associative array of headers to add to the request. Each key is the
463
+ name of a header, and each value is a string or array of strings
464
+ representing the header field values.
465
+ :Types: array
466
+ :Defaults: None
467
+
468
+ .. code-block:: php
469
+
470
+ // Set various headers on a request
471
+ $client->get('/get', [
472
+ 'headers' => [
473
+ 'User-Agent' => 'testing/1.0',
474
+ 'Accept' => 'application/json',
475
+ 'X-Foo' => ['Bar', 'Baz']
476
+ ]
477
+ ]);
478
+
479
+ body
480
+ ----
481
+
482
+ :Summary: The ``body`` option is used to control the body of an entity
483
+ enclosing request (e.g., PUT, POST, PATCH).
484
+ :Types:
485
+ - string
486
+ - ``fopen()`` resource
487
+ - ``GuzzleHttp\Stream\StreamInterface``
488
+ - ``GuzzleHttp\Post\PostBodyInterface``
489
+ :Default: None
490
+
491
+ This setting can be set to any of the following types:
492
+
493
+ - string
494
+
495
+ .. code-block:: php
496
+
497
+ // You can send requests that use a string as the message body.
498
+ $client->put('/put', ['body' => 'foo']);
499
+
500
+ - resource returned from ``fopen()``
501
+
502
+ .. code-block:: php
503
+
504
+ // You can send requests that use a stream resource as the body.
505
+ $resource = fopen('http://httpbin.org', 'r');
506
+ $client->put('/put', ['body' => $resource]);
507
+
508
+ - Array
509
+
510
+ Use an array to send POST style requests that use a
511
+ ``GuzzleHttp\Post\PostBodyInterface`` object as the body.
512
+
513
+ .. code-block:: php
514
+
515
+ // You can send requests that use a POST body containing fields & files.
516
+ $client->post('/post', [
517
+ 'body' => [
518
+ 'field' => 'abc',
519
+ 'other_field' => '123',
520
+ 'file_name' => fopen('/path/to/file', 'r')
521
+ ]
522
+ ]);
523
+
524
+ - ``GuzzleHttp\Stream\StreamInterface``
525
+
526
+ .. code-block:: php
527
+
528
+ // You can send requests that use a Guzzle stream object as the body
529
+ $stream = GuzzleHttp\Stream\Stream::factory('contents...');
530
+ $client->post('/post', ['body' => $stream]);
531
+
532
+ json
533
+ ----
534
+
535
+ :Summary: The ``json`` option is used to easily upload JSON encoded data as the
536
+ body of a request. A Content-Type header of ``application/json`` will be
537
+ added if no Content-Type header is already present on the message.
538
+ :Types:
539
+ Any PHP type that can be operated on by PHP's ``json_encode()`` function.
540
+ :Default: None
541
+
542
+ .. code-block:: php
543
+
544
+ $request = $client->createRequest('PUT', '/put', ['json' => ['foo' => 'bar']]);
545
+ echo $request->getHeader('Content-Type');
546
+ // application/json
547
+ echo $request->getBody();
548
+ // {"foo":"bar"}
549
+
550
+ .. note::
551
+
552
+ This request option does not support customizing the Content-Type header
553
+ or any of the options from PHP's `json_encode() <http://www.php.net/manual/en/function.json-encode.php>`_
554
+ function. If you need to customize these settings, then you must pass the
555
+ JSON encoded data into the request yourself using the ``body`` request
556
+ option and you must specify the correct Content-Type header using the
557
+ ``headers`` request option.
558
+
559
+ query
560
+ -----
561
+
562
+ :Summary: Associative array of query string values to add to the request.
563
+ :Types:
564
+ - array
565
+ - ``GuzzleHttp\Query``
566
+ :Default: None
567
+
568
+ .. code-block:: php
569
+
570
+ // Send a GET request to /get?foo=bar
571
+ $client->get('/get', ['query' => ['foo' => 'bar']]);
572
+
573
+ Query strings specified in the ``query`` option are combined with any query
574
+ string values that are parsed from the URL.
575
+
576
+ .. code-block:: php
577
+
578
+ // Send a GET request to /get?abc=123&foo=bar
579
+ $client->get('/get?abc=123', ['query' => ['foo' => 'bar']]);
580
+
581
+ auth
582
+ ----
583
+
584
+ :Summary: Pass an array of HTTP authentication parameters to use with the
585
+ request. The array must contain the username in index [0], the password in
586
+ index [1], and you can optionally provide a built-in authentication type in
587
+ index [2]. Pass ``null`` to disable authentication for a request.
588
+ :Types:
589
+ - array
590
+ - string
591
+ - null
592
+ :Default: None
593
+
594
+ The built-in authentication types are as follows:
595
+
596
+ basic
597
+ Use `basic HTTP authentication <http://www.ietf.org/rfc/rfc2069.txt>`_ in
598
+ the ``Authorization`` header (the default setting used if none is
599
+ specified).
600
+
601
+ .. code-block:: php
602
+
603
+ $client->get('/get', ['auth' => ['username', 'password']]);
604
+
605
+ digest
606
+ Use `digest authentication <http://www.ietf.org/rfc/rfc2069.txt>`_ (must be
607
+ supported by the HTTP handler).
608
+
609
+ .. code-block:: php
610
+
611
+ $client->get('/get', ['auth' => ['username', 'password', 'digest']]);
612
+
613
+ *This is currently only supported when using the cURL handler, but creating
614
+ a replacement that can be used with any HTTP handler is planned.*
615
+
616
+ .. important::
617
+
618
+ The authentication type (whether it's provided as a string or as the third
619
+ option in an array) is always converted to a lowercase string. Take this
620
+ into account when implementing custom authentication types and when
621
+ implementing custom message factories.
622
+
623
+ Custom Authentication Schemes
624
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
625
+
626
+ You can also provide a string representing a custom authentication type name.
627
+ When using a custom authentication type string, you will need to implement
628
+ the authentication method in an event listener that checks the ``auth`` request
629
+ option of a request before it is sent. Authentication listeners that require
630
+ a request is not modified after they are signed should have a very low priority
631
+ to ensure that they are fired last or near last in the event chain.
632
+
633
+ .. code-block:: php
634
+
635
+ use GuzzleHttp\Event\BeforeEvent;
636
+ use GuzzleHttp\Event\RequestEvents;
637
+
638
+ /**
639
+ * Custom authentication listener that handles the "foo" auth type.
640
+ *
641
+ * Listens to the "before" event of a request and only modifies the request
642
+ * when the "auth" config setting of the request is "foo".
643
+ */
644
+ class FooAuth implements GuzzleHttp\Event\SubscriberInterface
645
+ {
646
+ private $password;
647
+
648
+ public function __construct($password)
649
+ {
650
+ $this->password = $password;
651
+ }
652
+
653
+ public function getEvents()
654
+ {
655
+ return ['before' => ['sign', RequestEvents::SIGN_REQUEST]];
656
+ }
657
+
658
+ public function sign(BeforeEvent $e)
659
+ {
660
+ if ($e->getRequest()->getConfig()['auth'] == 'foo') {
661
+ $e->getRequest()->setHeader('X-Foo', 'Foo ' . $this->password);
662
+ }
663
+ }
664
+ }
665
+
666
+ $client->getEmitter()->attach(new FooAuth('password'));
667
+ $client->get('/', ['auth' => 'foo']);
668
+
669
+ Adapter Specific Authentication Schemes
670
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
671
+
672
+ If you need to use authentication methods provided by cURL (e.g., NTLM, GSS,
673
+ etc.), then you need to specify a curl handler option in the ``options``
674
+ request option array. See :ref:`config-option` for more information.
675
+
676
+ .. _cookies-option:
677
+
678
+ cookies
679
+ -------
680
+
681
+ :Summary: Specifies whether or not cookies are used in a request or what cookie
682
+ jar to use or what cookies to send.
683
+ :Types:
684
+ - bool
685
+ - array
686
+ - ``GuzzleHttp\Cookie\CookieJarInterface``
687
+ :Default: None
688
+
689
+ Set to ``true`` to use a shared cookie session associated with the client.
690
+
691
+ .. code-block:: php
692
+
693
+ // Enable cookies using the shared cookie jar of the client.
694
+ $client->get('/get', ['cookies' => true]);
695
+
696
+ Pass an associative array containing cookies to send in the request and start a
697
+ new cookie session.
698
+
699
+ .. code-block:: php
700
+
701
+ // Enable cookies and send specific cookies
702
+ $client->get('/get', ['cookies' => ['foo' => 'bar']]);
703
+
704
+ Set to a ``GuzzleHttp\Cookie\CookieJarInterface`` object to use an existing
705
+ cookie jar.
706
+
707
+ .. code-block:: php
708
+
709
+ $jar = new GuzzleHttp\Cookie\CookieJar();
710
+ $client->get('/get', ['cookies' => $jar]);
711
+
712
+ .. _allow_redirects-option:
713
+
714
+ allow_redirects
715
+ ---------------
716
+
717
+ :Summary: Describes the redirect behavior of a request
718
+ :Types:
719
+ - bool
720
+ - array
721
+ :Default:
722
+ ::
723
+
724
+ [
725
+ 'max' => 5,
726
+ 'strict' => false,
727
+ 'referer' => true,
728
+ 'protocols' => ['http', 'https']
729
+ ]
730
+
731
+ Set to ``false`` to disable redirects.
732
+
733
+ .. code-block:: php
734
+
735
+ $res = $client->get('/redirect/3', ['allow_redirects' => false]);
736
+ echo $res->getStatusCode();
737
+ // 302
738
+
739
+ Set to ``true`` (the default setting) to enable normal redirects with a maximum
740
+ number of 5 redirects.
741
+
742
+ .. code-block:: php
743
+
744
+ $res = $client->get('/redirect/3');
745
+ echo $res->getStatusCode();
746
+ // 200
747
+
748
+ Pass an associative array containing the 'max' key to specify the maximum
749
+ number of redirects, provide a 'strict' key value to specify whether or not to
750
+ use strict RFC compliant redirects (meaning redirect POST requests with POST
751
+ requests vs. doing what most browsers do which is redirect POST requests with
752
+ GET requests), provide a 'referer' key to specify whether or not the "Referer"
753
+ header should be added when redirecting, and provide a 'protocols' array that
754
+ specifies which protocols are supported for redirects (defaults to
755
+ ``['http', 'https']``).
756
+
757
+ .. code-block:: php
758
+
759
+ $res = $client->get('/redirect/3', [
760
+ 'allow_redirects' => [
761
+ 'max' => 10, // allow at most 10 redirects.
762
+ 'strict' => true, // use "strict" RFC compliant redirects.
763
+ 'referer' => true, // add a Referer header
764
+ 'protocols' => ['https'] // only allow https URLs
765
+ ]
766
+ ]);
767
+ echo $res->getStatusCode();
768
+ // 200
769
+
770
+ decode_content
771
+ --------------
772
+
773
+ :Summary: Specify whether or not ``Content-Encoding`` responses (gzip,
774
+ deflate, etc.) are automatically decoded.
775
+ :Types:
776
+ - string
777
+ - bool
778
+ :Default: ``true``
779
+
780
+ This option can be used to control how content-encoded response bodies are
781
+ handled. By default, ``decode_content`` is set to true, meaning any gzipped
782
+ or deflated response will be decoded by Guzzle.
783
+
784
+ When set to ``false``, the body of a response is never decoded, meaning the
785
+ bytes pass through the handler unchanged.
786
+
787
+ .. code-block:: php
788
+
789
+ // Request gzipped data, but do not decode it while downloading
790
+ $client->get('/foo.js', [
791
+ 'headers' => ['Accept-Encoding' => 'gzip'],
792
+ 'decode_content' => false
793
+ ]);
794
+
795
+ When set to a string, the bytes of a response are decoded and the string value
796
+ provided to the ``decode_content`` option is passed as the ``Accept-Encoding``
797
+ header of the request.
798
+
799
+ .. code-block:: php
800
+
801
+ // Pass "gzip" as the Accept-Encoding header.
802
+ $client->get('/foo.js', ['decode_content' => 'gzip']);
803
+
804
+ .. _save_to-option:
805
+
806
+ save_to
807
+ -------
808
+
809
+ :Summary: Specify where the body of a response will be saved.
810
+ :Types:
811
+ - string
812
+ - ``fopen()`` resource
813
+ - ``GuzzleHttp\Stream\StreamInterface``
814
+ :Default: PHP temp stream
815
+
816
+ Pass a string to specify the path to a file that will store the contents of the
817
+ response body:
818
+
819
+ .. code-block:: php
820
+
821
+ $client->get('/stream/20', ['save_to' => '/path/to/file']);
822
+
823
+ Pass a resource returned from ``fopen()`` to write the response to a PHP stream:
824
+
825
+ .. code-block:: php
826
+
827
+ $resource = fopen('/path/to/file', 'w');
828
+ $client->get('/stream/20', ['save_to' => $resource]);
829
+
830
+ Pass a ``GuzzleHttp\Stream\StreamInterface`` object to stream the response body
831
+ to an open Guzzle stream:
832
+
833
+ .. code-block:: php
834
+
835
+ $resource = fopen('/path/to/file', 'w');
836
+ $stream = GuzzleHttp\Stream\Stream::factory($resource);
837
+ $client->get('/stream/20', ['save_to' => $stream]);
838
+
839
+ .. _events-option:
840
+
841
+ events
842
+ ------
843
+
844
+ :Summary: An associative array mapping event names to a callable. Or an
845
+ associative array containing the 'fn' key that maps to a callable, an
846
+ optional 'priority' key used to specify the event priority, and an optional
847
+ 'once' key used to specify if the event should remove itself the first time
848
+ it is triggered.
849
+ :Types: array
850
+ :Default: None
851
+
852
+ .. code-block:: php
853
+
854
+ use GuzzleHttp\Event\BeforeEvent;
855
+ use GuzzleHttp\Event\HeadersEvent;
856
+ use GuzzleHttp\Event\CompleteEvent;
857
+ use GuzzleHttp\Event\ErrorEvent;
858
+
859
+ $client->get('/', [
860
+ 'events' => [
861
+ 'before' => function (BeforeEvent $e) { echo 'Before'; },
862
+ 'complete' => function (CompleteEvent $e) { echo 'Complete'; },
863
+ 'error' => function (ErrorEvent $e) { echo 'Error'; },
864
+ ]
865
+ ]);
866
+
867
+ Here's an example of using the associative array format for control over the
868
+ priority and whether or not an event should be triggered more than once.
869
+
870
+ .. code-block:: php
871
+
872
+ $client->get('/', [
873
+ 'events' => [
874
+ 'before' => [
875
+ 'fn' => function (BeforeEvent $e) { echo 'Before'; },
876
+ 'priority' => 100,
877
+ 'once' => true
878
+ ]
879
+ ]
880
+ ]);
881
+
882
+ .. _subscribers-option:
883
+
884
+ subscribers
885
+ -----------
886
+
887
+ :Summary: Array of event subscribers to add to the request. Each value in the
888
+ array must be an instance of ``GuzzleHttp\Event\SubscriberInterface``.
889
+ :Types: array
890
+ :Default: None
891
+
892
+ .. code-block:: php
893
+
894
+ use GuzzleHttp\Subscriber\History;
895
+ use GuzzleHttp\Subscriber\Mock;
896
+ use GuzzleHttp\Message\Response;
897
+
898
+ $history = new History();
899
+ $mock = new Mock([new Response(200)]);
900
+ $client->get('/', ['subscribers' => [$history, $mock]]);
901
+
902
+ echo $history;
903
+ // Outputs the request and response history
904
+
905
+ .. _exceptions-option:
906
+
907
+ exceptions
908
+ ----------
909
+
910
+ :Summary: Set to ``false`` to disable throwing exceptions on an HTTP protocol
911
+ errors (i.e., 4xx and 5xx responses). Exceptions are thrown by default when
912
+ HTTP protocol errors are encountered.
913
+ :Types: bool
914
+ :Default: ``true``
915
+
916
+ .. code-block:: php
917
+
918
+ $client->get('/status/500');
919
+ // Throws a GuzzleHttp\Exception\ServerException
920
+
921
+ $res = $client->get('/status/500', ['exceptions' => false]);
922
+ echo $res->getStatusCode();
923
+ // 500
924
+
925
+ .. _timeout-option:
926
+
927
+ timeout
928
+ -------
929
+
930
+ :Summary: Float describing the timeout of the request in seconds. Use ``0``
931
+ to wait indefinitely (the default behavior).
932
+ :Types: float
933
+ :Default: ``0``
934
+
935
+ .. code-block:: php
936
+
937
+ // Timeout if a server does not return a response in 3.14 seconds.
938
+ $client->get('/delay/5', ['timeout' => 3.14]);
939
+ // PHP Fatal error: Uncaught exception 'GuzzleHttp\Exception\RequestException'
940
+
941
+ .. _connect_timeout-option:
942
+
943
+ connect_timeout
944
+ ---------------
945
+
946
+ :Summary: Float describing the number of seconds to wait while trying to connect
947
+ to a server. Use ``0`` to wait indefinitely (the default behavior).
948
+ :Types: float
949
+ :Default: ``0``
950
+
951
+ .. code-block:: php
952
+
953
+ // Timeout if the client fails to connect to the server in 3.14 seconds.
954
+ $client->get('/delay/5', ['connect_timeout' => 3.14]);
955
+
956
+ .. note::
957
+
958
+ This setting must be supported by the HTTP handler used to send a request.
959
+ ``connect_timeout`` is currently only supported by the built-in cURL
960
+ handler.
961
+
962
+ .. _verify-option:
963
+
964
+ verify
965
+ ------
966
+
967
+ :Summary: Describes the SSL certificate verification behavior of a request.
968
+
969
+ - Set to ``true`` to enable SSL certificate verification and use the default
970
+ CA bundle provided by operating system.
971
+ - Set to ``false`` to disable certificate verification (this is insecure!).
972
+ - Set to a string to provide the path to a CA bundle to enable verification
973
+ using a custom certificate.
974
+ :Types:
975
+ - bool
976
+ - string
977
+ :Default: ``true``
978
+
979
+ .. code-block:: php
980
+
981
+ // Use the system's CA bundle (this is the default setting)
982
+ $client->get('/', ['verify' => true]);
983
+
984
+ // Use a custom SSL certificate on disk.
985
+ $client->get('/', ['verify' => '/path/to/cert.pem']);
986
+
987
+ // Disable validation entirely (don't do this!).
988
+ $client->get('/', ['verify' => false]);
989
+
990
+ Not all system's have a known CA bundle on disk. For example, Windows and
991
+ OS X do not have a single common location for CA bundles. When setting
992
+ "verify" to ``true``, Guzzle will do its best to find the most appropriate
993
+ CA bundle on your system. When using cURL or the PHP stream wrapper on PHP
994
+ versions >= 5.6, this happens by default. When using the PHP stream
995
+ wrapper on versions < 5.6, Guzzle tries to find your CA bundle in the
996
+ following order:
997
+
998
+ 1. Check if ``openssl.cafile`` is set in your php.ini file.
999
+ 2. Check if ``curl.cainfo`` is set in your php.ini file.
1000
+ 3. Check if ``/etc/pki/tls/certs/ca-bundle.crt`` exists (Red Hat, CentOS,
1001
+ Fedora; provided by the ca-certificates package)
1002
+ 4. Check if ``/etc/ssl/certs/ca-certificates.crt`` exists (Ubuntu, Debian;
1003
+ provided by the ca-certificates package)
1004
+ 5. Check if ``/usr/local/share/certs/ca-root-nss.crt`` exists (FreeBSD;
1005
+ provided by the ca_root_nss package)
1006
+ 6. Check if ``/usr/local/etc/openssl/cert.pem`` (OS X; provided by homebrew)
1007
+ 7. Check if ``C:\windows\system32\curl-ca-bundle.crt`` exists (Windows)
1008
+ 8. Check if ``C:\windows\curl-ca-bundle.crt`` exists (Windows)
1009
+
1010
+ The result of this lookup is cached in memory so that subsequent calls
1011
+ in the same process will return very quickly. However, when sending only
1012
+ a single request per-process in something like Apache, you should consider
1013
+ setting the ``openssl.cafile`` environment variable to the path on disk
1014
+ to the file so that this entire process is skipped.
1015
+
1016
+ If you do not need a specific certificate bundle, then Mozilla provides a
1017
+ commonly used CA bundle which can be downloaded
1018
+ `here <https://raw.githubusercontent.com/bagder/ca-bundle/master/ca-bundle.crt>`_
1019
+ (provided by the maintainer of cURL). Once you have a CA bundle available on
1020
+ disk, you can set the "openssl.cafile" PHP ini setting to point to the path to
1021
+ the file, allowing you to omit the "verify" request option. Much more detail on
1022
+ SSL certificates can be found on the
1023
+ `cURL website <http://curl.haxx.se/docs/sslcerts.html>`_.
1024
+
1025
+ .. _cert-option:
1026
+
1027
+ cert
1028
+ ----
1029
+
1030
+ :Summary: Set to a string to specify the path to a file containing a PEM
1031
+ formatted client side certificate. If a password is required, then set to
1032
+ an array containing the path to the PEM file in the first array element
1033
+ followed by the password required for the certificate in the second array
1034
+ element.
1035
+ :Types:
1036
+ - string
1037
+ - array
1038
+ :Default: None
1039
+
1040
+ .. code-block:: php
1041
+
1042
+ $client->get('/', ['cert' => ['/path/server.pem', 'password']]);
1043
+
1044
+ .. _ssl_key-option:
1045
+
1046
+ ssl_key
1047
+ -------
1048
+
1049
+ :Summary: Specify the path to a file containing a private SSL key in PEM
1050
+ format. If a password is required, then set to an array containing the path
1051
+ to the SSL key in the first array element followed by the password required
1052
+ for the certificate in the second element.
1053
+ :Types:
1054
+ - string
1055
+ - array
1056
+ :Default: None
1057
+
1058
+ .. note::
1059
+
1060
+ ``ssl_key`` is implemented by HTTP handlers. This is currently only
1061
+ supported by the cURL handler, but might be supported by other third-part
1062
+ handlers.
1063
+
1064
+ .. _proxy-option:
1065
+
1066
+ proxy
1067
+ -----
1068
+
1069
+ :Summary: Pass a string to specify an HTTP proxy, or an array to specify
1070
+ different proxies for different protocols.
1071
+ :Types:
1072
+ - string
1073
+ - array
1074
+ :Default: None
1075
+
1076
+ Pass a string to specify a proxy for all protocols.
1077
+
1078
+ .. code-block:: php
1079
+
1080
+ $client->get('/', ['proxy' => 'tcp://localhost:8125']);
1081
+
1082
+ Pass an associative array to specify HTTP proxies for specific URI schemes
1083
+ (i.e., "http", "https").
1084
+
1085
+ .. code-block:: php
1086
+
1087
+ $client->get('/', [
1088
+ 'proxy' => [
1089
+ 'http' => 'tcp://localhost:8125', // Use this proxy with "http"
1090
+ 'https' => 'tcp://localhost:9124' // Use this proxy with "https"
1091
+ ]
1092
+ ]);
1093
+
1094
+ .. note::
1095
+
1096
+ You can provide proxy URLs that contain a scheme, username, and password.
1097
+ For example, ``"http://username:password@192.168.16.1:10"``.
1098
+
1099
+ .. _debug-option:
1100
+
1101
+ debug
1102
+ -----
1103
+
1104
+ :Summary: Set to ``true`` or set to a PHP stream returned by ``fopen()`` to
1105
+ enable debug output with the handler used to send a request. For example,
1106
+ when using cURL to transfer requests, cURL's verbose of ``CURLOPT_VERBOSE``
1107
+ will be emitted. When using the PHP stream wrapper, stream wrapper
1108
+ notifications will be emitted. If set to true, the output is written to
1109
+ PHP's STDOUT. If a PHP stream is provided, output is written to the stream.
1110
+ :Types:
1111
+ - bool
1112
+ - ``fopen()`` resource
1113
+ :Default: None
1114
+
1115
+ .. code-block:: php
1116
+
1117
+ $client->get('/get', ['debug' => true]);
1118
+
1119
+ Running the above example would output something like the following:
1120
+
1121
+ ::
1122
+
1123
+ * About to connect() to httpbin.org port 80 (#0)
1124
+ * Trying 107.21.213.98... * Connected to httpbin.org (107.21.213.98) port 80 (#0)
1125
+ > GET /get HTTP/1.1
1126
+ Host: httpbin.org
1127
+ User-Agent: Guzzle/4.0 curl/7.21.4 PHP/5.5.7
1128
+
1129
+ < HTTP/1.1 200 OK
1130
+ < Access-Control-Allow-Origin: *
1131
+ < Content-Type: application/json
1132
+ < Date: Sun, 16 Feb 2014 06:50:09 GMT
1133
+ < Server: gunicorn/0.17.4
1134
+ < Content-Length: 335
1135
+ < Connection: keep-alive
1136
+ <
1137
+ * Connection #0 to host httpbin.org left intact
1138
+
1139
+ .. _stream-option:
1140
+
1141
+ stream
1142
+ ------
1143
+
1144
+ :Summary: Set to ``true`` to stream a response rather than download it all
1145
+ up-front.
1146
+ :Types: bool
1147
+ :Default: ``false``
1148
+
1149
+ .. code-block:: php
1150
+
1151
+ $response = $client->get('/stream/20', ['stream' => true]);
1152
+ // Read bytes off of the stream until the end of the stream is reached
1153
+ $body = $response->getBody();
1154
+ while (!$body->eof()) {
1155
+ echo $body->read(1024);
1156
+ }
1157
+
1158
+ .. note::
1159
+
1160
+ Streaming response support must be implemented by the HTTP handler used by
1161
+ a client. This option might not be supported by every HTTP handler, but the
1162
+ interface of the response object remains the same regardless of whether or
1163
+ not it is supported by the handler.
1164
+
1165
+ .. _expect-option:
1166
+
1167
+ expect
1168
+ ------
1169
+
1170
+ :Summary: Controls the behavior of the "Expect: 100-Continue" header.
1171
+ :Types:
1172
+ - bool
1173
+ - integer
1174
+ :Default: ``1048576``
1175
+
1176
+ Set to ``true`` to enable the "Expect: 100-Continue" header for all requests
1177
+ that sends a body. Set to ``false`` to disable the "Expect: 100-Continue"
1178
+ header for all requests. Set to a number so that the size of the payload must
1179
+ be greater than the number in order to send the Expect header. Setting to a
1180
+ number will send the Expect header for all requests in which the size of the
1181
+ payload cannot be determined or where the body is not rewindable.
1182
+
1183
+ By default, Guzzle will add the "Expect: 100-Continue" header when the size of
1184
+ the body of a request is greater than 1 MB and a request is using HTTP/1.1.
1185
+
1186
+ .. note::
1187
+
1188
+ This option only takes effect when using HTTP/1.1. The HTTP/1.0 and
1189
+ HTTP/2.0 protocols do not support the "Expect: 100-Continue" header.
1190
+ Support for handling the "Expect: 100-Continue" workflow must be
1191
+ implemented by Guzzle HTTP handlers used by a client.
1192
+
1193
+ .. _version-option:
1194
+
1195
+ version
1196
+ -------
1197
+
1198
+ :Summary: Protocol version to use with the request.
1199
+ :Types: string, float
1200
+ :Default: ``1.1``
1201
+
1202
+ .. code-block:: php
1203
+
1204
+ // Force HTTP/1.0
1205
+ $request = $client->createRequest('GET', '/get', ['version' => 1.0]);
1206
+ echo $request->getProtocolVersion();
1207
+ // 1.0
1208
+
1209
+ .. _config-option:
1210
+
1211
+ config
1212
+ ------
1213
+
1214
+ :Summary: Associative array of config options that are forwarded to a request's
1215
+ configuration collection. These values are used as configuration options
1216
+ that can be consumed by plugins and handlers.
1217
+ :Types: array
1218
+ :Default: None
1219
+
1220
+ .. code-block:: php
1221
+
1222
+ $request = $client->createRequest('GET', '/get', ['config' => ['foo' => 'bar']]);
1223
+ echo $request->getConfig('foo');
1224
+ // 'bar'
1225
+
1226
+ Some HTTP handlers allow you to specify custom handler-specific settings. For
1227
+ example, you can pass custom cURL options to requests by passing an associative
1228
+ array in the ``config`` request option under the ``curl`` key.
1229
+
1230
+ .. code-block:: php
1231
+
1232
+ // Use custom cURL options with the request. This example uses NTLM auth
1233
+ // to authenticate with a server.
1234
+ $client->get('/', [
1235
+ 'config' => [
1236
+ 'curl' => [
1237
+ CURLOPT_HTTPAUTH => CURLAUTH_NTLM,
1238
+ CURLOPT_USERPWD => 'username:password'
1239
+ ]
1240
+ ]
1241
+ ]);
1242
+
1243
+ future
1244
+ ------
1245
+
1246
+ :Summary: Specifies whether or not a response SHOULD be an instance of a
1247
+ ``GuzzleHttp\Message\FutureResponse`` object.
1248
+ :Types:
1249
+ - bool
1250
+ - string
1251
+ :Default: ``false``
1252
+
1253
+ By default, Guzzle requests should be synchronous. You can create asynchronous
1254
+ future responses by passing the ``future`` request option as ``true``. The
1255
+ response will only be executed when it is used like a normal response, the
1256
+ ``wait()`` method of the response is called, or the corresponding handler that
1257
+ created the response is destructing and there are futures that have not been
1258
+ resolved.
1259
+
1260
+ .. important::
1261
+
1262
+ This option only has an effect if your handler can create and return future
1263
+ responses. However, even if a response is completed synchronously, Guzzle
1264
+ will ensure that a FutureResponse object is returned for API consistency.
1265
+
1266
+ .. code-block:: php
1267
+
1268
+ $response = $client->get('/foo', ['future' => true])
1269
+ ->then(function ($response) {
1270
+ echo 'I got a response! ' . $response;
1271
+ });
1272
+
1273
+ Event Subscribers
1274
+ =================
1275
+
1276
+ Requests emit lifecycle events when they are transferred. A client object has a
1277
+ ``GuzzleHttp\Common\EventEmitter`` object that can be used to add event
1278
+ *listeners* and event *subscribers* to all requests created by the client.
1279
+
1280
+ .. important::
1281
+
1282
+ **Every** event listener or subscriber added to a client will be added to
1283
+ every request created by the client.
1284
+
1285
+ .. code-block:: php
1286
+
1287
+ use GuzzleHttp\Client;
1288
+ use GuzzleHttp\Event\BeforeEvent;
1289
+
1290
+ $client = new Client();
1291
+
1292
+ // Add a listener that will echo out requests before they are sent
1293
+ $client->getEmitter()->on('before', function (BeforeEvent $e) {
1294
+ echo 'About to send request: ' . $e->getRequest();
1295
+ });
1296
+
1297
+ $client->get('http://httpbin.org/get');
1298
+ // Outputs the request as a string because of the event
1299
+
1300
+ See :doc:`events` for more information on the event system used in Guzzle.
1301
+
1302
+ Environment Variables
1303
+ =====================
1304
+
1305
+ Guzzle exposes a few environment variables that can be used to customize the
1306
+ behavior of the library.
1307
+
1308
+ ``GUZZLE_CURL_SELECT_TIMEOUT``
1309
+ Controls the duration in seconds that a curl_multi_* handler will use when
1310
+ selecting on curl handles using ``curl_multi_select()``. Some systems
1311
+ have issues with PHP's implementation of ``curl_multi_select()`` where
1312
+ calling this function always results in waiting for the maximum duration of
1313
+ the timeout.
1314
+ ``HTTP_PROXY``
1315
+ Defines the proxy to use when sending requests using the "http" protocol.
1316
+ ``HTTPS_PROXY``
1317
+ Defines the proxy to use when sending requests using the "https" protocol.
1318
+
1319
+ Relevant ini Settings
1320
+ ---------------------
1321
+
1322
+ Guzzle can utilize PHP ini settings when configuring clients.
1323
+
1324
+ ``openssl.cafile``
1325
+ Specifies the path on disk to a CA file in PEM format to use when sending
1326
+ requests over "https". See: https://wiki.php.net/rfc/tls-peer-verification#phpini_defaults
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/docs/conf.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys, os
2
+ from sphinx.highlighting import lexers
3
+ from pygments.lexers.web import PhpLexer
4
+
5
+
6
+ lexers['php'] = PhpLexer(startinline=True, linenos=1)
7
+ lexers['php-annotations'] = PhpLexer(startinline=True, linenos=1)
8
+ primary_domain = 'php'
9
+
10
+ extensions = []
11
+ templates_path = ['_templates']
12
+ source_suffix = '.rst'
13
+ master_doc = 'index'
14
+ project = u'Guzzle'
15
+ copyright = u'2014, Michael Dowling'
16
+ version = '5.0.0'
17
+ html_title = "Guzzle Documentation"
18
+ html_short_title = "Guzzle"
19
+
20
+ exclude_patterns = ['_build']
21
+ html_static_path = ['_static']
22
+
23
+ on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
24
+
25
+ if not on_rtd: # only import and set the theme if we're building docs locally
26
+ import sphinx_rtd_theme
27
+ html_theme = 'sphinx_rtd_theme'
28
+ html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/docs/events.rst ADDED
@@ -0,0 +1,516 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ============
2
+ Event System
3
+ ============
4
+
5
+ Guzzle uses an event emitter to allow you to easily extend the behavior of a
6
+ request, change the response associated with a request, and implement custom
7
+ error handling. All events in Guzzle are managed and emitted by an
8
+ **event emitter**.
9
+
10
+ Event Emitters
11
+ ==============
12
+
13
+ Clients, requests, and any other class that implements the
14
+ ``GuzzleHttp\Event\HasEmitterInterface`` interface have a
15
+ ``GuzzleHttp\Event\Emitter`` object. You can add event *listeners* and
16
+ event *subscribers* to an event *emitter*.
17
+
18
+ emitter
19
+ An object that implements ``GuzzleHttp\Event\EmitterInterface``. This
20
+ object emits named events to event listeners. You may register event
21
+ listeners on subscribers on an emitter.
22
+
23
+ event listeners
24
+ Callable functions that are registered on an event emitter for specific
25
+ events. Event listeners are registered on an emitter with a *priority*
26
+ setting. If no priority is provided, ``0`` is used by default.
27
+
28
+ event subscribers
29
+ Classes that tell an event emitter what methods to listen to and what
30
+ functions on the class to invoke when the event is triggered. Event
31
+ subscribers subscribe event listeners to an event emitter. They should be
32
+ used when creating more complex event based logic in applications (i.e.,
33
+ cookie handling is implemented using an event subscriber because it's
34
+ easier to share a subscriber than an anonymous function and because
35
+ handling cookies is a complex process).
36
+
37
+ priority
38
+ Describes the order in which event listeners are invoked when an event is
39
+ emitted. The higher a priority value, the earlier the event listener will
40
+ be invoked (a higher priority means the listener is more important). If
41
+ no priority is provided, the priority is assumed to be ``0``.
42
+
43
+ When specifying an event priority, you can pass ``"first"`` or ``"last"`` to
44
+ dynamically specify the priority based on the current event priorities
45
+ associated with the given event name in the emitter. Use ``"first"`` to set
46
+ the priority to the current highest priority plus one. Use ``"last"`` to
47
+ set the priority to the current lowest event priority minus one. It is
48
+ important to remember that these dynamic priorities are calculated only at
49
+ the point of insertion into the emitter and they are not rearranged after
50
+ subsequent listeners are added to an emitter.
51
+
52
+ propagation
53
+ Describes whether or not other event listeners are triggered. Event
54
+ emitters will trigger every event listener registered to a specific event
55
+ in priority order until all of the listeners have been triggered **or**
56
+ until the propagation of an event is stopped.
57
+
58
+ Getting an EventEmitter
59
+ -----------------------
60
+
61
+ You can get the event emitter of ``GuzzleHttp\Event\HasEmitterInterface``
62
+ object using the the ``getEmitter()`` method. Here's an example of getting a
63
+ client object's event emitter.
64
+
65
+ .. code-block:: php
66
+
67
+ $client = new GuzzleHttp\Client();
68
+ $emitter = $client->getEmitter();
69
+
70
+ .. note::
71
+
72
+ You'll notice that the event emitter used in Guzzle is very similar to the
73
+ `Symfony2 EventDispatcher component <https://github.com/symfony/symfony/tree/master/src/Symfony/Component/EventDispatcher>`_.
74
+ This is because the Guzzle event system is based on the Symfony2 event
75
+ system with several changes. Guzzle uses its own event emitter to improve
76
+ performance, isolate Guzzle from changes to the Symfony, and provide a few
77
+ improvements that make it easier to use for an HTTP client (e.g., the
78
+ addition of the ``once()`` method).
79
+
80
+ Adding Event Listeners
81
+ ----------------------
82
+
83
+ After you have the emitter, you can register event listeners that listen to
84
+ specific events using the ``on()`` method. When registering an event listener,
85
+ you must tell the emitter what event to listen to (e.g., "before", "after",
86
+ "progress", "complete", "error", etc.), what callable to invoke when the
87
+ event is triggered, and optionally provide a priority.
88
+
89
+ .. code-block:: php
90
+
91
+ use GuzzleHttp\Event\BeforeEvent;
92
+
93
+ $emitter->on('before', function (BeforeEvent $event) {
94
+ echo $event->getRequest();
95
+ });
96
+
97
+ When a listener is triggered, it is passed an event that implements the
98
+ ``GuzzleHttp\Event\EventInterface`` interface, the name of the event, and the
99
+ event emitter itself. The above example could more verbosely be written as
100
+ follows:
101
+
102
+ .. code-block:: php
103
+
104
+ use GuzzleHttp\Event\BeforeEvent;
105
+
106
+ $emitter->on('before', function (BeforeEvent $event, $name) {
107
+ echo $event->getRequest();
108
+ });
109
+
110
+ You can add an event listener that automatically removes itself after it is
111
+ triggered using the ``once()`` method of an event emitter.
112
+
113
+ .. code-block:: php
114
+
115
+ $client = new GuzzleHttp\Client();
116
+ $client->getEmitter()->once('before', function () {
117
+ echo 'This will only happen once... per request!';
118
+ });
119
+
120
+ Event Propagation
121
+ -----------------
122
+
123
+ Event listeners can prevent other event listeners from being triggered by
124
+ stopping an event's propagation.
125
+
126
+ Stopping event propagation can be useful, for example, if an event listener has
127
+ changed the state of the subject to such an extent that allowing subsequent
128
+ event listeners to be triggered could place the subject in an inconsistent
129
+ state. This technique is used in Guzzle extensively when intercepting error
130
+ events with responses.
131
+
132
+ You can stop the propagation of an event using the ``stopPropagation()`` method
133
+ of a ``GuzzleHttp\Event\EventInterface`` object:
134
+
135
+ .. code-block:: php
136
+
137
+ use GuzzleHttp\Event\ErrorEvent;
138
+
139
+ $emitter->on('error', function (ErrorEvent $event) {
140
+ $event->stopPropagation();
141
+ });
142
+
143
+ After stopping the propagation of an event, any subsequent event listeners that
144
+ have not yet been triggered will not be triggered. You can check to see if the
145
+ propagation of an event was stopped using the ``isPropagationStopped()`` method
146
+ of the event.
147
+
148
+ .. code-block:: php
149
+
150
+ $client = new GuzzleHttp\Client();
151
+ $emitter = $client->getEmitter();
152
+ // Note: assume that the $errorEvent was created
153
+ if ($emitter->emit('error', $errorEvent)->isPropagationStopped()) {
154
+ echo 'It was stopped!';
155
+ }
156
+
157
+ .. hint::
158
+
159
+ When emitting events, the event that was emitted is returned from the
160
+ emitter. This allows you to easily chain calls as shown in the above
161
+ example.
162
+
163
+ Event Subscribers
164
+ -----------------
165
+
166
+ Event subscribers are classes that implement the
167
+ ``GuzzleHttp\Event\SubscriberInterface`` object. They are used to register
168
+ one or more event listeners to methods of the class. Event subscribers tell
169
+ event emitters exactly which events to listen to and what method to invoke on
170
+ the class when the event is triggered by called the ``getEvents()`` method of
171
+ a subscriber.
172
+
173
+ The following example registers event listeners to the ``before`` and
174
+ ``complete`` event of a request. When the ``before`` event is emitted, the
175
+ ``onBefore`` instance method of the subscriber is invoked. When the
176
+ ``complete`` event is emitted, the ``onComplete`` event of the subscriber is
177
+ invoked. Each array value in the ``getEvents()`` return value MUST
178
+ contain the name of the method to invoke and can optionally contain the
179
+ priority of the listener (as shown in the ``before`` listener in the example).
180
+
181
+ .. code-block:: php
182
+
183
+ use GuzzleHttp\Event\EmitterInterface;
184
+ use GuzzleHttp\Event\SubscriberInterface;
185
+ use GuzzleHttp\Event\BeforeEvent;
186
+ use GuzzleHttp\Event\CompleteEvent;
187
+
188
+ class SimpleSubscriber implements SubscriberInterface
189
+ {
190
+ public function getEvents()
191
+ {
192
+ return [
193
+ // Provide name and optional priority
194
+ 'before' => ['onBefore', 100],
195
+ 'complete' => ['onComplete'],
196
+ // You can pass a list of listeners with different priorities
197
+ 'error' => [['beforeError', 'first'], ['afterError', 'last']]
198
+ ];
199
+ }
200
+
201
+ public function onBefore(BeforeEvent $event, $name)
202
+ {
203
+ echo 'Before!';
204
+ }
205
+
206
+ public function onComplete(CompleteEvent $event, $name)
207
+ {
208
+ echo 'Complete!';
209
+ }
210
+ }
211
+
212
+ To register the listeners the subscriber needs to be attached to the emitter:
213
+
214
+ .. code-block:: php
215
+
216
+ $client = new GuzzleHttp\Client();
217
+ $emitter = $client->getEmitter();
218
+ $subscriber = new SimpleSubscriber();
219
+ $emitter->attach($subscriber);
220
+
221
+ //to remove the listeners
222
+ $emitter->detach($subscriber);
223
+
224
+ .. note::
225
+
226
+ You can specify event priorities using integers or ``"first"`` and
227
+ ``"last"`` to dynamically determine the priority.
228
+
229
+ Event Priorities
230
+ ================
231
+
232
+ When adding event listeners or subscribers, you can provide an optional event
233
+ priority. This priority is used to determine how early or late a listener is
234
+ triggered. Specifying the correct priority is an important aspect of ensuring
235
+ a listener behaves as expected. For example, if you wanted to ensure that
236
+ cookies associated with a redirect were added to a cookie jar, you'd need to
237
+ make sure that the listener that collects the cookies is triggered before the
238
+ listener that performs the redirect.
239
+
240
+ In order to help make the process of determining the correct event priority of
241
+ a listener easier, Guzzle provides several pre-determined named event
242
+ priorities. These priorities are exposed as constants on the
243
+ ``GuzzleHttp\Event\RequestEvents`` object.
244
+
245
+ last
246
+ Use ``"last"`` as an event priority to set the priority to the current
247
+ lowest event priority minus one.
248
+
249
+ first
250
+ Use ``"first"`` as an event priority to set the priority to the current
251
+ highest priority plus one.
252
+
253
+ ``GuzzleHttp\Event\RequestEvents::EARLY``
254
+ Used when you want a listener to be triggered as early as possible in the
255
+ event chain.
256
+
257
+ ``GuzzleHttp\Event\RequestEvents::LATE``
258
+ Used when you want a listener to be to be triggered as late as possible in
259
+ the event chain.
260
+
261
+ ``GuzzleHttp\Event\RequestEvents::PREPARE_REQUEST``
262
+ Used when you want a listener to be trigger while a request is being
263
+ prepared during the ``before`` event. This event priority is used by the
264
+ ``GuzzleHttp\Subscriber\Prepare`` event subscriber which is responsible for
265
+ guessing a Content-Type, Content-Length, and Expect header of a request.
266
+ You should subscribe after this event is triggered if you want to ensure
267
+ that this subscriber has already been triggered.
268
+
269
+ ``GuzzleHttp\Event\RequestEvents::SIGN_REQUEST``
270
+ Used when you want a listener to be triggered when a request is about to be
271
+ signed. Any listener triggered at this point should expect that the request
272
+ object will no longer be mutated. If you are implementing a custom
273
+ signature subscriber, then you should use this event priority to sign
274
+ requests.
275
+
276
+ ``GuzzleHttp\Event\RequestEvents::VERIFY_RESPONSE``
277
+ Used when you want a listener to be triggered when a response is being
278
+ validated during the ``complete`` event. The
279
+ ``GuzzleHttp\Subscriber\HttpError`` event subscriber uses this event
280
+ priority to check if an exception should be thrown due to a 4xx or 5xx
281
+ level response status code. If you are doing any kind of verification of a
282
+ response during the complete event, it should happen at this priority.
283
+
284
+ ``GuzzleHttp\Event\RequestEvents::REDIRECT_RESPONSE``
285
+ Used when you want a listener to be triggered when a response is being
286
+ redirected during the ``complete`` event. The
287
+ ``GuzzleHttp\Subscriber\Redirect`` event subscriber uses this event
288
+ priority when performing redirects.
289
+
290
+ You can use the above event priorities as a guideline for determining the
291
+ priority of you event listeners. You can use these constants and add to or
292
+ subtract from them to ensure that a listener happens before or after the named
293
+ priority.
294
+
295
+ .. note::
296
+
297
+ "first" and "last" priorities are not adjusted after they added to an
298
+ emitter. For example, if you add a listener with a priority of "first",
299
+ you can still add subsequent listeners with a higher priority which would
300
+ be triggered before the listener added with a priority of "first".
301
+
302
+ Working With Request Events
303
+ ===========================
304
+
305
+ Requests emit lifecycle events when they are transferred.
306
+
307
+ .. important::
308
+
309
+ Excluding the ``end`` event, request lifecycle events may be triggered
310
+ multiple times due to redirects, retries, or reusing a request multiple
311
+ times. Use the ``once()`` method want the event to be triggered once. You
312
+ can also remove an event listener from an emitter by using the emitter which
313
+ is provided to the listener.
314
+
315
+ .. _before_event:
316
+
317
+ before
318
+ ------
319
+
320
+ The ``before`` event is emitted before a request is sent. The event emitted is
321
+ a ``GuzzleHttp\Event\BeforeEvent``.
322
+
323
+ .. code-block:: php
324
+
325
+ use GuzzleHttp\Client;
326
+ use GuzzleHttp\Event\EmitterInterface;
327
+ use GuzzleHttp\Event\BeforeEvent;
328
+
329
+ $client = new Client(['base_url' => 'http://httpbin.org']);
330
+ $request = $client->createRequest('GET', '/');
331
+ $request->getEmitter()->on(
332
+ 'before',
333
+ function (BeforeEvent $e, $name) {
334
+ echo $name . "\n";
335
+ // "before"
336
+ echo $e->getRequest()->getMethod() . "\n";
337
+ // "GET" / "POST" / "PUT" / etc.
338
+ echo get_class($e->getClient());
339
+ // "GuzzleHttp\Client"
340
+ }
341
+ );
342
+
343
+ You can intercept a request with a response before the request is sent over the
344
+ wire. The ``intercept()`` method of the ``BeforeEvent`` accepts a
345
+ ``GuzzleHttp\Message\ResponseInterface``. Intercepting the event will prevent
346
+ the request from being sent over the wire and stops the propagation of the
347
+ ``before`` event, preventing subsequent event listeners from being invoked.
348
+
349
+ .. code-block:: php
350
+
351
+ use GuzzleHttp\Client;
352
+ use GuzzleHttp\Event\BeforeEvent;
353
+ use GuzzleHttp\Message\Response;
354
+
355
+ $client = new Client(['base_url' => 'http://httpbin.org']);
356
+ $request = $client->createRequest('GET', '/status/500');
357
+ $request->getEmitter()->on('before', function (BeforeEvent $e) {
358
+ $response = new Response(200);
359
+ $e->intercept($response);
360
+ });
361
+
362
+ $response = $client->send($request);
363
+ echo $response->getStatusCode();
364
+ // 200
365
+
366
+ .. attention::
367
+
368
+ Any exception encountered while executing the ``before`` event will trigger
369
+ the ``error`` event of a request.
370
+
371
+ .. _complete_event:
372
+
373
+ complete
374
+ --------
375
+
376
+ The ``complete`` event is emitted after a transaction completes and an entire
377
+ response has been received. The event is a ``GuzzleHttp\Event\CompleteEvent``.
378
+
379
+ You can intercept the ``complete`` event with a different response if needed
380
+ using the ``intercept()`` method of the event. This can be useful, for example,
381
+ for changing the response for caching.
382
+
383
+ .. code-block:: php
384
+
385
+ use GuzzleHttp\Client;
386
+ use GuzzleHttp\Event\CompleteEvent;
387
+ use GuzzleHttp\Message\Response;
388
+
389
+ $client = new Client(['base_url' => 'http://httpbin.org']);
390
+ $request = $client->createRequest('GET', '/status/302');
391
+ $cachedResponse = new Response(200);
392
+
393
+ $request->getEmitter()->on(
394
+ 'complete',
395
+ function (CompleteEvent $e) use ($cachedResponse) {
396
+ if ($e->getResponse()->getStatusCode() == 302) {
397
+ // Intercept the original transaction with the new response
398
+ $e->intercept($cachedResponse);
399
+ }
400
+ }
401
+ );
402
+
403
+ $response = $client->send($request);
404
+ echo $response->getStatusCode();
405
+ // 200
406
+
407
+ .. attention::
408
+
409
+ Any ``GuzzleHttp\Exception\RequestException`` encountered while executing
410
+ the ``complete`` event will trigger the ``error`` event of a request.
411
+
412
+ .. _error_event:
413
+
414
+ error
415
+ -----
416
+
417
+ The ``error`` event is emitted when a request fails (whether it's from a
418
+ networking error or an HTTP protocol error). The event emitted is a
419
+ ``GuzzleHttp\Event\ErrorEvent``.
420
+
421
+ This event is useful for retrying failed requests. Here's an example of
422
+ retrying failed basic auth requests by re-sending the original request with
423
+ a username and password.
424
+
425
+ .. code-block:: php
426
+
427
+ use GuzzleHttp\Client;
428
+ use GuzzleHttp\Event\ErrorEvent;
429
+
430
+ $client = new Client(['base_url' => 'http://httpbin.org']);
431
+ $request = $client->createRequest('GET', '/basic-auth/foo/bar');
432
+ $request->getEmitter()->on('error', function (ErrorEvent $e) {
433
+ if ($e->getResponse()->getStatusCode() == 401) {
434
+ // Add authentication stuff as needed and retry the request
435
+ $e->getRequest()->setHeader('Authorization', 'Basic ' . base64_encode('foo:bar'));
436
+ // Get the client of the event and retry the request
437
+ $newResponse = $e->getClient()->send($e->getRequest());
438
+ // Intercept the original transaction with the new response
439
+ $e->intercept($newResponse);
440
+ }
441
+ });
442
+
443
+ .. attention::
444
+
445
+ If an ``error`` event is intercepted with a response, then the ``complete``
446
+ event of a request is triggered. If the ``complete`` event fails, then the
447
+ ``error`` event is triggered once again.
448
+
449
+ .. _progress_event:
450
+
451
+ progress
452
+ --------
453
+
454
+ The ``progress`` event is emitted when data is uploaded or downloaded. The
455
+ event emitted is a ``GuzzleHttp\Event\ProgressEvent``.
456
+
457
+ You can access the emitted progress values using the corresponding public
458
+ properties of the event object:
459
+
460
+ - ``$downloadSize``: The number of bytes that will be downloaded (if known)
461
+ - ``$downloaded``: The number of bytes that have been downloaded
462
+ - ``$uploadSize``: The number of bytes that will be uploaded (if known)
463
+ - ``$uploaded``: The number of bytes that have been uploaded
464
+
465
+ This event cannot be intercepted.
466
+
467
+ .. code-block:: php
468
+
469
+ use GuzzleHttp\Client;
470
+ use GuzzleHttp\Event\ProgressEvent;
471
+
472
+ $client = new Client(['base_url' => 'http://httpbin.org']);
473
+ $request = $client->createRequest('PUT', '/put', [
474
+ 'body' => str_repeat('.', 100000)
475
+ ]);
476
+
477
+ $request->getEmitter()->on('progress', function (ProgressEvent $e) {
478
+ echo 'Downloaded ' . $e->downloaded . ' of ' . $e->downloadSize . ' '
479
+ . 'Uploaded ' . $e->uploaded . ' of ' . $e->uploadSize . "\r";
480
+ });
481
+
482
+ $client->send($request);
483
+ echo "\n";
484
+
485
+ .. _end_event:
486
+
487
+ end
488
+ ---
489
+
490
+ The ``end`` event is a terminal event, emitted once per request, that provides
491
+ access to the response that was received or the exception that was encountered.
492
+ The event emitted is a ``GuzzleHttp\Event\EndEvent``.
493
+
494
+ This event can be intercepted, but keep in mind that the ``complete`` event
495
+ will not fire after intercepting this event.
496
+
497
+ .. code-block:: php
498
+
499
+ use GuzzleHttp\Client;
500
+ use GuzzleHttp\Event\EndEvent;
501
+
502
+ $client = new Client(['base_url' => 'http://httpbin.org']);
503
+ $request = $client->createRequest('PUT', '/put', [
504
+ 'body' => str_repeat('.', 100000)
505
+ ]);
506
+
507
+ $request->getEmitter()->on('end', function (EndEvent $e) {
508
+ if ($e->getException()) {
509
+ echo 'Error: ' . $e->getException()->getMessage();
510
+ } else {
511
+ echo 'Response: ' . $e->getResponse();
512
+ }
513
+ });
514
+
515
+ $client->send($request);
516
+ echo "\n";
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/docs/faq.rst ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ===
2
+ FAQ
3
+ ===
4
+
5
+ Why should I use Guzzle?
6
+ ========================
7
+
8
+ Guzzle makes it easy to send HTTP requests and super simple to integrate with
9
+ web services. Guzzle manages things like persistent connections, represents
10
+ query strings as collections, makes it simple to send streaming POST requests
11
+ with fields and files, and abstracts away the underlying HTTP transport layer.
12
+ By providing an object oriented interface for HTTP clients, requests, responses,
13
+ headers, and message bodies, Guzzle makes it so that you no longer need to fool
14
+ around with cURL options, stream contexts, or sockets.
15
+
16
+ **Asynchronous and Synchronous Requests**
17
+
18
+ Guzzle allows you to send both asynchronous and synchronous requests using the
19
+ same interface and no direct dependency on an event loop. This flexibility
20
+ allows Guzzle to send an HTTP request using the most appropriate HTTP handler
21
+ based on the request being sent. For example, when sending synchronous
22
+ requests, Guzzle will by default send requests using cURL easy handles to
23
+ ensure you're using the fastest possible method for serially transferring HTTP
24
+ requests. When sending asynchronous requests, Guzzle might use cURL's multi
25
+ interface or any other asynchronous handler you configure. When you request
26
+ streaming data, Guzzle will by default use PHP's stream wrapper.
27
+
28
+ **Streams**
29
+
30
+ Request and response message bodies use :doc:`Guzzle Streams <streams>`,
31
+ allowing you to stream data without needing to load it all into memory.
32
+ Guzzle's stream layer provides a large suite of functionality:
33
+
34
+ - You can modify streams at runtime using custom or a number of
35
+ pre-made decorators.
36
+ - You can emit progress events as data is read from a stream.
37
+ - You can validate the integrity of a stream using a rolling hash as data is
38
+ read from a stream.
39
+
40
+ **Event System and Plugins**
41
+
42
+ Guzzle's event system allows you to completely modify the behavior of a client
43
+ or request at runtime to cater them for any API. You can send a request with a
44
+ client, and the client can do things like automatically retry your request if
45
+ it fails, automatically redirect, log HTTP messages that are sent over the
46
+ wire, emit progress events as data is uploaded and downloaded, sign requests
47
+ using OAuth 1.0, verify the integrity of messages before and after they are
48
+ sent over the wire, and anything else you might need.
49
+
50
+ **Testable**
51
+
52
+ Another important aspect of Guzzle is that it's really
53
+ :doc:`easy to test clients <testing>`. You can mock HTTP responses and when
54
+ testing an handler implementation, Guzzle provides a mock node.js web server.
55
+
56
+ **Ecosystem**
57
+
58
+ Guzzle has a large `ecosystem of plugins <http://guzzle.readthedocs.org/en/latest/index.html#http-components>`_,
59
+ including `service descriptions <https://github.com/guzzle/guzzle-services>`_
60
+ which allows you to abstract web services using service descriptions. These
61
+ service descriptions define how to serialize an HTTP request and how to parse
62
+ an HTTP response into a more meaningful model object.
63
+
64
+ - `Guzzle Command <https://github.com/guzzle/command>`_: Provides the building
65
+ blocks for service description abstraction.
66
+ - `Guzzle Services <https://github.com/guzzle/guzzle-services>`_: Provides an
67
+ implementation of "Guzzle Command" that utilizes Guzzle's service description
68
+ format.
69
+
70
+ Does Guzzle require cURL?
71
+ =========================
72
+
73
+ No. Guzzle can use any HTTP handler to send requests. This means that Guzzle
74
+ can be used with cURL, PHP's stream wrapper, sockets, and non-blocking libraries
75
+ like `React <http://reactphp.org/>`_. You just need to configure a
76
+ `RingPHP <http://guzzle-ring.readthedocs.org/en/latest/>`_ handler to use a
77
+ different method of sending requests.
78
+
79
+ .. note::
80
+
81
+ Guzzle has historically only utilized cURL to send HTTP requests. cURL is
82
+ an amazing HTTP client (arguably the best), and Guzzle will continue to use
83
+ it by default when it is available. It is rare, but some developers don't
84
+ have cURL installed on their systems or run into version specific issues.
85
+ By allowing swappable HTTP handlers, Guzzle is now much more customizable
86
+ and able to adapt to fit the needs of more developers.
87
+
88
+ Can Guzzle send asynchronous requests?
89
+ ======================================
90
+
91
+ Yes. Pass the ``future`` true request option to a request to send it
92
+ asynchronously. Guzzle will then return a ``GuzzleHttp\Message\FutureResponse``
93
+ object that can be used synchronously by accessing the response object like a
94
+ normal response, and it can be used asynchronously using a promise that is
95
+ notified when the response is resolved with a real response or rejected with an
96
+ exception.
97
+
98
+ .. code-block:: php
99
+
100
+ $request = $client->createRequest('GET', ['future' => true]);
101
+ $client->send($request)->then(function ($response) {
102
+ echo 'Got a response! ' . $response;
103
+ });
104
+
105
+ You can force an asynchronous response to complete using the ``wait()`` method
106
+ of a response.
107
+
108
+ .. code-block:: php
109
+
110
+ $request = $client->createRequest('GET', ['future' => true]);
111
+ $futureResponse = $client->send($request);
112
+ $futureResponse->wait();
113
+
114
+ How can I add custom cURL options?
115
+ ==================================
116
+
117
+ cURL offer a huge number of `customizable options <http://us1.php.net/curl_setopt>`_.
118
+ While Guzzle normalizes many of these options across different handlers, there
119
+ are times when you need to set custom cURL options. This can be accomplished
120
+ by passing an associative array of cURL settings in the **curl** key of the
121
+ **config** request option.
122
+
123
+ For example, let's say you need to customize the outgoing network interface
124
+ used with a client.
125
+
126
+ .. code-block:: php
127
+
128
+ $client->get('/', [
129
+ 'config' => [
130
+ 'curl' => [
131
+ CURLOPT_INTERFACE => 'xxx.xxx.xxx.xxx'
132
+ ]
133
+ ]
134
+ ]);
135
+
136
+ How can I add custom stream context options?
137
+ ============================================
138
+
139
+ You can pass custom `stream context options <http://www.php.net/manual/en/context.php>`_
140
+ using the **stream_context** key of the **config** request option. The
141
+ **stream_context** array is an associative array where each key is a PHP
142
+ transport, and each value is an associative array of transport options.
143
+
144
+ For example, let's say you need to customize the outgoing network interface
145
+ used with a client and allow self-signed certificates.
146
+
147
+ .. code-block:: php
148
+
149
+ $client->get('/', [
150
+ 'stream' => true,
151
+ 'config' => [
152
+ 'stream_context' => [
153
+ 'ssl' => [
154
+ 'allow_self_signed' => true
155
+ ],
156
+ 'socket' => [
157
+ 'bindto' => 'xxx.xxx.xxx.xxx'
158
+ ]
159
+ ]
160
+ ]
161
+ ]);
162
+
163
+ Why am I getting an SSL verification error?
164
+ ===========================================
165
+
166
+ You need to specify the path on disk to the CA bundle used by Guzzle for
167
+ verifying the peer certificate. See :ref:`verify-option`.
168
+
169
+ What is this Maximum function nesting error?
170
+ ============================================
171
+
172
+ Maximum function nesting level of '100' reached, aborting
173
+
174
+ You could run into this error if you have the XDebug extension installed and
175
+ you execute a lot of requests in callbacks. This error message comes
176
+ specifically from the XDebug extension. PHP itself does not have a function
177
+ nesting limit. Change this setting in your php.ini to increase the limit::
178
+
179
+ xdebug.max_nesting_level = 1000
180
+
181
+ Why am I getting a 417 error response?
182
+ ======================================
183
+
184
+ This can occur for a number of reasons, but if you are sending PUT, POST, or
185
+ PATCH requests with an ``Expect: 100-Continue`` header, a server that does not
186
+ support this header will return a 417 response. You can work around this by
187
+ setting the ``expect`` request option to ``false``:
188
+
189
+ .. code-block:: php
190
+
191
+ $client = new GuzzleHttp\Client();
192
+
193
+ // Disable the expect header on a single request
194
+ $response = $client->put('/', [], 'the body', [
195
+ 'expect' => false
196
+ ]);
197
+
198
+ // Disable the expect header on all client requests
199
+ $client->setDefaultOption('expect', false)
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/docs/handlers.rst ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ================
2
+ RingPHP Handlers
3
+ ================
4
+
5
+ Guzzle uses RingPHP handlers to send HTTP requests over the wire.
6
+ RingPHP provides a low-level library that can be used to "glue" Guzzle with
7
+ any transport method you choose. By default, Guzzle utilizes cURL and PHP's
8
+ stream wrappers to send HTTP requests.
9
+
10
+ RingPHP handlers makes it extremely simple to integrate Guzzle with any
11
+ HTTP transport. For example, you could quite easily bridge Guzzle and React
12
+ to use Guzzle in React's event loop.
13
+
14
+ Using a handler
15
+ ---------------
16
+
17
+ You can change the handler used by a client using the ``handler`` option in the
18
+ ``GuzzleHttp\Client`` constructor.
19
+
20
+ .. code-block:: php
21
+
22
+ use GuzzleHttp\Client;
23
+ use GuzzleHttp\Ring\Client\MockHandler;
24
+
25
+ // Create a mock handler that always returns a 200 response.
26
+ $handler = new MockHandler(['status' => 200]);
27
+
28
+ // Configure to client to use the mock handler.
29
+ $client = new Client(['handler' => $handler]);
30
+
31
+ At its core, handlers are simply PHP callables that accept a request array
32
+ and return a ``GuzzleHttp\Ring\Future\FutureArrayInterface``. This future array
33
+ can be used just like a normal PHP array, causing it to block, or you can use
34
+ the promise interface using the ``then()`` method of the future. Guzzle hooks
35
+ up to the RingPHP project using a very simple bridge class
36
+ (``GuzzleHttp\RingBridge``).
37
+
38
+ Creating a handler
39
+ ------------------
40
+
41
+ See the `RingPHP <http://ringphp.readthedocs.org>`_ project
42
+ documentation for more information on creating custom handlers that can be
43
+ used with Guzzle clients.
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/docs/http-messages.rst ADDED
@@ -0,0 +1,483 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ =============================
2
+ Request and Response Messages
3
+ =============================
4
+
5
+ Guzzle is an HTTP client that sends HTTP requests to a server and receives HTTP
6
+ responses. Both requests and responses are referred to as messages.
7
+
8
+ Headers
9
+ =======
10
+
11
+ Both request and response messages contain HTTP headers.
12
+
13
+ Complex Headers
14
+ ---------------
15
+
16
+ Some headers contain additional key value pair information. For example, Link
17
+ headers contain a link and several key value pairs:
18
+
19
+ ::
20
+
21
+ <http://foo.com>; rel="thing"; type="image/jpeg"
22
+
23
+ Guzzle provides a convenience feature that can be used to parse these types of
24
+ headers:
25
+
26
+ .. code-block:: php
27
+
28
+ use GuzzleHttp\Message\Request;
29
+
30
+ $request = new Request('GET', '/', [
31
+ 'Link' => '<http:/.../front.jpeg>; rel="front"; type="image/jpeg"'
32
+ ]);
33
+
34
+ $parsed = Request::parseHeader($request, 'Link');
35
+ var_export($parsed);
36
+
37
+ Will output:
38
+
39
+ .. code-block:: php
40
+
41
+ array (
42
+ 0 =>
43
+ array (
44
+ 0 => '<http:/.../front.jpeg>',
45
+ 'rel' => 'front',
46
+ 'type' => 'image/jpeg',
47
+ ),
48
+ )
49
+
50
+ The result contains a hash of key value pairs. Header values that have no key
51
+ (i.e., the link) are indexed numerically while headers parts that form a key
52
+ value pair are added as a key value pair.
53
+
54
+ See :ref:`headers` for information on how the headers of a request and response
55
+ can be accessed and modified.
56
+
57
+ Body
58
+ ====
59
+
60
+ Both request and response messages can contain a body.
61
+
62
+ You can check to see if a request or response has a body using the
63
+ ``getBody()`` method:
64
+
65
+ .. code-block:: php
66
+
67
+ $response = GuzzleHttp\get('http://httpbin.org/get');
68
+ if ($response->getBody()) {
69
+ echo $response->getBody();
70
+ // JSON string: { ... }
71
+ }
72
+
73
+ The body used in request and response objects is a
74
+ ``GuzzleHttp\Stream\StreamInterface``. This stream is used for both uploading
75
+ data and downloading data. Guzzle will, by default, store the body of a message
76
+ in a stream that uses PHP temp streams. When the size of the body exceeds
77
+ 2 MB, the stream will automatically switch to storing data on disk rather than
78
+ in memory (protecting your application from memory exhaustion).
79
+
80
+ You can change the body used in a request or response using the ``setBody()``
81
+ method:
82
+
83
+ .. code-block:: php
84
+
85
+ use GuzzleHttp\Stream\Stream;
86
+ $request = $client->createRequest('PUT', 'http://httpbin.org/put');
87
+ $request->setBody(Stream::factory('foo'));
88
+
89
+ The easiest way to create a body for a request is using the static
90
+ ``GuzzleHttp\Stream\Stream::factory()`` method. This method accepts various
91
+ inputs like strings, resources returned from ``fopen()``, and other
92
+ ``GuzzleHttp\Stream\StreamInterface`` objects.
93
+
94
+ The body of a request or response can be cast to a string or you can read and
95
+ write bytes off of the stream as needed.
96
+
97
+ .. code-block:: php
98
+
99
+ use GuzzleHttp\Stream\Stream;
100
+ $request = $client->createRequest('PUT', 'http://httpbin.org/put', ['body' => 'testing...']);
101
+
102
+ echo $request->getBody()->read(4);
103
+ // test
104
+ echo $request->getBody()->read(4);
105
+ // ing.
106
+ echo $request->getBody()->read(1024);
107
+ // ..
108
+ var_export($request->eof());
109
+ // true
110
+
111
+ You can find out more about Guzzle stream objects in :doc:`streams`.
112
+
113
+ Requests
114
+ ========
115
+
116
+ Requests are sent from a client to a server. Requests include the method to
117
+ be applied to a resource, the identifier of the resource, and the protocol
118
+ version to use.
119
+
120
+ Clients are used to create request messages. More precisely, clients use
121
+ a ``GuzzleHttp\Message\MessageFactoryInterface`` to create request messages.
122
+ You create requests with a client using the ``createRequest()`` method.
123
+
124
+ .. code-block:: php
125
+
126
+ // Create a request but don't send it immediately
127
+ $request = $client->createRequest('GET', 'http://httpbin.org/get');
128
+
129
+ Request Methods
130
+ ---------------
131
+
132
+ When creating a request, you are expected to provide the HTTP method you wish
133
+ to perform. You can specify any method you'd like, including a custom method
134
+ that might not be part of RFC 7231 (like "MOVE").
135
+
136
+ .. code-block:: php
137
+
138
+ // Create a request using a completely custom HTTP method
139
+ $request = $client->createRequest('MOVE', 'http://httpbin.org/move', ['exceptions' => false]);
140
+
141
+ echo $request->getMethod();
142
+ // MOVE
143
+
144
+ $response = $client->send($request);
145
+ echo $response->getStatusCode();
146
+ // 405
147
+
148
+ You can create and send a request using methods on a client that map to the
149
+ HTTP method you wish to use.
150
+
151
+ :GET: ``$client->get('http://httpbin.org/get', [/** options **/])``
152
+ :POST: ``$client->post('http://httpbin.org/post', [/** options **/])``
153
+ :HEAD: ``$client->head('http://httpbin.org/get', [/** options **/])``
154
+ :PUT: ``$client->put('http://httpbin.org/put', [/** options **/])``
155
+ :DELETE: ``$client->delete('http://httpbin.org/delete', [/** options **/])``
156
+ :OPTIONS: ``$client->options('http://httpbin.org/get', [/** options **/])``
157
+ :PATCH: ``$client->patch('http://httpbin.org/put', [/** options **/])``
158
+
159
+ .. code-block:: php
160
+
161
+ $response = $client->patch('http://httpbin.org/patch', ['body' => 'content']);
162
+
163
+ Request URI
164
+ -----------
165
+
166
+ The resource you are requesting with an HTTP request is identified by the
167
+ path of the request, the query string, and the "Host" header of the request.
168
+
169
+ When creating a request, you can provide the entire resource URI as a URL.
170
+
171
+ .. code-block:: php
172
+
173
+ $response = $client->get('http://httbin.org/get?q=foo');
174
+
175
+ Using the above code, you will send a request that uses ``httpbin.org`` as
176
+ the Host header, sends the request over port 80, uses ``/get`` as the path,
177
+ and sends ``?q=foo`` as the query string. All of this is parsed automatically
178
+ from the provided URI.
179
+
180
+ Sometimes you don't know what the entire request will be when it is created.
181
+ In these cases, you can modify the request as needed before sending it using
182
+ the ``createRequest()`` method of the client and methods on the request that
183
+ allow you to change it.
184
+
185
+ .. code-block:: php
186
+
187
+ $request = $client->createRequest('GET', 'http://httbin.org');
188
+
189
+ You can change the path of the request using ``setPath()``:
190
+
191
+ .. code-block:: php
192
+
193
+ $request->setPath('/get');
194
+ echo $request->getPath();
195
+ // /get
196
+ echo $request->getUrl();
197
+ // http://httpbin.com/get
198
+
199
+ Scheme
200
+ ~~~~~~
201
+
202
+ The `scheme <http://tools.ietf.org/html/rfc3986#section-3.1>`_ of a request
203
+ specifies the protocol to use when sending the request. When using Guzzle, the
204
+ scheme can be set to "http" or "https".
205
+
206
+ You can change the scheme of the request using the ``setScheme()`` method:
207
+
208
+ .. code-block:: php
209
+
210
+ $request = $client->createRequest('GET', 'http://httbin.org');
211
+ $request->setScheme('https');
212
+ echo $request->getScheme();
213
+ // https
214
+ echo $request->getUrl();
215
+ // https://httpbin.com/get
216
+
217
+ Port
218
+ ~~~~
219
+
220
+ No port is necessary when using the "http" or "https" schemes, but you can
221
+ override the port using ``setPort()``. If you need to modify the port used with
222
+ the specified scheme from the default setting, then you must use the
223
+ ``setPort()`` method.
224
+
225
+ .. code-block:: php
226
+
227
+ $request = $client->createRequest('GET', 'http://httbin.org');
228
+ $request->setPort(8080);
229
+ echo $request->getPort();
230
+ // 8080
231
+ echo $request->getUrl();
232
+ // https://httpbin.com:8080/get
233
+
234
+ // Set the port back to the default value for the scheme
235
+ $request->setPort(443);
236
+ echo $request->getUrl();
237
+ // https://httpbin.com/get
238
+
239
+ Query string
240
+ ~~~~~~~~~~~~
241
+
242
+ You can get the query string of the request using the ``getQuery()`` method.
243
+ This method returns a ``GuzzleHttp\Query`` object. A Query object can be
244
+ accessed like a PHP array, iterated in a foreach statement like a PHP array,
245
+ and cast to a string.
246
+
247
+ .. code-block:: php
248
+
249
+ $request = $client->createRequest('GET', 'http://httbin.org');
250
+ $query = $request->getQuery();
251
+ $query['foo'] = 'bar';
252
+ $query['baz'] = 'bam';
253
+ $query['bam'] = ['test' => 'abc'];
254
+
255
+ echo $request->getQuery();
256
+ // foo=bar&baz=bam&bam%5Btest%5D=abc
257
+
258
+ echo $request->getQuery()['foo'];
259
+ // bar
260
+ echo $request->getQuery()->get('foo');
261
+ // bar
262
+ echo $request->getQuery()->get('foo');
263
+ // bar
264
+
265
+ var_export($request->getQuery()['bam']);
266
+ // array('test' => 'abc')
267
+
268
+ foreach ($query as $key => $value) {
269
+ var_export($value);
270
+ }
271
+
272
+ echo $request->getUrl();
273
+ // https://httpbin.com/get?foo=bar&baz=bam&bam%5Btest%5D=abc
274
+
275
+ Query Aggregators
276
+ ^^^^^^^^^^^^^^^^^
277
+
278
+ Query objects can store scalar values or arrays of values. When an array of
279
+ values is added to a query object, the query object uses a query aggregator to
280
+ convert the complex structure into a string. Query objects will use
281
+ `PHP style query strings <http://www.php.net/http_build_query>`_ when complex
282
+ query string parameters are converted to a string. You can customize how
283
+ complex query string parameters are aggregated using the ``setAggregator()``
284
+ method of a query string object.
285
+
286
+ .. code-block:: php
287
+
288
+ $query->setAggregator($query::duplicateAggregator());
289
+
290
+ In the above example, we've changed the query object to use the
291
+ "duplicateAggregator". This aggregator will allow duplicate entries to appear
292
+ in a query string rather than appending "[n]" to each value. So if you had a
293
+ query string with ``['a' => ['b', 'c']]``, the duplicate aggregator would
294
+ convert this to "a=b&a=c" while the default aggregator would convert this to
295
+ "a[0]=b&a[1]=c" (with urlencoded brackets).
296
+
297
+ The ``setAggregator()`` method accepts a ``callable`` which is used to convert
298
+ a deeply nested array of query string variables into a flattened array of key
299
+ value pairs. The callable accepts an array of query data and returns a
300
+ flattened array of key value pairs where each value is an array of strings.
301
+ You can use the ``GuzzleHttp\Query::walkQuery()`` static function to easily
302
+ create custom query aggregators.
303
+
304
+ Host
305
+ ~~~~
306
+
307
+ You can change the host header of the request in a predictable way using the
308
+ ``setHost()`` method of a request:
309
+
310
+ .. code-block:: php
311
+
312
+ $request->setHost('www.google.com');
313
+ echo $request->getHost();
314
+ // www.google.com
315
+ echo $request->getUrl();
316
+ // https://www.google.com/get?foo=bar&baz=bam
317
+
318
+ .. note::
319
+
320
+ The Host header can also be changed by modifying the Host header of a
321
+ request directly, but modifying the Host header directly could result in
322
+ sending a request to a different Host than what is specified in the Host
323
+ header (sometimes this is actually the desired behavior).
324
+
325
+ Resource
326
+ ~~~~~~~~
327
+
328
+ You can use the ``getResource()`` method of a request to return the path and
329
+ query string of a request in a single string.
330
+
331
+ .. code-block:: php
332
+
333
+ $request = $client->createRequest('GET', 'http://httpbin.org/get?baz=bar');
334
+ echo $request->getResource();
335
+ // /get?baz=bar
336
+
337
+ Request Config
338
+ --------------
339
+
340
+ Request messages contain a configuration collection that can be used by
341
+ event listeners and HTTP handlers to modify how a request behaves or is
342
+ transferred over the wire. For example, many of the request options that are
343
+ specified when creating a request are actually set as config options that are
344
+ only acted upon by handlers and listeners when the request is sent.
345
+
346
+ You can get access to the request's config object using the ``getConfig()``
347
+ method of a request.
348
+
349
+ .. code-block:: php
350
+
351
+ $request = $client->createRequest('GET', '/');
352
+ $config = $request->getConfig();
353
+
354
+ The config object is a ``GuzzleHttp\Collection`` object that acts like
355
+ an associative array. You can grab values from the collection using array like
356
+ access. You can also modify and remove values using array like access.
357
+
358
+ .. code-block:: php
359
+
360
+ $config['foo'] = 'bar';
361
+ echo $config['foo'];
362
+ // bar
363
+
364
+ var_export(isset($config['foo']));
365
+ // true
366
+
367
+ unset($config['foo']);
368
+ var_export(isset($config['foo']));
369
+ // false
370
+
371
+ var_export($config['foo']);
372
+ // NULL
373
+
374
+ HTTP handlers and event listeners can expose additional customization options
375
+ through request config settings. For example, in order to specify custom cURL
376
+ options to the cURL handler, you need to specify an associative array in the
377
+ ``curl`` ``config`` request option.
378
+
379
+ .. code-block:: php
380
+
381
+ $client->get('/', [
382
+ 'config' => [
383
+ 'curl' => [
384
+ CURLOPT_HTTPAUTH => CURLAUTH_NTLM,
385
+ CURLOPT_USERPWD => 'username:password'
386
+ ]
387
+ ]
388
+ ]);
389
+
390
+ Consult the HTTP handlers and event listeners you are using to see if they
391
+ allow customization through request configuration options.
392
+
393
+ Event Emitter
394
+ -------------
395
+
396
+ Request objects implement ``GuzzleHttp\Event\HasEmitterInterface``, so they
397
+ have a method called ``getEmitter()`` that can be used to get an event emitter
398
+ used by the request. Any listener or subscriber attached to a request will only
399
+ be triggered for the lifecycle events of a specific request. Conversely, adding
400
+ an event listener or subscriber to a client will listen to all lifecycle events
401
+ of all requests created by the client.
402
+
403
+ See :doc:`events` for more information.
404
+
405
+ Responses
406
+ =========
407
+
408
+ Responses are the HTTP messages a client receives from a server after sending
409
+ an HTTP request message.
410
+
411
+ Start-Line
412
+ ----------
413
+
414
+ The start-line of a response contains the protocol and protocol version,
415
+ status code, and reason phrase.
416
+
417
+ .. code-block:: php
418
+
419
+ $response = GuzzleHttp\get('http://httpbin.org/get');
420
+ echo $response->getStatusCode();
421
+ // 200
422
+ echo $response->getReasonPhrase();
423
+ // OK
424
+ echo $response->getProtocolVersion();
425
+ // 1.1
426
+
427
+ Body
428
+ ----
429
+
430
+ As described earlier, you can get the body of a response using the
431
+ ``getBody()`` method.
432
+
433
+ .. code-block:: php
434
+
435
+ if ($body = $response->getBody()) {
436
+ echo $body;
437
+ // Cast to a string: { ... }
438
+ $body->seek(0);
439
+ // Rewind the body
440
+ $body->read(1024);
441
+ // Read bytes of the body
442
+ }
443
+
444
+ When working with JSON responses, you can use the ``json()`` method of a
445
+ response:
446
+
447
+ .. code-block:: php
448
+
449
+ $json = $response->json();
450
+
451
+ .. note::
452
+
453
+ Guzzle uses the ``json_decode()`` method of PHP and uses arrays rather than
454
+ ``stdClass`` objects for objects.
455
+
456
+ You can use the ``xml()`` method when working with XML data.
457
+
458
+ .. code-block:: php
459
+
460
+ $xml = $response->xml();
461
+
462
+ .. note::
463
+
464
+ Guzzle uses the ``SimpleXMLElement`` objects when converting response
465
+ bodies to XML.
466
+
467
+ Effective URL
468
+ -------------
469
+
470
+ The URL that was ultimately accessed that returned a response can be accessed
471
+ using the ``getEffectiveUrl()`` method of a response. This method will return
472
+ the URL of a request or the URL of the last redirected URL if any redirects
473
+ occurred while transferring a request.
474
+
475
+ .. code-block:: php
476
+
477
+ $response = GuzzleHttp\get('http://httpbin.org/get');
478
+ echo $response->getEffectiveUrl();
479
+ // http://httpbin.org/get
480
+
481
+ $response = GuzzleHttp\get('http://httpbin.org/redirect-to?url=http://www.google.com');
482
+ echo $response->getEffectiveUrl();
483
+ // http://www.google.com
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/docs/index.rst ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .. title:: Guzzle | PHP HTTP client and framework for consuming RESTful web services
2
+
3
+ ======
4
+ Guzzle
5
+ ======
6
+
7
+ Guzzle is a PHP HTTP client that makes it easy to send HTTP requests and
8
+ trivial to integrate with web services.
9
+
10
+ - Manages things like persistent connections, represents query strings as
11
+ collections, simplifies sending streaming POST requests with fields and
12
+ files, and abstracts away the underlying HTTP transport layer.
13
+ - Can send both synchronous and asynchronous requests using the same interface
14
+ without requiring a dependency on a specific event loop.
15
+ - Pluggable HTTP handlers allows Guzzle to integrate with any method you choose
16
+ for sending HTTP requests over the wire (e.g., cURL, sockets, PHP's stream
17
+ wrapper, non-blocking event loops like `React <http://reactphp.org/>`_, etc.).
18
+ - Guzzle makes it so that you no longer need to fool around with cURL options,
19
+ stream contexts, or sockets.
20
+
21
+ .. code-block:: php
22
+
23
+ $client = new GuzzleHttp\Client();
24
+ $response = $client->get('http://guzzlephp.org');
25
+ $res = $client->get('https://api.github.com/user', ['auth' => ['user', 'pass']]);
26
+ echo $res->getStatusCode();
27
+ // "200"
28
+ echo $res->getHeader('content-type');
29
+ // 'application/json; charset=utf8'
30
+ echo $res->getBody();
31
+ // {"type":"User"...'
32
+ var_export($res->json());
33
+ // Outputs the JSON decoded data
34
+
35
+ // Send an asynchronous request.
36
+ $req = $client->createRequest('GET', 'http://httpbin.org', ['future' => true]);
37
+ $client->send($req)->then(function ($response) {
38
+ echo 'I completed! ' . $response;
39
+ });
40
+
41
+ User guide
42
+ ----------
43
+
44
+ .. toctree::
45
+ :maxdepth: 2
46
+
47
+ overview
48
+ quickstart
49
+ clients
50
+ http-messages
51
+ events
52
+ streams
53
+ handlers
54
+ testing
55
+ faq
56
+
57
+ HTTP Components
58
+ ---------------
59
+
60
+ There are a number of optional libraries you can use along with Guzzle's HTTP
61
+ layer to add capabilities to the client.
62
+
63
+ `Log Subscriber <https://github.com/guzzle/log-subscriber>`_
64
+ Logs HTTP requests and responses sent over the wire using customizable
65
+ log message templates.
66
+
67
+ `OAuth Subscriber <https://github.com/guzzle/oauth-subscriber>`_
68
+ Signs requests using OAuth 1.0.
69
+
70
+ `Cache Subscriber <https://github.com/guzzle/cache-subscriber>`_
71
+ Implements a private transparent proxy cache that caches HTTP responses.
72
+
73
+ `Retry Subscriber <https://github.com/guzzle/retry-subscriber>`_
74
+ Retries failed requests using customizable retry strategies (e.g., retry
75
+ based on response status code, cURL error codes, etc.)
76
+
77
+ `Message Integrity Subscriber <https://github.com/guzzle/message-integrity-subscriber>`_
78
+ Verifies the message integrity of HTTP responses using customizable
79
+ validators. This plugin can be used, for example, to verify the Content-MD5
80
+ headers of responses.
81
+
82
+ Service Description Commands
83
+ ----------------------------
84
+
85
+ You can use the **Guzzle Command** library to encapsulate interaction with a
86
+ web service using command objects. Building on top of Guzzle's command
87
+ abstraction allows you to easily implement things like service description that
88
+ can be used to serialize requests and parse responses using a meta-description
89
+ of a web service.
90
+
91
+ `Guzzle Command <https://github.com/guzzle/command>`_
92
+ Provides the foundational elements used to build high-level, command based,
93
+ web service clients with Guzzle.
94
+
95
+ `Guzzle Services <https://github.com/guzzle/guzzle-services>`_
96
+ Provides an implementation of the *Guzzle Command* library that uses
97
+ Guzzle service descriptions to describe web services, serialize requests,
98
+ and parse responses into easy to use model structures.
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/docs/overview.rst ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ========
2
+ Overview
3
+ ========
4
+
5
+ Requirements
6
+ ============
7
+
8
+ #. PHP 5.4.0
9
+ #. To use the PHP stream handler, ``allow_url_fopen`` must be enabled in your
10
+ system's php.ini.
11
+ #. To use the cURL handler, you must have a recent version of cURL >= 7.16.2
12
+ compiled with OpenSSL and zlib.
13
+
14
+ .. note::
15
+
16
+ Guzzle no longer requires cURL in order to send HTTP requests. Guzzle will
17
+ use the PHP stream wrapper to send HTTP requests if cURL is not installed.
18
+ Alternatively, you can provide your own HTTP handler used to send requests.
19
+
20
+ .. _installation:
21
+
22
+ Installation
23
+ ============
24
+
25
+ The recommended way to install Guzzle is with `Composer <http://getcomposer.org>`_. Composer is a dependency
26
+ management tool for PHP that allows you to declare the dependencies your project needs and installs them into your
27
+ project.
28
+
29
+ .. code-block:: bash
30
+
31
+ # Install Composer
32
+ curl -sS https://getcomposer.org/installer | php
33
+
34
+ You can add Guzzle as a dependency using the composer.phar CLI:
35
+
36
+ .. code-block:: bash
37
+
38
+ php composer.phar require guzzlehttp/guzzle:~5.0
39
+
40
+ Alternatively, you can specify Guzzle as a dependency in your project's
41
+ existing composer.json file:
42
+
43
+ .. code-block:: js
44
+
45
+ {
46
+ "require": {
47
+ "guzzlehttp/guzzle": "~5.0"
48
+ }
49
+ }
50
+
51
+ After installing, you need to require Composer's autoloader:
52
+
53
+ .. code-block:: php
54
+
55
+ require 'vendor/autoload.php';
56
+
57
+ You can find out more on how to install Composer, configure autoloading, and
58
+ other best-practices for defining dependencies at `getcomposer.org <http://getcomposer.org>`_.
59
+
60
+ Bleeding edge
61
+ -------------
62
+
63
+ During your development, you can keep up with the latest changes on the master
64
+ branch by setting the version requirement for Guzzle to ``~5.0@dev``.
65
+
66
+ .. code-block:: js
67
+
68
+ {
69
+ "require": {
70
+ "guzzlehttp/guzzle": "~5.0@dev"
71
+ }
72
+ }
73
+
74
+ License
75
+ =======
76
+
77
+ Licensed using the `MIT license <http://opensource.org/licenses/MIT>`_.
78
+
79
+ Copyright (c) 2014 Michael Dowling <https://github.com/mtdowling>
80
+
81
+ Permission is hereby granted, free of charge, to any person obtaining a copy
82
+ of this software and associated documentation files (the "Software"), to deal
83
+ in the Software without restriction, including without limitation the rights
84
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
85
+ copies of the Software, and to permit persons to whom the Software is
86
+ furnished to do so, subject to the following conditions:
87
+
88
+ The above copyright notice and this permission notice shall be included in
89
+ all copies or substantial portions of the Software.
90
+
91
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
92
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
93
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
94
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
95
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
96
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
97
+ THE SOFTWARE.
98
+
99
+ Contributing
100
+ ============
101
+
102
+ Guidelines
103
+ ----------
104
+
105
+ 1. Guzzle follows PSR-0, PSR-1, and PSR-2.
106
+ 2. Guzzle is meant to be lean and fast with very few dependencies.
107
+ 3. Guzzle has a minimum PHP version requirement of PHP 5.4. Pull requests must
108
+ not require a PHP version greater than PHP 5.4.
109
+ 4. All pull requests must include unit tests to ensure the change works as
110
+ expected and to prevent regressions.
111
+
112
+ Running the tests
113
+ -----------------
114
+
115
+ In order to contribute, you'll need to checkout the source from GitHub and
116
+ install Guzzle's dependencies using Composer:
117
+
118
+ .. code-block:: bash
119
+
120
+ git clone https://github.com/guzzle/guzzle.git
121
+ cd guzzle && curl -s http://getcomposer.org/installer | php && ./composer.phar install --dev
122
+
123
+ Guzzle is unit tested with PHPUnit. Run the tests using the vendored PHPUnit
124
+ binary:
125
+
126
+ .. code-block:: bash
127
+
128
+ vendor/bin/phpunit
129
+
130
+ .. note::
131
+
132
+ You'll need to install node.js v0.5.0 or newer in order to perform
133
+ integration tests on Guzzle's HTTP handlers.
134
+
135
+ Reporting a security vulnerability
136
+ ==================================
137
+
138
+ We want to ensure that Guzzle is a secure HTTP client library for everyone. If
139
+ you've discovered a security vulnerability in Guzzle, we appreciate your help
140
+ in disclosing it to us in a `responsible manner <http://en.wikipedia.org/wiki/Responsible_disclosure>`_.
141
+
142
+ Publicly disclosing a vulnerability can put the entire community at risk. If
143
+ you've discovered a security concern, please email us at
144
+ security@guzzlephp.org. We'll work with you to make sure that we understand the
145
+ scope of the issue, and that we fully address your concern. We consider
146
+ correspondence sent to security@guzzlephp.org our highest priority, and work to
147
+ address any issues that arise as quickly as possible.
148
+
149
+ After a security vulnerability has been corrected, a security hotfix release will
150
+ be deployed as soon as possible.
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/docs/quickstart.rst ADDED
@@ -0,0 +1,448 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ==========
2
+ Quickstart
3
+ ==========
4
+
5
+ This page provides a quick introduction to Guzzle and introductory examples.
6
+ If you have not already installed, Guzzle, head over to the :ref:`installation`
7
+ page.
8
+
9
+ Make a Request
10
+ ==============
11
+
12
+ You can send requests with Guzzle using a ``GuzzleHttp\ClientInterface``
13
+ object.
14
+
15
+ Creating a Client
16
+ -----------------
17
+
18
+ The procedural API is simple but not very testable; it's best left for quick
19
+ prototyping. If you want to use Guzzle in a more flexible and testable way,
20
+ then you'll need to use a ``GuzzleHttp\ClientInterface`` object.
21
+
22
+ .. code-block:: php
23
+
24
+ use GuzzleHttp\Client;
25
+
26
+ $client = new Client();
27
+ $response = $client->get('http://httpbin.org/get');
28
+
29
+ // You can use the same methods you saw in the procedural API
30
+ $response = $client->delete('http://httpbin.org/delete');
31
+ $response = $client->head('http://httpbin.org/get');
32
+ $response = $client->options('http://httpbin.org/get');
33
+ $response = $client->patch('http://httpbin.org/patch');
34
+ $response = $client->post('http://httpbin.org/post');
35
+ $response = $client->put('http://httpbin.org/put');
36
+
37
+ You can create a request with a client and then send the request with the
38
+ client when you're ready.
39
+
40
+ .. code-block:: php
41
+
42
+ $request = $client->createRequest('GET', 'http://www.foo.com');
43
+ $response = $client->send($request);
44
+
45
+ Client objects provide a great deal of flexibility in how request are
46
+ transferred including default request options, subscribers that are attached
47
+ to each request, and a base URL that allows you to send requests with relative
48
+ URLs. You can find out all about clients in the :doc:`clients` page of the
49
+ documentation.
50
+
51
+ Using Responses
52
+ ===============
53
+
54
+ In the previous examples, we retrieved a ``$response`` variable. This value is
55
+ actually a ``GuzzleHttp\Message\ResponseInterface`` object and contains lots
56
+ of helpful information.
57
+
58
+ You can get the status code and reason phrase of the response.
59
+
60
+ .. code-block:: php
61
+
62
+ $code = $response->getStatusCode();
63
+ // 200
64
+
65
+ $reason = $response->getReasonPhrase();
66
+ // OK
67
+
68
+ By providing the ``future`` request option to a request, you can send requests
69
+ asynchronously using the promise interface of a future response.
70
+
71
+ .. code-block:: php
72
+
73
+ $client->get('http://httpbin.org', ['future' => true])
74
+ ->then(function ($response) {
75
+ echo $response->getStatusCode();
76
+ });
77
+
78
+ Response Body
79
+ -------------
80
+
81
+ The body of a response can be retrieved and cast to a string.
82
+
83
+ .. code-block:: php
84
+
85
+ $body = $response->getBody();
86
+ echo $body;
87
+ // { "some_json_data" ...}
88
+
89
+ You can also read read bytes from body of a response like a stream.
90
+
91
+ .. code-block:: php
92
+
93
+ $body = $response->getBody();
94
+
95
+ while (!$body->eof()) {
96
+ echo $body->read(1024);
97
+ }
98
+
99
+ JSON Responses
100
+ ~~~~~~~~~~~~~~
101
+
102
+ You can more easily work with JSON responses using the ``json()`` method of a
103
+ response.
104
+
105
+ .. code-block:: php
106
+
107
+ $response = $client->get('http://httpbin.org/get');
108
+ $json = $response->json();
109
+ var_dump($json[0]['origin']);
110
+
111
+ Guzzle internally uses PHP's ``json_decode()`` function to parse responses. If
112
+ Guzzle is unable to parse the JSON response body, then a
113
+ ``GuzzleHttp\Exception\ParseException`` is thrown.
114
+
115
+ XML Responses
116
+ ~~~~~~~~~~~~~
117
+
118
+ You can use a response's ``xml()`` method to more easily work with responses
119
+ that contain XML data.
120
+
121
+ .. code-block:: php
122
+
123
+ $response = $client->get('https://github.com/mtdowling.atom');
124
+ $xml = $response->xml();
125
+ echo $xml->id;
126
+ // tag:github.com,2008:/mtdowling
127
+
128
+ Guzzle internally uses a ``SimpleXMLElement`` object to parse responses. If
129
+ Guzzle is unable to parse the XML response body, then a
130
+ ``GuzzleHttp\Exception\ParseException`` is thrown.
131
+
132
+ Query String Parameters
133
+ =======================
134
+
135
+ Sending query string parameters with a request is easy. You can set query
136
+ string parameters in the request's URL.
137
+
138
+ .. code-block:: php
139
+
140
+ $response = $client->get('http://httpbin.org?foo=bar');
141
+
142
+ You can also specify the query string parameters using the ``query`` request
143
+ option.
144
+
145
+ .. code-block:: php
146
+
147
+ $client->get('http://httpbin.org', [
148
+ 'query' => ['foo' => 'bar']
149
+ ]);
150
+
151
+ And finally, you can build up the query string of a request as needed by
152
+ calling the ``getQuery()`` method of a request and modifying the request's
153
+ ``GuzzleHttp\Query`` object as needed.
154
+
155
+ .. code-block:: php
156
+
157
+ $request = $client->createRequest('GET', 'http://httpbin.org');
158
+ $query = $request->getQuery();
159
+ $query->set('foo', 'bar');
160
+
161
+ // You can use the query string object like an array
162
+ $query['baz'] = 'bam';
163
+
164
+ // The query object can be cast to a string
165
+ echo $query;
166
+ // foo=bar&baz=bam
167
+
168
+ // Setting a value to false or null will cause the "=" sign to be omitted
169
+ $query['empty'] = null;
170
+ echo $query;
171
+ // foo=bar&baz=bam&empty
172
+
173
+ // Use an empty string to include the "=" sign with an empty value
174
+ $query['empty'] = '';
175
+ echo $query;
176
+ // foo=bar&baz=bam&empty=
177
+
178
+ .. _headers:
179
+
180
+ Request and Response Headers
181
+ ----------------------------
182
+
183
+ You can specify request headers when sending or creating requests with a
184
+ client. In the following example, we send the ``X-Foo-Header`` with a value of
185
+ ``value`` by setting the ``headers`` request option.
186
+
187
+ .. code-block:: php
188
+
189
+ $response = $client->get('http://httpbin.org/get', [
190
+ 'headers' => ['X-Foo-Header' => 'value']
191
+ ]);
192
+
193
+ You can view the headers of a response using header specific methods of a
194
+ response class. Headers work exactly the same way for request and response
195
+ object.
196
+
197
+ You can retrieve a header from a request or response using the ``getHeader()``
198
+ method of the object. This method is case-insensitive and by default will
199
+ return a string containing the header field value.
200
+
201
+ .. code-block:: php
202
+
203
+ $response = $client->get('http://www.yahoo.com');
204
+ $length = $response->getHeader('Content-Length');
205
+
206
+ Header fields that contain multiple values can be retrieved as a string or as
207
+ an array. Retrieving the field values as a string will naively concatenate all
208
+ of the header values together with a comma. Because not all header fields
209
+ should be represented this way (e.g., ``Set-Cookie``), you can pass an optional
210
+ flag to the ``getHeader()`` method to retrieve the header values as an array.
211
+
212
+ .. code-block:: php
213
+
214
+ $values = $response->getHeader('Set-Cookie', true);
215
+ foreach ($values as $value) {
216
+ echo $value;
217
+ }
218
+
219
+ You can test if a request or response has a specific header using the
220
+ ``hasHeader()`` method. This method accepts a case-insensitive string and
221
+ returns true if the header is present or false if it is not.
222
+
223
+ You can retrieve all of the headers of a message using the ``getHeaders()``
224
+ method of a request or response. The return value is an associative array where
225
+ the keys represent the header name as it will be sent over the wire, and each
226
+ value is an array of strings associated with the header.
227
+
228
+ .. code-block:: php
229
+
230
+ $headers = $response->getHeaders();
231
+ foreach ($message->getHeaders() as $name => $values) {
232
+ echo $name . ": " . implode(", ", $values);
233
+ }
234
+
235
+ Modifying headers
236
+ -----------------
237
+
238
+ The headers of a message can be modified using the ``setHeader()``,
239
+ ``addHeader()``, ``setHeaders()``, and ``removeHeader()`` methods of a request
240
+ or response object.
241
+
242
+ .. code-block:: php
243
+
244
+ $request = $client->createRequest('GET', 'http://httpbin.org/get');
245
+
246
+ // Set a single value for a header
247
+ $request->setHeader('User-Agent', 'Testing!');
248
+
249
+ // Set multiple values for a header in one call
250
+ $request->setHeader('X-Foo', ['Baz', 'Bar']);
251
+
252
+ // Add a header to the message
253
+ $request->addHeader('X-Foo', 'Bam');
254
+
255
+ echo $request->getHeader('X-Foo');
256
+ // Baz, Bar, Bam
257
+
258
+ // Remove a specific header using a case-insensitive name
259
+ $request->removeHeader('x-foo');
260
+ echo $request->getHeader('X-Foo');
261
+ // Echoes an empty string: ''
262
+
263
+ Uploading Data
264
+ ==============
265
+
266
+ Guzzle provides several methods of uploading data.
267
+
268
+ You can send requests that contain a stream of data by passing a string,
269
+ resource returned from ``fopen``, or a ``GuzzleHttp\Stream\StreamInterface``
270
+ object to the ``body`` request option.
271
+
272
+ .. code-block:: php
273
+
274
+ $r = $client->post('http://httpbin.org/post', ['body' => 'raw data']);
275
+
276
+ You can easily upload JSON data using the ``json`` request option.
277
+
278
+ .. code-block:: php
279
+
280
+ $r = $client->put('http://httpbin.org/put', ['json' => ['foo' => 'bar']]);
281
+
282
+ POST Requests
283
+ -------------
284
+
285
+ In addition to specifying the raw data of a request using the ``body`` request
286
+ option, Guzzle provides helpful abstractions over sending POST data.
287
+
288
+ Sending POST Fields
289
+ ~~~~~~~~~~~~~~~~~~~
290
+
291
+ Sending ``application/x-www-form-urlencoded`` POST requests requires that you
292
+ specify the body of a POST request as an array.
293
+
294
+ .. code-block:: php
295
+
296
+ $response = $client->post('http://httpbin.org/post', [
297
+ 'body' => [
298
+ 'field_name' => 'abc',
299
+ 'other_field' => '123'
300
+ ]
301
+ ]);
302
+
303
+ You can also build up POST requests before sending them.
304
+
305
+ .. code-block:: php
306
+
307
+ $request = $client->createRequest('POST', 'http://httpbin.org/post');
308
+ $postBody = $request->getBody();
309
+
310
+ // $postBody is an instance of GuzzleHttp\Post\PostBodyInterface
311
+ $postBody->setField('foo', 'bar');
312
+ echo $postBody->getField('foo');
313
+ // 'bar'
314
+
315
+ echo json_encode($postBody->getFields());
316
+ // {"foo": "bar"}
317
+
318
+ // Send the POST request
319
+ $response = $client->send($request);
320
+
321
+ Sending POST Files
322
+ ~~~~~~~~~~~~~~~~~~
323
+
324
+ Sending ``multipart/form-data`` POST requests (POST requests that contain
325
+ files) is the same as sending ``application/x-www-form-urlencoded``, except
326
+ some of the array values of the POST fields map to PHP ``fopen`` resources, or
327
+ ``GuzzleHttp\Stream\StreamInterface``, or
328
+ ``GuzzleHttp\Post\PostFileInterface`` objects.
329
+
330
+ .. code-block:: php
331
+
332
+ use GuzzleHttp\Post\PostFile;
333
+
334
+ $response = $client->post('http://httpbin.org/post', [
335
+ 'body' => [
336
+ 'field_name' => 'abc',
337
+ 'file_filed' => fopen('/path/to/file', 'r'),
338
+ 'other_file' => new PostFile('other_file', 'this is the content')
339
+ ]
340
+ ]);
341
+
342
+ Just like when sending POST fields, you can also build up POST requests with
343
+ files before sending them.
344
+
345
+ .. code-block:: php
346
+
347
+ use GuzzleHttp\Post\PostFile;
348
+
349
+ $request = $client->createRequest('POST', 'http://httpbin.org/post');
350
+ $postBody = $request->getBody();
351
+ $postBody->setField('foo', 'bar');
352
+ $postBody->addFile(new PostFile('test', fopen('/path/to/file', 'r')));
353
+ $response = $client->send($request);
354
+
355
+ Cookies
356
+ =======
357
+
358
+ Guzzle can maintain a cookie session for you if instructed using the
359
+ ``cookies`` request option.
360
+
361
+ - Set to ``true`` to use a shared cookie session associated with the client.
362
+ - Pass an associative array containing cookies to send in the request and start
363
+ a new cookie session.
364
+ - Set to a ``GuzzleHttp\Subscriber\CookieJar\CookieJarInterface`` object to use
365
+ an existing cookie jar.
366
+
367
+ Redirects
368
+ =========
369
+
370
+ Guzzle will automatically follow redirects unless you tell it not to. You can
371
+ customize the redirect behavior using the ``allow_redirects`` request option.
372
+
373
+ - Set to true to enable normal redirects with a maximum number of 5 redirects.
374
+ This is the default setting.
375
+ - Set to false to disable redirects.
376
+ - Pass an associative array containing the 'max' key to specify the maximum
377
+ number of redirects and optionally provide a 'strict' key value to specify
378
+ whether or not to use strict RFC compliant redirects (meaning redirect POST
379
+ requests with POST requests vs. doing what most browsers do which is
380
+ redirect POST requests with GET requests).
381
+
382
+ .. code-block:: php
383
+
384
+ $response = $client->get('http://github.com');
385
+ echo $response->getStatusCode();
386
+ // 200
387
+ echo $response->getEffectiveUrl();
388
+ // 'https://github.com/'
389
+
390
+ The following example shows that redirects can be disabled.
391
+
392
+ .. code-block:: php
393
+
394
+ $response = $client->get('http://github.com', ['allow_redirects' => false]);
395
+ echo $response->getStatusCode();
396
+ // 301
397
+ echo $response->getEffectiveUrl();
398
+ // 'http://github.com/'
399
+
400
+ Exceptions
401
+ ==========
402
+
403
+ Guzzle throws exceptions for errors that occur during a transfer.
404
+
405
+ - In the event of a networking error (connection timeout, DNS errors, etc.),
406
+ a ``GuzzleHttp\Exception\RequestException`` is thrown. This exception
407
+ extends from ``GuzzleHttp\Exception\TransferException``. Catching this
408
+ exception will catch any exception that can be thrown while transferring
409
+ (non-parallel) requests.
410
+
411
+ .. code-block:: php
412
+
413
+ use GuzzleHttp\Exception\RequestException;
414
+
415
+ try {
416
+ $client->get('https://github.com/_abc_123_404');
417
+ } catch (RequestException $e) {
418
+ echo $e->getRequest();
419
+ if ($e->hasResponse()) {
420
+ echo $e->getResponse();
421
+ }
422
+ }
423
+
424
+ - A ``GuzzleHttp\Exception\ClientException`` is thrown for 400
425
+ level errors if the ``exceptions`` request option is set to true. This
426
+ exception extends from ``GuzzleHttp\Exception\BadResponseException`` and
427
+ ``GuzzleHttp\Exception\BadResponseException`` extends from
428
+ ``GuzzleHttp\Exception\RequestException``.
429
+
430
+ .. code-block:: php
431
+
432
+ use GuzzleHttp\Exception\ClientException;
433
+
434
+ try {
435
+ $client->get('https://github.com/_abc_123_404');
436
+ } catch (ClientException $e) {
437
+ echo $e->getRequest();
438
+ echo $e->getResponse();
439
+ }
440
+
441
+ - A ``GuzzleHttp\Exception\ServerException`` is thrown for 500 level
442
+ errors if the ``exceptions`` request option is set to true. This
443
+ exception extends from ``GuzzleHttp\Exception\BadResponseException``.
444
+ - A ``GuzzleHttp\Exception\TooManyRedirectsException`` is thrown when too
445
+ many redirects are followed. This exception extends from ``GuzzleHttp\Exception\RequestException``.
446
+
447
+ All of the above exceptions extend from
448
+ ``GuzzleHttp\Exception\TransferException``.
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/docs/requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
1
+ Sphinx>=1.2b1
2
+ guzzle_sphinx_theme>=0.6.0
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/docs/streams.rst ADDED
@@ -0,0 +1,213 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ =======
2
+ Streams
3
+ =======
4
+
5
+ Guzzle uses stream objects to represent request and response message bodies.
6
+ These stream objects allow you to work with various types of data all using a
7
+ common interface.
8
+
9
+ HTTP messages consist of a start-line, headers, and a body. The body of an HTTP
10
+ message can be very small or extremely large. Attempting to represent the body
11
+ of a message as a string can easily consume more memory than intended because
12
+ the body must be stored completely in memory. Attempting to store the body of a
13
+ request or response in memory would preclude the use of that implementation from
14
+ being able to work with large message bodies. The StreamInterface is used in
15
+ order to hide the implementation details of where a stream of data is read from
16
+ or written to.
17
+
18
+ Guzzle's StreamInterface exposes several methods that enable streams to be read
19
+ from, written to, and traversed effectively.
20
+
21
+ Streams expose their capabilities using three methods: ``isReadable()``,
22
+ ``isWritable()``, and ``isSeekable()``. These methods can be used by stream
23
+ collaborators to determine if a stream is capable of their requirements.
24
+
25
+ Each stream instance has various capabilities: they can be read-only,
26
+ write-only, read-write, allow arbitrary random access (seeking forwards or
27
+ backwards to any location), or only allow sequential access (for example in the
28
+ case of a socket or pipe).
29
+
30
+ Creating Streams
31
+ ================
32
+
33
+ The best way to create a stream is using the static factory method,
34
+ ``GuzzleHttp\Stream\Stream::factory()``. This factory accepts strings,
35
+ resources returned from ``fopen()``, an object that implements
36
+ ``__toString()``, and an object that implements
37
+ ``GuzzleHttp\Stream\StreamInterface``.
38
+
39
+ .. code-block:: php
40
+
41
+ use GuzzleHttp\Stream\Stream;
42
+
43
+ $stream = Stream::factory('string data');
44
+ echo $stream;
45
+ // string data
46
+ echo $stream->read(3);
47
+ // str
48
+ echo $stream->getContents();
49
+ // ing data
50
+ var_export($stream->eof());
51
+ // true
52
+ var_export($stream->tell());
53
+ // 11
54
+
55
+ Metadata
56
+ ========
57
+
58
+ Guzzle streams expose stream metadata through the ``getMetadata()`` method.
59
+ This method provides the data you would retrieve when calling PHP's
60
+ `stream_get_meta_data() function <http://php.net/manual/en/function.stream-get-meta-data.php>`_,
61
+ and can optionally expose other custom data.
62
+
63
+ .. code-block:: php
64
+
65
+ use GuzzleHttp\Stream\Stream;
66
+
67
+ $resource = fopen('/path/to/file', 'r');
68
+ $stream = Stream::factory($resource);
69
+ echo $stream->getMetadata('uri');
70
+ // /path/to/file
71
+ var_export($stream->isReadable());
72
+ // true
73
+ var_export($stream->isWritable());
74
+ // false
75
+ var_export($stream->isSeekable());
76
+ // true
77
+
78
+ Stream Decorators
79
+ =================
80
+
81
+ With the small and focused interface, add custom functionality to streams is
82
+ very simple with stream decorators. Guzzle provides several built-in decorators
83
+ that provide additional stream functionality.
84
+
85
+ CachingStream
86
+ -------------
87
+
88
+ The CachingStream is used to allow seeking over previously read bytes on
89
+ non-seekable streams. This can be useful when transferring a non-seekable
90
+ entity body fails due to needing to rewind the stream (for example, resulting
91
+ from a redirect). Data that is read from the remote stream will be buffered in
92
+ a PHP temp stream so that previously read bytes are cached first in memory,
93
+ then on disk.
94
+
95
+ .. code-block:: php
96
+
97
+ use GuzzleHttp\Stream\Stream;
98
+ use GuzzleHttp\Stream\CachingStream;
99
+
100
+ $original = Stream::factory(fopen('http://www.google.com', 'r'));
101
+ $stream = new CachingStream($original);
102
+
103
+ $stream->read(1024);
104
+ echo $stream->tell();
105
+ // 1024
106
+
107
+ $stream->seek(0);
108
+ echo $stream->tell();
109
+ // 0
110
+
111
+ LimitStream
112
+ -----------
113
+
114
+ LimitStream can be used to read a subset or slice of an existing stream object.
115
+ This can be useful for breaking a large file into smaller pieces to be sent in
116
+ chunks (e.g. Amazon S3's multipart upload API).
117
+
118
+ .. code-block:: php
119
+
120
+ use GuzzleHttp\Stream\Stream;
121
+ use GuzzleHttp\Stream\LimitStream;
122
+
123
+ $original = Stream::factory(fopen('/tmp/test.txt', 'r+'));
124
+ echo $original->getSize();
125
+ // >>> 1048576
126
+
127
+ // Limit the size of the body to 1024 bytes and start reading from byte 2048
128
+ $stream = new LimitStream($original, 1024, 2048);
129
+ echo $stream->getSize();
130
+ // >>> 1024
131
+ echo $stream->tell();
132
+ // >>> 0
133
+
134
+ NoSeekStream
135
+ ------------
136
+
137
+ NoSeekStream wraps a stream and does not allow seeking.
138
+
139
+ .. code-block:: php
140
+
141
+ use GuzzleHttp\Stream\Stream;
142
+ use GuzzleHttp\Stream\LimitStream;
143
+
144
+ $original = Stream::factory('foo');
145
+ $noSeek = new NoSeekStream($original);
146
+
147
+ echo $noSeek->read(3);
148
+ // foo
149
+ var_export($noSeek->isSeekable());
150
+ // false
151
+ $noSeek->seek(0);
152
+ var_export($noSeek->read(3));
153
+ // NULL
154
+
155
+ Creating Custom Decorators
156
+ --------------------------
157
+
158
+ Creating a stream decorator is very easy thanks to the
159
+ ``GuzzleHttp\Stream\StreamDecoratorTrait``. This trait provides methods that
160
+ implement ``GuzzleHttp\Stream\StreamInterface`` by proxying to an underlying
161
+ stream. Just ``use`` the ``StreamDecoratorTrait`` and implement your custom
162
+ methods.
163
+
164
+ For example, let's say we wanted to call a specific function each time the last
165
+ byte is read from a stream. This could be implemented by overriding the
166
+ ``read()`` method.
167
+
168
+ .. code-block:: php
169
+
170
+ use GuzzleHttp\Stream\StreamDecoratorTrait;
171
+
172
+ class EofCallbackStream implements StreamInterface
173
+ {
174
+ use StreamDecoratorTrait;
175
+
176
+ private $callback;
177
+
178
+ public function __construct(StreamInterface $stream, callable $callback)
179
+ {
180
+ $this->stream = $stream;
181
+ $this->callback = $callback;
182
+ }
183
+
184
+ public function read($length)
185
+ {
186
+ $result = $this->stream->read($length);
187
+
188
+ // Invoke the callback when EOF is hit.
189
+ if ($this->eof()) {
190
+ call_user_func($this->callback);
191
+ }
192
+
193
+ return $result;
194
+ }
195
+ }
196
+
197
+ This decorator could be added to any existing stream and used like so:
198
+
199
+ .. code-block:: php
200
+
201
+ use GuzzleHttp\Stream\Stream;
202
+
203
+ $original = Stream::factory('foo');
204
+ $eofStream = new EofCallbackStream($original, function () {
205
+ echo 'EOF!';
206
+ });
207
+
208
+ $eofStream->read(2);
209
+ $eofStream->read(1);
210
+ // echoes "EOF!"
211
+ $eofStream->seek(0);
212
+ $eofStream->read(3);
213
+ // echoes "EOF!"
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/docs/testing.rst ADDED
@@ -0,0 +1,232 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ======================
2
+ Testing Guzzle Clients
3
+ ======================
4
+
5
+ Guzzle provides several tools that will enable you to easily mock the HTTP
6
+ layer without needing to send requests over the internet.
7
+
8
+ * Mock subscriber
9
+ * Mock handler
10
+ * Node.js web server for integration testing
11
+
12
+ Mock Subscriber
13
+ ===============
14
+
15
+ When testing HTTP clients, you often need to simulate specific scenarios like
16
+ returning a successful response, returning an error, or returning specific
17
+ responses in a certain order. Because unit tests need to be predictable, easy
18
+ to bootstrap, and fast, hitting an actual remote API is a test smell.
19
+
20
+ Guzzle provides a mock subscriber that can be attached to clients or requests
21
+ that allows you to queue up a list of responses to use rather than hitting a
22
+ remote API.
23
+
24
+ .. code-block:: php
25
+
26
+ use GuzzleHttp\Client;
27
+ use GuzzleHttp\Subscriber\Mock;
28
+ use GuzzleHttp\Message\Response;
29
+
30
+ $client = new Client();
31
+
32
+ // Create a mock subscriber and queue two responses.
33
+ $mock = new Mock([
34
+ new Response(200, ['X-Foo' => 'Bar']), // Use response object
35
+ "HTTP/1.1 202 OK\r\nContent-Length: 0\r\n\r\n" // Use a response string
36
+ ]);
37
+
38
+ // Add the mock subscriber to the client.
39
+ $client->getEmitter()->attach($mock);
40
+ // The first request is intercepted with the first response.
41
+ echo $client->get('/')->getStatusCode();
42
+ //> 200
43
+ // The second request is intercepted with the second response.
44
+ echo $client->get('/')->getStatusCode();
45
+ //> 202
46
+
47
+ When no more responses are in the queue and a request is sent, an
48
+ ``OutOfBoundsException`` is thrown.
49
+
50
+ History Subscriber
51
+ ==================
52
+
53
+ When using things like the ``Mock`` subscriber, you often need to know if the
54
+ requests you expected to send were sent exactly as you intended. While the mock
55
+ subscriber responds with mocked responses, the ``GuzzleHttp\Subscriber\History``
56
+ subscriber maintains a history of the requests that were sent by a client.
57
+
58
+ .. code-block:: php
59
+
60
+ use GuzzleHttp\Client;
61
+ use GuzzleHttp\Subscriber\History;
62
+
63
+ $client = new Client();
64
+ $history = new History();
65
+
66
+ // Add the history subscriber to the client.
67
+ $client->getEmitter()->attach($history);
68
+
69
+ $client->get('http://httpbin.org/get');
70
+ $client->head('http://httpbin.org/get');
71
+
72
+ // Count the number of transactions
73
+ echo count($history);
74
+ //> 2
75
+ // Get the last request
76
+ $lastRequest = $history->getLastRequest();
77
+ // Get the last response
78
+ $lastResponse = $history->getLastResponse();
79
+
80
+ // Iterate over the transactions that were sent
81
+ foreach ($history as $transaction) {
82
+ echo $transaction['request']->getMethod();
83
+ //> GET, HEAD
84
+ echo $transaction['response']->getStatusCode();
85
+ //> 200, 200
86
+ }
87
+
88
+ The history subscriber can also be printed, revealing the requests and
89
+ responses that were sent as a string, in order.
90
+
91
+ .. code-block:: php
92
+
93
+ echo $history;
94
+
95
+ ::
96
+
97
+ > GET /get HTTP/1.1
98
+ Host: httpbin.org
99
+ User-Agent: Guzzle/4.0-dev curl/7.21.4 PHP/5.5.8
100
+
101
+ < HTTP/1.1 200 OK
102
+ Access-Control-Allow-Origin: *
103
+ Content-Type: application/json
104
+ Date: Tue, 25 Mar 2014 03:53:27 GMT
105
+ Server: gunicorn/0.17.4
106
+ Content-Length: 270
107
+ Connection: keep-alive
108
+
109
+ {
110
+ "headers": {
111
+ "Connection": "close",
112
+ "X-Request-Id": "3d0f7d5c-c937-4394-8248-2b8e03fcccdb",
113
+ "User-Agent": "Guzzle/4.0-dev curl/7.21.4 PHP/5.5.8",
114
+ "Host": "httpbin.org"
115
+ },
116
+ "origin": "76.104.247.1",
117
+ "args": {},
118
+ "url": "http://httpbin.org/get"
119
+ }
120
+
121
+ > HEAD /get HTTP/1.1
122
+ Host: httpbin.org
123
+ User-Agent: Guzzle/4.0-dev curl/7.21.4 PHP/5.5.8
124
+
125
+ < HTTP/1.1 200 OK
126
+ Access-Control-Allow-Origin: *
127
+ Content-length: 270
128
+ Content-Type: application/json
129
+ Date: Tue, 25 Mar 2014 03:53:27 GMT
130
+ Server: gunicorn/0.17.4
131
+ Connection: keep-alive
132
+
133
+ Mock Adapter
134
+ ============
135
+
136
+ In addition to using the Mock subscriber, you can use the
137
+ ``GuzzleHttp\Ring\Client\MockHandler`` as the handler of a client to return the
138
+ same response over and over or return the result of a callable function.
139
+
140
+ Test Web Server
141
+ ===============
142
+
143
+ Using mock responses is almost always enough when testing a web service client.
144
+ When implementing custom :doc:`HTTP handlers <handlers>`, you'll need to send
145
+ actual HTTP requests in order to sufficiently test the handler. However, a
146
+ best practice is to contact a local web server rather than a server over the
147
+ internet.
148
+
149
+ - Tests are more reliable
150
+ - Tests do not require a network connection
151
+ - Tests have no external dependencies
152
+
153
+ Using the test server
154
+ ---------------------
155
+
156
+ .. warning::
157
+
158
+ The following functionality is provided to help developers of Guzzle
159
+ develop HTTP handlers. There is no promise of backwards compatibility
160
+ when it comes to the node.js test server or the ``GuzzleHttp\Tests\Server``
161
+ class. If you are using the test server or ``Server`` class outside of
162
+ guzzlehttp/guzzle, then you will need to configure autoloading and
163
+ ensure the web server is started manually.
164
+
165
+ .. hint::
166
+
167
+ You almost never need to use this test web server. You should only ever
168
+ consider using it when developing HTTP handlers. The test web server
169
+ is not necessary for mocking requests. For that, please use the
170
+ Mock subcribers and History subscriber.
171
+
172
+ Guzzle ships with a node.js test server that receives requests and returns
173
+ responses from a queue. The test server exposes a simple API that is used to
174
+ enqueue responses and inspect the requests that it has received.
175
+
176
+ Any operation on the ``Server`` object will ensure that
177
+ the server is running and wait until it is able to receive requests before
178
+ returning.
179
+
180
+ .. code-block:: php
181
+
182
+ use GuzzleHttp\Client;
183
+ use GuzzleHttp\Tests\Server;
184
+
185
+ // Start the server and queue a response
186
+ Server::enqueue("HTTP/1.1 200 OK\r\n\Content-Length: 0r\n\r\n");
187
+
188
+ $client = new Client(['base_url' => Server::$url]);
189
+ echo $client->get('/foo')->getStatusCode();
190
+ // 200
191
+
192
+ ``GuzzleHttp\Tests\Server`` provides a static interface to the test server. You
193
+ can queue an HTTP response or an array of responses by calling
194
+ ``Server::enqueue()``. This method accepts a string representing an HTTP
195
+ response message, a ``GuzzleHttp\Message\ResponseInterface``, or an array of
196
+ HTTP message strings / ``GuzzleHttp\Message\ResponseInterface`` objects.
197
+
198
+ .. code-block:: php
199
+
200
+ // Queue single response
201
+ Server::enqueue("HTTP/1.1 200 OK\r\n\Content-Length: 0r\n\r\n");
202
+
203
+ // Clear the queue and queue an array of responses
204
+ Server::enqueue([
205
+ "HTTP/1.1 200 OK\r\n\Content-Length: 0r\n\r\n",
206
+ "HTTP/1.1 404 Not Found\r\n\Content-Length: 0r\n\r\n"
207
+ ]);
208
+
209
+ When a response is queued on the test server, the test server will remove any
210
+ previously queued responses. As the server receives requests, queued responses
211
+ are dequeued and returned to the request. When the queue is empty, the server
212
+ will return a 500 response.
213
+
214
+ You can inspect the requests that the server has retrieved by calling
215
+ ``Server::received()``. This method accepts an optional ``$hydrate`` parameter
216
+ that specifies if you are retrieving an array of HTTP requests as strings or an
217
+ array of ``GuzzleHttp\Message\RequestInterface`` objects.
218
+
219
+ .. code-block:: php
220
+
221
+ foreach (Server::received() as $response) {
222
+ echo $response;
223
+ }
224
+
225
+ You can clear the list of received requests from the web server using the
226
+ ``Server::flush()`` method.
227
+
228
+ .. code-block:: php
229
+
230
+ Server::flush();
231
+ echo count(Server::received());
232
+ // 0
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/phpunit.xml.dist ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <phpunit bootstrap="./tests/bootstrap.php"
3
+ colors="true">
4
+ <testsuites>
5
+ <testsuite>
6
+ <directory>tests</directory>
7
+ </testsuite>
8
+ </testsuites>
9
+ <filter>
10
+ <whitelist>
11
+ <directory suffix=".php">src</directory>
12
+ <exclude>
13
+ <directory suffix="Interface.php">src/</directory>
14
+ </exclude>
15
+ </whitelist>
16
+ </filter>
17
+ </phpunit>
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/BatchResults.php ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ /**
5
+ * Represents the result of a batch operation. This result container is
6
+ * iterable, countable, and you can can get a result by value using the
7
+ * getResult function.
8
+ *
9
+ * Successful results are anything other than exceptions. Failure results are
10
+ * exceptions.
11
+ *
12
+ * @package GuzzleHttp
13
+ */
14
+ class BatchResults implements \Countable, \IteratorAggregate, \ArrayAccess
15
+ {
16
+ private $hash;
17
+
18
+ /**
19
+ * @param \SplObjectStorage $hash Hash of key objects to result values.
20
+ */
21
+ public function __construct(\SplObjectStorage $hash)
22
+ {
23
+ $this->hash = $hash;
24
+ }
25
+
26
+ /**
27
+ * Get the keys that are available on the batch result.
28
+ *
29
+ * @return array
30
+ */
31
+ public function getKeys()
32
+ {
33
+ return iterator_to_array($this->hash);
34
+ }
35
+
36
+ /**
37
+ * Gets a result from the container for the given object. When getting
38
+ * results for a batch of requests, provide the request object.
39
+ *
40
+ * @param object $forObject Object to retrieve the result for.
41
+ *
42
+ * @return mixed|null
43
+ */
44
+ public function getResult($forObject)
45
+ {
46
+ return isset($this->hash[$forObject]) ? $this->hash[$forObject] : null;
47
+ }
48
+
49
+ /**
50
+ * Get an array of successful results.
51
+ *
52
+ * @return array
53
+ */
54
+ public function getSuccessful()
55
+ {
56
+ $results = [];
57
+ foreach ($this->hash as $key) {
58
+ if (!($this->hash[$key] instanceof \Exception)) {
59
+ $results[] = $this->hash[$key];
60
+ }
61
+ }
62
+
63
+ return $results;
64
+ }
65
+
66
+ /**
67
+ * Get an array of failed results.
68
+ *
69
+ * @return array
70
+ */
71
+ public function getFailures()
72
+ {
73
+ $results = [];
74
+ foreach ($this->hash as $key) {
75
+ if ($this->hash[$key] instanceof \Exception) {
76
+ $results[] = $this->hash[$key];
77
+ }
78
+ }
79
+
80
+ return $results;
81
+ }
82
+
83
+ /**
84
+ * Allows iteration over all batch result values.
85
+ *
86
+ * @return \ArrayIterator
87
+ */
88
+ public function getIterator()
89
+ {
90
+ $results = [];
91
+ foreach ($this->hash as $key) {
92
+ $results[] = $this->hash[$key];
93
+ }
94
+
95
+ return new \ArrayIterator($results);
96
+ }
97
+
98
+ /**
99
+ * Counts the number of elements in the batch result.
100
+ *
101
+ * @return int
102
+ */
103
+ public function count()
104
+ {
105
+ return count($this->hash);
106
+ }
107
+
108
+ /**
109
+ * Checks if the batch contains a specific numerical array index.
110
+ *
111
+ * @param int $key Index to access
112
+ *
113
+ * @return bool
114
+ */
115
+ public function offsetExists($key)
116
+ {
117
+ return $key < count($this->hash);
118
+ }
119
+
120
+ /**
121
+ * Allows access of the batch using a numerical array index.
122
+ *
123
+ * @param int $key Index to access.
124
+ *
125
+ * @return mixed|null
126
+ */
127
+ public function offsetGet($key)
128
+ {
129
+ $i = -1;
130
+ foreach ($this->hash as $obj) {
131
+ if ($key === ++$i) {
132
+ return $this->hash[$obj];
133
+ }
134
+ }
135
+
136
+ return null;
137
+ }
138
+
139
+ public function offsetUnset($key)
140
+ {
141
+ throw new \RuntimeException('Not implemented');
142
+ }
143
+
144
+ public function offsetSet($key, $value)
145
+ {
146
+ throw new \RuntimeException('Not implemented');
147
+ }
148
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Client.php ADDED
@@ -0,0 +1,352 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ use GuzzleHttp\Event\HasEmitterTrait;
5
+ use GuzzleHttp\Message\MessageFactory;
6
+ use GuzzleHttp\Message\MessageFactoryInterface;
7
+ use GuzzleHttp\Message\RequestInterface;
8
+ use GuzzleHttp\Message\FutureResponse;
9
+ use GuzzleHttp\Ring\Core;
10
+ use GuzzleHttp\Ring\Future\FutureInterface;
11
+ use GuzzleHttp\Exception\RequestException;
12
+ use React\Promise\FulfilledPromise;
13
+ use React\Promise\RejectedPromise;
14
+
15
+ /**
16
+ * HTTP client
17
+ */
18
+ class Client implements ClientInterface
19
+ {
20
+ use HasEmitterTrait;
21
+
22
+ /** @var MessageFactoryInterface Request factory used by the client */
23
+ private $messageFactory;
24
+
25
+ /** @var Url Base URL of the client */
26
+ private $baseUrl;
27
+
28
+ /** @var array Default request options */
29
+ private $defaults;
30
+
31
+ /** @var callable Request state machine */
32
+ private $fsm;
33
+
34
+ /**
35
+ * Clients accept an array of constructor parameters.
36
+ *
37
+ * Here's an example of creating a client using an URI template for the
38
+ * client's base_url and an array of default request options to apply
39
+ * to each request:
40
+ *
41
+ * $client = new Client([
42
+ * 'base_url' => [
43
+ * 'http://www.foo.com/{version}/',
44
+ * ['version' => '123']
45
+ * ],
46
+ * 'defaults' => [
47
+ * 'timeout' => 10,
48
+ * 'allow_redirects' => false,
49
+ * 'proxy' => '192.168.16.1:10'
50
+ * ]
51
+ * ]);
52
+ *
53
+ * @param array $config Client configuration settings
54
+ * - base_url: Base URL of the client that is merged into relative URLs.
55
+ * Can be a string or an array that contains a URI template followed
56
+ * by an associative array of expansion variables to inject into the
57
+ * URI template.
58
+ * - handler: callable RingPHP handler used to transfer requests
59
+ * - message_factory: Factory used to create request and response object
60
+ * - defaults: Default request options to apply to each request
61
+ * - emitter: Event emitter used for request events
62
+ * - fsm: (internal use only) The request finite state machine. A
63
+ * function that accepts a transaction and optional final state. The
64
+ * function is responsible for transitioning a request through its
65
+ * lifecycle events.
66
+ */
67
+ public function __construct(array $config = [])
68
+ {
69
+ $this->configureBaseUrl($config);
70
+ $this->configureDefaults($config);
71
+
72
+ if (isset($config['emitter'])) {
73
+ $this->emitter = $config['emitter'];
74
+ }
75
+
76
+ $this->messageFactory = isset($config['message_factory'])
77
+ ? $config['message_factory']
78
+ : new MessageFactory();
79
+
80
+ if (isset($config['fsm'])) {
81
+ $this->fsm = $config['fsm'];
82
+ } else {
83
+ if (isset($config['handler'])) {
84
+ $handler = $config['handler'];
85
+ } elseif (isset($config['adapter'])) {
86
+ $handler = $config['adapter'];
87
+ } else {
88
+ $handler = Utils::getDefaultHandler();
89
+ }
90
+ $this->fsm = new RequestFsm($handler, $this->messageFactory);
91
+ }
92
+ }
93
+
94
+ public function getDefaultOption($keyOrPath = null)
95
+ {
96
+ return $keyOrPath === null
97
+ ? $this->defaults
98
+ : Utils::getPath($this->defaults, $keyOrPath);
99
+ }
100
+
101
+ public function setDefaultOption($keyOrPath, $value)
102
+ {
103
+ Utils::setPath($this->defaults, $keyOrPath, $value);
104
+ }
105
+
106
+ public function getBaseUrl()
107
+ {
108
+ return (string) $this->baseUrl;
109
+ }
110
+
111
+ public function createRequest($method, $url = null, array $options = [])
112
+ {
113
+ $options = $this->mergeDefaults($options);
114
+ // Use a clone of the client's emitter
115
+ $options['config']['emitter'] = clone $this->getEmitter();
116
+ $url = $url || (is_string($url) && strlen($url))
117
+ ? $this->buildUrl($url)
118
+ : (string) $this->baseUrl;
119
+
120
+ return $this->messageFactory->createRequest($method, $url, $options);
121
+ }
122
+
123
+ public function get($url = null, $options = [])
124
+ {
125
+ return $this->send($this->createRequest('GET', $url, $options));
126
+ }
127
+
128
+ public function head($url = null, array $options = [])
129
+ {
130
+ return $this->send($this->createRequest('HEAD', $url, $options));
131
+ }
132
+
133
+ public function delete($url = null, array $options = [])
134
+ {
135
+ return $this->send($this->createRequest('DELETE', $url, $options));
136
+ }
137
+
138
+ public function put($url = null, array $options = [])
139
+ {
140
+ return $this->send($this->createRequest('PUT', $url, $options));
141
+ }
142
+
143
+ public function patch($url = null, array $options = [])
144
+ {
145
+ return $this->send($this->createRequest('PATCH', $url, $options));
146
+ }
147
+
148
+ public function post($url = null, array $options = [])
149
+ {
150
+ return $this->send($this->createRequest('POST', $url, $options));
151
+ }
152
+
153
+ public function options($url = null, array $options = [])
154
+ {
155
+ return $this->send($this->createRequest('OPTIONS', $url, $options));
156
+ }
157
+
158
+ public function send(RequestInterface $request)
159
+ {
160
+ $isFuture = $request->getConfig()->get('future');
161
+ $trans = new Transaction($this, $request, $isFuture);
162
+ $fn = $this->fsm;
163
+
164
+ try {
165
+ $fn($trans);
166
+ if ($isFuture) {
167
+ // Turn the normal response into a future if needed.
168
+ return $trans->response instanceof FutureInterface
169
+ ? $trans->response
170
+ : new FutureResponse(new FulfilledPromise($trans->response));
171
+ }
172
+ // Resolve deep futures if this is not a future
173
+ // transaction. This accounts for things like retries
174
+ // that do not have an immediate side-effect.
175
+ while ($trans->response instanceof FutureInterface) {
176
+ $trans->response = $trans->response->wait();
177
+ }
178
+ return $trans->response;
179
+ } catch (\Exception $e) {
180
+ if ($isFuture) {
181
+ // Wrap the exception in a promise
182
+ return new FutureResponse(new RejectedPromise($e));
183
+ }
184
+ throw RequestException::wrapException($trans->request, $e);
185
+ }
186
+ }
187
+
188
+ /**
189
+ * Get an array of default options to apply to the client
190
+ *
191
+ * @return array
192
+ */
193
+ protected function getDefaultOptions()
194
+ {
195
+ $settings = [
196
+ 'allow_redirects' => true,
197
+ 'exceptions' => true,
198
+ 'decode_content' => true,
199
+ 'verify' => true
200
+ ];
201
+
202
+ // Use the standard Linux HTTP_PROXY and HTTPS_PROXY if set
203
+ if ($proxy = getenv('HTTP_PROXY')) {
204
+ $settings['proxy']['http'] = $proxy;
205
+ }
206
+
207
+ if ($proxy = getenv('HTTPS_PROXY')) {
208
+ $settings['proxy']['https'] = $proxy;
209
+ }
210
+
211
+ return $settings;
212
+ }
213
+
214
+ /**
215
+ * Expand a URI template and inherit from the base URL if it's relative
216
+ *
217
+ * @param string|array $url URL or an array of the URI template to expand
218
+ * followed by a hash of template varnames.
219
+ * @return string
220
+ * @throws \InvalidArgumentException
221
+ */
222
+ private function buildUrl($url)
223
+ {
224
+ // URI template (absolute or relative)
225
+ if (!is_array($url)) {
226
+ return strpos($url, '://')
227
+ ? (string) $url
228
+ : (string) $this->baseUrl->combine($url);
229
+ }
230
+
231
+ if (!isset($url[1])) {
232
+ throw new \InvalidArgumentException('You must provide a hash of '
233
+ . 'varname options in the second element of a URL array.');
234
+ }
235
+
236
+ // Absolute URL
237
+ if (strpos($url[0], '://')) {
238
+ return Utils::uriTemplate($url[0], $url[1]);
239
+ }
240
+
241
+ // Combine the relative URL with the base URL
242
+ return (string) $this->baseUrl->combine(
243
+ Utils::uriTemplate($url[0], $url[1])
244
+ );
245
+ }
246
+
247
+ private function configureBaseUrl(&$config)
248
+ {
249
+ if (!isset($config['base_url'])) {
250
+ $this->baseUrl = new Url('', '');
251
+ } elseif (!is_array($config['base_url'])) {
252
+ $this->baseUrl = Url::fromString($config['base_url']);
253
+ } elseif (count($config['base_url']) < 2) {
254
+ throw new \InvalidArgumentException('You must provide a hash of '
255
+ . 'varname options in the second element of a base_url array.');
256
+ } else {
257
+ $this->baseUrl = Url::fromString(
258
+ Utils::uriTemplate(
259
+ $config['base_url'][0],
260
+ $config['base_url'][1]
261
+ )
262
+ );
263
+ $config['base_url'] = (string) $this->baseUrl;
264
+ }
265
+ }
266
+
267
+ private function configureDefaults($config)
268
+ {
269
+ if (!isset($config['defaults'])) {
270
+ $this->defaults = $this->getDefaultOptions();
271
+ } else {
272
+ $this->defaults = array_replace(
273
+ $this->getDefaultOptions(),
274
+ $config['defaults']
275
+ );
276
+ }
277
+
278
+ // Add the default user-agent header
279
+ if (!isset($this->defaults['headers'])) {
280
+ $this->defaults['headers'] = [
281
+ 'User-Agent' => Utils::getDefaultUserAgent()
282
+ ];
283
+ } elseif (!Core::hasHeader($this->defaults, 'User-Agent')) {
284
+ // Add the User-Agent header if one was not already set
285
+ $this->defaults['headers']['User-Agent'] = Utils::getDefaultUserAgent();
286
+ }
287
+ }
288
+
289
+ /**
290
+ * Merges default options into the array passed by reference.
291
+ *
292
+ * @param array $options Options to modify by reference
293
+ *
294
+ * @return array
295
+ */
296
+ private function mergeDefaults($options)
297
+ {
298
+ $defaults = $this->defaults;
299
+
300
+ // Case-insensitively merge in default headers if both defaults and
301
+ // options have headers specified.
302
+ if (!empty($defaults['headers']) && !empty($options['headers'])) {
303
+ // Create a set of lowercased keys that are present.
304
+ $lkeys = [];
305
+ foreach (array_keys($options['headers']) as $k) {
306
+ $lkeys[strtolower($k)] = true;
307
+ }
308
+ // Merge in lowercase default keys when not present in above set.
309
+ foreach ($defaults['headers'] as $key => $value) {
310
+ if (!isset($lkeys[strtolower($key)])) {
311
+ $options['headers'][$key] = $value;
312
+ }
313
+ }
314
+ // No longer need to merge in headers.
315
+ unset($defaults['headers']);
316
+ }
317
+
318
+ $result = array_replace_recursive($defaults, $options);
319
+ foreach ($options as $k => $v) {
320
+ if ($v === null) {
321
+ unset($result[$k]);
322
+ }
323
+ }
324
+
325
+ return $result;
326
+ }
327
+
328
+ /**
329
+ * @deprecated Use {@see GuzzleHttp\Pool} instead.
330
+ * @see GuzzleHttp\Pool
331
+ */
332
+ public function sendAll($requests, array $options = [])
333
+ {
334
+ Pool::send($this, $requests, $options);
335
+ }
336
+
337
+ /**
338
+ * @deprecated Use GuzzleHttp\Utils::getDefaultHandler
339
+ */
340
+ public static function getDefaultHandler()
341
+ {
342
+ return Utils::getDefaultHandler();
343
+ }
344
+
345
+ /**
346
+ * @deprecated Use GuzzleHttp\Utils::getDefaultUserAgent
347
+ */
348
+ public static function getDefaultUserAgent()
349
+ {
350
+ return Utils::getDefaultUserAgent();
351
+ }
352
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/ClientInterface.php ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ use GuzzleHttp\Event\HasEmitterInterface;
5
+ use GuzzleHttp\Exception\RequestException;
6
+ use GuzzleHttp\Message\RequestInterface;
7
+ use GuzzleHttp\Message\ResponseInterface;
8
+
9
+ /**
10
+ * Client interface for sending HTTP requests
11
+ */
12
+ interface ClientInterface extends HasEmitterInterface
13
+ {
14
+ const VERSION = '5.3.0';
15
+
16
+ /**
17
+ * Create and return a new {@see RequestInterface} object.
18
+ *
19
+ * Use an absolute path to override the base path of the client, or a
20
+ * relative path to append to the base path of the client. The URL can
21
+ * contain the query string as well. Use an array to provide a URL
22
+ * template and additional variables to use in the URL template expansion.
23
+ *
24
+ * @param string $method HTTP method
25
+ * @param string|array|Url $url URL or URI template
26
+ * @param array $options Array of request options to apply.
27
+ *
28
+ * @return RequestInterface
29
+ */
30
+ public function createRequest($method, $url = null, array $options = []);
31
+
32
+ /**
33
+ * Send a GET request
34
+ *
35
+ * @param string|array|Url $url URL or URI template
36
+ * @param array $options Array of request options to apply.
37
+ *
38
+ * @return ResponseInterface
39
+ * @throws RequestException When an error is encountered
40
+ */
41
+ public function get($url = null, $options = []);
42
+
43
+ /**
44
+ * Send a HEAD request
45
+ *
46
+ * @param string|array|Url $url URL or URI template
47
+ * @param array $options Array of request options to apply.
48
+ *
49
+ * @return ResponseInterface
50
+ * @throws RequestException When an error is encountered
51
+ */
52
+ public function head($url = null, array $options = []);
53
+
54
+ /**
55
+ * Send a DELETE request
56
+ *
57
+ * @param string|array|Url $url URL or URI template
58
+ * @param array $options Array of request options to apply.
59
+ *
60
+ * @return ResponseInterface
61
+ * @throws RequestException When an error is encountered
62
+ */
63
+ public function delete($url = null, array $options = []);
64
+
65
+ /**
66
+ * Send a PUT request
67
+ *
68
+ * @param string|array|Url $url URL or URI template
69
+ * @param array $options Array of request options to apply.
70
+ *
71
+ * @return ResponseInterface
72
+ * @throws RequestException When an error is encountered
73
+ */
74
+ public function put($url = null, array $options = []);
75
+
76
+ /**
77
+ * Send a PATCH request
78
+ *
79
+ * @param string|array|Url $url URL or URI template
80
+ * @param array $options Array of request options to apply.
81
+ *
82
+ * @return ResponseInterface
83
+ * @throws RequestException When an error is encountered
84
+ */
85
+ public function patch($url = null, array $options = []);
86
+
87
+ /**
88
+ * Send a POST request
89
+ *
90
+ * @param string|array|Url $url URL or URI template
91
+ * @param array $options Array of request options to apply.
92
+ *
93
+ * @return ResponseInterface
94
+ * @throws RequestException When an error is encountered
95
+ */
96
+ public function post($url = null, array $options = []);
97
+
98
+ /**
99
+ * Send an OPTIONS request
100
+ *
101
+ * @param string|array|Url $url URL or URI template
102
+ * @param array $options Array of request options to apply.
103
+ *
104
+ * @return ResponseInterface
105
+ * @throws RequestException When an error is encountered
106
+ */
107
+ public function options($url = null, array $options = []);
108
+
109
+ /**
110
+ * Sends a single request
111
+ *
112
+ * @param RequestInterface $request Request to send
113
+ *
114
+ * @return \GuzzleHttp\Message\ResponseInterface
115
+ * @throws \LogicException When the handler does not populate a response
116
+ * @throws RequestException When an error is encountered
117
+ */
118
+ public function send(RequestInterface $request);
119
+
120
+ /**
121
+ * Get default request options of the client.
122
+ *
123
+ * @param string|null $keyOrPath The Path to a particular default request
124
+ * option to retrieve or pass null to retrieve all default request
125
+ * options. The syntax uses "/" to denote a path through nested PHP
126
+ * arrays. For example, "headers/content-type".
127
+ *
128
+ * @return mixed
129
+ */
130
+ public function getDefaultOption($keyOrPath = null);
131
+
132
+ /**
133
+ * Set a default request option on the client so that any request created
134
+ * by the client will use the provided default value unless overridden
135
+ * explicitly when creating a request.
136
+ *
137
+ * @param string|null $keyOrPath The Path to a particular configuration
138
+ * value to set. The syntax uses a path notation that allows you to
139
+ * specify nested configuration values (e.g., 'headers/content-type').
140
+ * @param mixed $value Default request option value to set
141
+ */
142
+ public function setDefaultOption($keyOrPath, $value);
143
+
144
+ /**
145
+ * Get the base URL of the client.
146
+ *
147
+ * @return string Returns the base URL if present
148
+ */
149
+ public function getBaseUrl();
150
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Collection.php ADDED
@@ -0,0 +1,236 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ /**
5
+ * Key value pair collection object
6
+ */
7
+ class Collection implements
8
+ \ArrayAccess,
9
+ \IteratorAggregate,
10
+ \Countable,
11
+ ToArrayInterface
12
+ {
13
+ use HasDataTrait;
14
+
15
+ /**
16
+ * @param array $data Associative array of data to set
17
+ */
18
+ public function __construct(array $data = [])
19
+ {
20
+ $this->data = $data;
21
+ }
22
+
23
+ /**
24
+ * Create a new collection from an array, validate the keys, and add default
25
+ * values where missing
26
+ *
27
+ * @param array $config Configuration values to apply.
28
+ * @param array $defaults Default parameters
29
+ * @param array $required Required parameter names
30
+ *
31
+ * @return self
32
+ * @throws \InvalidArgumentException if a parameter is missing
33
+ */
34
+ public static function fromConfig(
35
+ array $config = [],
36
+ array $defaults = [],
37
+ array $required = []
38
+ ) {
39
+ $data = $config + $defaults;
40
+
41
+ if ($missing = array_diff($required, array_keys($data))) {
42
+ throw new \InvalidArgumentException(
43
+ 'Config is missing the following keys: ' .
44
+ implode(', ', $missing));
45
+ }
46
+
47
+ return new self($data);
48
+ }
49
+
50
+ /**
51
+ * Removes all key value pairs
52
+ */
53
+ public function clear()
54
+ {
55
+ $this->data = [];
56
+ }
57
+
58
+ /**
59
+ * Get a specific key value.
60
+ *
61
+ * @param string $key Key to retrieve.
62
+ *
63
+ * @return mixed|null Value of the key or NULL
64
+ */
65
+ public function get($key)
66
+ {
67
+ return isset($this->data[$key]) ? $this->data[$key] : null;
68
+ }
69
+
70
+ /**
71
+ * Set a key value pair
72
+ *
73
+ * @param string $key Key to set
74
+ * @param mixed $value Value to set
75
+ */
76
+ public function set($key, $value)
77
+ {
78
+ $this->data[$key] = $value;
79
+ }
80
+
81
+ /**
82
+ * Add a value to a key. If a key of the same name has already been added,
83
+ * the key value will be converted into an array and the new value will be
84
+ * pushed to the end of the array.
85
+ *
86
+ * @param string $key Key to add
87
+ * @param mixed $value Value to add to the key
88
+ */
89
+ public function add($key, $value)
90
+ {
91
+ if (!array_key_exists($key, $this->data)) {
92
+ $this->data[$key] = $value;
93
+ } elseif (is_array($this->data[$key])) {
94
+ $this->data[$key][] = $value;
95
+ } else {
96
+ $this->data[$key] = array($this->data[$key], $value);
97
+ }
98
+ }
99
+
100
+ /**
101
+ * Remove a specific key value pair
102
+ *
103
+ * @param string $key A key to remove
104
+ */
105
+ public function remove($key)
106
+ {
107
+ unset($this->data[$key]);
108
+ }
109
+
110
+ /**
111
+ * Get all keys in the collection
112
+ *
113
+ * @return array
114
+ */
115
+ public function getKeys()
116
+ {
117
+ return array_keys($this->data);
118
+ }
119
+
120
+ /**
121
+ * Returns whether or not the specified key is present.
122
+ *
123
+ * @param string $key The key for which to check the existence.
124
+ *
125
+ * @return bool
126
+ */
127
+ public function hasKey($key)
128
+ {
129
+ return array_key_exists($key, $this->data);
130
+ }
131
+
132
+ /**
133
+ * Checks if any keys contains a certain value
134
+ *
135
+ * @param string $value Value to search for
136
+ *
137
+ * @return mixed Returns the key if the value was found FALSE if the value
138
+ * was not found.
139
+ */
140
+ public function hasValue($value)
141
+ {
142
+ return array_search($value, $this->data, true);
143
+ }
144
+
145
+ /**
146
+ * Replace the data of the object with the value of an array
147
+ *
148
+ * @param array $data Associative array of data
149
+ */
150
+ public function replace(array $data)
151
+ {
152
+ $this->data = $data;
153
+ }
154
+
155
+ /**
156
+ * Add and merge in a Collection or array of key value pair data.
157
+ *
158
+ * @param Collection|array $data Associative array of key value pair data
159
+ */
160
+ public function merge($data)
161
+ {
162
+ foreach ($data as $key => $value) {
163
+ $this->add($key, $value);
164
+ }
165
+ }
166
+
167
+ /**
168
+ * Overwrite key value pairs in this collection with all of the data from
169
+ * an array or collection.
170
+ *
171
+ * @param array|\Traversable $data Values to override over this config
172
+ */
173
+ public function overwriteWith($data)
174
+ {
175
+ if (is_array($data)) {
176
+ $this->data = $data + $this->data;
177
+ } elseif ($data instanceof Collection) {
178
+ $this->data = $data->toArray() + $this->data;
179
+ } else {
180
+ foreach ($data as $key => $value) {
181
+ $this->data[$key] = $value;
182
+ }
183
+ }
184
+ }
185
+
186
+ /**
187
+ * Returns a Collection containing all the elements of the collection after
188
+ * applying the callback function to each one.
189
+ *
190
+ * The callable should accept three arguments:
191
+ * - (string) $key
192
+ * - (string) $value
193
+ * - (array) $context
194
+ *
195
+ * The callable must return a the altered or unaltered value.
196
+ *
197
+ * @param callable $closure Map function to apply
198
+ * @param array $context Context to pass to the callable
199
+ *
200
+ * @return Collection
201
+ */
202
+ public function map(callable $closure, array $context = [])
203
+ {
204
+ $collection = new static();
205
+ foreach ($this as $key => $value) {
206
+ $collection[$key] = $closure($key, $value, $context);
207
+ }
208
+
209
+ return $collection;
210
+ }
211
+
212
+ /**
213
+ * Iterates over each key value pair in the collection passing them to the
214
+ * callable. If the callable returns true, the current value from input is
215
+ * returned into the result Collection.
216
+ *
217
+ * The callable must accept two arguments:
218
+ * - (string) $key
219
+ * - (string) $value
220
+ *
221
+ * @param callable $closure Evaluation function
222
+ *
223
+ * @return Collection
224
+ */
225
+ public function filter(callable $closure)
226
+ {
227
+ $collection = new static();
228
+ foreach ($this->data as $key => $value) {
229
+ if ($closure($key, $value)) {
230
+ $collection[$key] = $value;
231
+ }
232
+ }
233
+
234
+ return $collection;
235
+ }
236
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php ADDED
@@ -0,0 +1,248 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Cookie;
3
+
4
+ use GuzzleHttp\Message\RequestInterface;
5
+ use GuzzleHttp\Message\ResponseInterface;
6
+ use GuzzleHttp\ToArrayInterface;
7
+
8
+ /**
9
+ * Cookie jar that stores cookies an an array
10
+ */
11
+ class CookieJar implements CookieJarInterface, ToArrayInterface
12
+ {
13
+ /** @var SetCookie[] Loaded cookie data */
14
+ private $cookies = [];
15
+
16
+ /** @var bool */
17
+ private $strictMode;
18
+
19
+ /**
20
+ * @param bool $strictMode Set to true to throw exceptions when invalid
21
+ * cookies are added to the cookie jar.
22
+ * @param array $cookieArray Array of SetCookie objects or a hash of arrays
23
+ * that can be used with the SetCookie constructor
24
+ */
25
+ public function __construct($strictMode = false, $cookieArray = [])
26
+ {
27
+ $this->strictMode = $strictMode;
28
+
29
+ foreach ($cookieArray as $cookie) {
30
+ if (!($cookie instanceof SetCookie)) {
31
+ $cookie = new SetCookie($cookie);
32
+ }
33
+ $this->setCookie($cookie);
34
+ }
35
+ }
36
+
37
+ /**
38
+ * Create a new Cookie jar from an associative array and domain.
39
+ *
40
+ * @param array $cookies Cookies to create the jar from
41
+ * @param string $domain Domain to set the cookies to
42
+ *
43
+ * @return self
44
+ */
45
+ public static function fromArray(array $cookies, $domain)
46
+ {
47
+ $cookieJar = new self();
48
+ foreach ($cookies as $name => $value) {
49
+ $cookieJar->setCookie(new SetCookie([
50
+ 'Domain' => $domain,
51
+ 'Name' => $name,
52
+ 'Value' => $value,
53
+ 'Discard' => true
54
+ ]));
55
+ }
56
+
57
+ return $cookieJar;
58
+ }
59
+
60
+ /**
61
+ * Quote the cookie value if it is not already quoted and it contains
62
+ * problematic characters.
63
+ *
64
+ * @param string $value Value that may or may not need to be quoted
65
+ *
66
+ * @return string
67
+ */
68
+ public static function getCookieValue($value)
69
+ {
70
+ if (substr($value, 0, 1) !== '"' &&
71
+ substr($value, -1, 1) !== '"' &&
72
+ strpbrk($value, ';,')
73
+ ) {
74
+ $value = '"' . $value . '"';
75
+ }
76
+
77
+ return $value;
78
+ }
79
+
80
+ public function toArray()
81
+ {
82
+ return array_map(function (SetCookie $cookie) {
83
+ return $cookie->toArray();
84
+ }, $this->getIterator()->getArrayCopy());
85
+ }
86
+
87
+ public function clear($domain = null, $path = null, $name = null)
88
+ {
89
+ if (!$domain) {
90
+ $this->cookies = [];
91
+ return;
92
+ } elseif (!$path) {
93
+ $this->cookies = array_filter(
94
+ $this->cookies,
95
+ function (SetCookie $cookie) use ($path, $domain) {
96
+ return !$cookie->matchesDomain($domain);
97
+ }
98
+ );
99
+ } elseif (!$name) {
100
+ $this->cookies = array_filter(
101
+ $this->cookies,
102
+ function (SetCookie $cookie) use ($path, $domain) {
103
+ return !($cookie->matchesPath($path) &&
104
+ $cookie->matchesDomain($domain));
105
+ }
106
+ );
107
+ } else {
108
+ $this->cookies = array_filter(
109
+ $this->cookies,
110
+ function (SetCookie $cookie) use ($path, $domain, $name) {
111
+ return !($cookie->getName() == $name &&
112
+ $cookie->matchesPath($path) &&
113
+ $cookie->matchesDomain($domain));
114
+ }
115
+ );
116
+ }
117
+ }
118
+
119
+ public function clearSessionCookies()
120
+ {
121
+ $this->cookies = array_filter(
122
+ $this->cookies,
123
+ function (SetCookie $cookie) {
124
+ return !$cookie->getDiscard() && $cookie->getExpires();
125
+ }
126
+ );
127
+ }
128
+
129
+ public function setCookie(SetCookie $cookie)
130
+ {
131
+ // Only allow cookies with set and valid domain, name, value
132
+ $result = $cookie->validate();
133
+ if ($result !== true) {
134
+ if ($this->strictMode) {
135
+ throw new \RuntimeException('Invalid cookie: ' . $result);
136
+ } else {
137
+ $this->removeCookieIfEmpty($cookie);
138
+ return false;
139
+ }
140
+ }
141
+
142
+ // Resolve conflicts with previously set cookies
143
+ foreach ($this->cookies as $i => $c) {
144
+
145
+ // Two cookies are identical, when their path, and domain are
146
+ // identical.
147
+ if ($c->getPath() != $cookie->getPath() ||
148
+ $c->getDomain() != $cookie->getDomain() ||
149
+ $c->getName() != $cookie->getName()
150
+ ) {
151
+ continue;
152
+ }
153
+
154
+ // The previously set cookie is a discard cookie and this one is
155
+ // not so allow the new cookie to be set
156
+ if (!$cookie->getDiscard() && $c->getDiscard()) {
157
+ unset($this->cookies[$i]);
158
+ continue;
159
+ }
160
+
161
+ // If the new cookie's expiration is further into the future, then
162
+ // replace the old cookie
163
+ if ($cookie->getExpires() > $c->getExpires()) {
164
+ unset($this->cookies[$i]);
165
+ continue;
166
+ }
167
+
168
+ // If the value has changed, we better change it
169
+ if ($cookie->getValue() !== $c->getValue()) {
170
+ unset($this->cookies[$i]);
171
+ continue;
172
+ }
173
+
174
+ // The cookie exists, so no need to continue
175
+ return false;
176
+ }
177
+
178
+ $this->cookies[] = $cookie;
179
+
180
+ return true;
181
+ }
182
+
183
+ public function count()
184
+ {
185
+ return count($this->cookies);
186
+ }
187
+
188
+ public function getIterator()
189
+ {
190
+ return new \ArrayIterator(array_values($this->cookies));
191
+ }
192
+
193
+ public function extractCookies(
194
+ RequestInterface $request,
195
+ ResponseInterface $response
196
+ ) {
197
+ if ($cookieHeader = $response->getHeaderAsArray('Set-Cookie')) {
198
+ foreach ($cookieHeader as $cookie) {
199
+ $sc = SetCookie::fromString($cookie);
200
+ if (!$sc->getDomain()) {
201
+ $sc->setDomain($request->getHost());
202
+ }
203
+ $this->setCookie($sc);
204
+ }
205
+ }
206
+ }
207
+
208
+ public function addCookieHeader(RequestInterface $request)
209
+ {
210
+ $values = [];
211
+ $scheme = $request->getScheme();
212
+ $host = $request->getHost();
213
+ $path = $request->getPath();
214
+
215
+ foreach ($this->cookies as $cookie) {
216
+ if ($cookie->matchesPath($path) &&
217
+ $cookie->matchesDomain($host) &&
218
+ !$cookie->isExpired() &&
219
+ (!$cookie->getSecure() || $scheme == 'https')
220
+ ) {
221
+ $values[] = $cookie->getName() . '='
222
+ . self::getCookieValue($cookie->getValue());
223
+ }
224
+ }
225
+
226
+ if ($values) {
227
+ $request->setHeader('Cookie', implode('; ', $values));
228
+ }
229
+ }
230
+
231
+ /**
232
+ * If a cookie already exists and the server asks to set it again with a
233
+ * null value, the cookie must be deleted.
234
+ *
235
+ * @param SetCookie $cookie
236
+ */
237
+ private function removeCookieIfEmpty(SetCookie $cookie)
238
+ {
239
+ $cookieValue = $cookie->getValue();
240
+ if ($cookieValue === null || $cookieValue === '') {
241
+ $this->clear(
242
+ $cookie->getDomain(),
243
+ $cookie->getPath(),
244
+ $cookie->getName()
245
+ );
246
+ }
247
+ }
248
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Cookie;
3
+
4
+ use GuzzleHttp\Message\RequestInterface;
5
+ use GuzzleHttp\Message\ResponseInterface;
6
+
7
+ /**
8
+ * Stores HTTP cookies.
9
+ *
10
+ * It extracts cookies from HTTP requests, and returns them in HTTP responses.
11
+ * CookieJarInterface instances automatically expire contained cookies when
12
+ * necessary. Subclasses are also responsible for storing and retrieving
13
+ * cookies from a file, database, etc.
14
+ *
15
+ * @link http://docs.python.org/2/library/cookielib.html Inspiration
16
+ */
17
+ interface CookieJarInterface extends \Countable, \IteratorAggregate
18
+ {
19
+ /**
20
+ * Add a Cookie header to a request.
21
+ *
22
+ * If no matching cookies are found in the cookie jar, then no Cookie
23
+ * header is added to the request.
24
+ *
25
+ * @param RequestInterface $request Request object to update
26
+ */
27
+ public function addCookieHeader(RequestInterface $request);
28
+
29
+ /**
30
+ * Extract cookies from an HTTP response and store them in the CookieJar.
31
+ *
32
+ * @param RequestInterface $request Request that was sent
33
+ * @param ResponseInterface $response Response that was received
34
+ */
35
+ public function extractCookies(
36
+ RequestInterface $request,
37
+ ResponseInterface $response
38
+ );
39
+
40
+ /**
41
+ * Sets a cookie in the cookie jar.
42
+ *
43
+ * @param SetCookie $cookie Cookie to set.
44
+ *
45
+ * @return bool Returns true on success or false on failure
46
+ */
47
+ public function setCookie(SetCookie $cookie);
48
+
49
+ /**
50
+ * Remove cookies currently held in the cookie jar.
51
+ *
52
+ * Invoking this method without arguments will empty the whole cookie jar.
53
+ * If given a $domain argument only cookies belonging to that domain will
54
+ * be removed. If given a $domain and $path argument, cookies belonging to
55
+ * the specified path within that domain are removed. If given all three
56
+ * arguments, then the cookie with the specified name, path and domain is
57
+ * removed.
58
+ *
59
+ * @param string $domain Clears cookies matching a domain
60
+ * @param string $path Clears cookies matching a domain and path
61
+ * @param string $name Clears cookies matching a domain, path, and name
62
+ *
63
+ * @return CookieJarInterface
64
+ */
65
+ public function clear($domain = null, $path = null, $name = null);
66
+
67
+ /**
68
+ * Discard all sessions cookies.
69
+ *
70
+ * Removes cookies that don't have an expire field or a have a discard
71
+ * field set to true. To be called when the user agent shuts down according
72
+ * to RFC 2965.
73
+ */
74
+ public function clearSessionCookies();
75
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Cookie;
3
+
4
+ use GuzzleHttp\Utils;
5
+
6
+ /**
7
+ * Persists non-session cookies using a JSON formatted file
8
+ */
9
+ class FileCookieJar extends CookieJar
10
+ {
11
+ /** @var string filename */
12
+ private $filename;
13
+
14
+ /**
15
+ * Create a new FileCookieJar object
16
+ *
17
+ * @param string $cookieFile File to store the cookie data
18
+ *
19
+ * @throws \RuntimeException if the file cannot be found or created
20
+ */
21
+ public function __construct($cookieFile)
22
+ {
23
+ $this->filename = $cookieFile;
24
+
25
+ if (file_exists($cookieFile)) {
26
+ $this->load($cookieFile);
27
+ }
28
+ }
29
+
30
+ /**
31
+ * Saves the file when shutting down
32
+ */
33
+ public function __destruct()
34
+ {
35
+ $this->save($this->filename);
36
+ }
37
+
38
+ /**
39
+ * Saves the cookies to a file.
40
+ *
41
+ * @param string $filename File to save
42
+ * @throws \RuntimeException if the file cannot be found or created
43
+ */
44
+ public function save($filename)
45
+ {
46
+ $json = [];
47
+ foreach ($this as $cookie) {
48
+ if ($cookie->getExpires() && !$cookie->getDiscard()) {
49
+ $json[] = $cookie->toArray();
50
+ }
51
+ }
52
+
53
+ if (false === file_put_contents($filename, json_encode($json))) {
54
+ // @codeCoverageIgnoreStart
55
+ throw new \RuntimeException("Unable to save file {$filename}");
56
+ // @codeCoverageIgnoreEnd
57
+ }
58
+ }
59
+
60
+ /**
61
+ * Load cookies from a JSON formatted file.
62
+ *
63
+ * Old cookies are kept unless overwritten by newly loaded ones.
64
+ *
65
+ * @param string $filename Cookie file to load.
66
+ * @throws \RuntimeException if the file cannot be loaded.
67
+ */
68
+ public function load($filename)
69
+ {
70
+ $json = file_get_contents($filename);
71
+ if (false === $json) {
72
+ // @codeCoverageIgnoreStart
73
+ throw new \RuntimeException("Unable to load file {$filename}");
74
+ // @codeCoverageIgnoreEnd
75
+ }
76
+
77
+ $data = Utils::jsonDecode($json, true);
78
+ if (is_array($data)) {
79
+ foreach (Utils::jsonDecode($json, true) as $cookie) {
80
+ $this->setCookie(new SetCookie($cookie));
81
+ }
82
+ } elseif (strlen($data)) {
83
+ throw new \RuntimeException("Invalid cookie file: {$filename}");
84
+ }
85
+ }
86
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Cookie;
3
+
4
+ use GuzzleHttp\Utils;
5
+
6
+ /**
7
+ * Persists cookies in the client session
8
+ */
9
+ class SessionCookieJar extends CookieJar
10
+ {
11
+ /** @var string session key */
12
+ private $sessionKey;
13
+
14
+ /**
15
+ * Create a new SessionCookieJar object
16
+ *
17
+ * @param string $sessionKey Session key name to store the cookie data in session
18
+ */
19
+ public function __construct($sessionKey)
20
+ {
21
+ $this->sessionKey = $sessionKey;
22
+ $this->load();
23
+ }
24
+
25
+ /**
26
+ * Saves cookies to session when shutting down
27
+ */
28
+ public function __destruct()
29
+ {
30
+ $this->save();
31
+ }
32
+
33
+ /**
34
+ * Save cookies to the client session
35
+ */
36
+ public function save()
37
+ {
38
+ $json = [];
39
+ foreach ($this as $cookie) {
40
+ if ($cookie->getExpires() && !$cookie->getDiscard()) {
41
+ $json[] = $cookie->toArray();
42
+ }
43
+ }
44
+
45
+ $_SESSION[$this->sessionKey] = json_encode($json);
46
+ }
47
+
48
+ /**
49
+ * Load the contents of the client session into the data array
50
+ */
51
+ protected function load()
52
+ {
53
+ $cookieJar = isset($_SESSION[$this->sessionKey])
54
+ ? $_SESSION[$this->sessionKey]
55
+ : null;
56
+
57
+ $data = Utils::jsonDecode($cookieJar, true);
58
+ if (is_array($data)) {
59
+ foreach ($data as $cookie) {
60
+ $this->setCookie(new SetCookie($cookie));
61
+ }
62
+ } elseif (strlen($data)) {
63
+ throw new \RuntimeException("Invalid cookie data");
64
+ }
65
+ }
66
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php ADDED
@@ -0,0 +1,373 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Cookie;
3
+
4
+ use GuzzleHttp\ToArrayInterface;
5
+
6
+ /**
7
+ * Set-Cookie object
8
+ */
9
+ class SetCookie implements ToArrayInterface
10
+ {
11
+ /** @var array */
12
+ private static $defaults = [
13
+ 'Name' => null,
14
+ 'Value' => null,
15
+ 'Domain' => null,
16
+ 'Path' => '/',
17
+ 'Max-Age' => null,
18
+ 'Expires' => null,
19
+ 'Secure' => false,
20
+ 'Discard' => false,
21
+ 'HttpOnly' => false
22
+ ];
23
+
24
+ /** @var array Cookie data */
25
+ private $data;
26
+
27
+ /**
28
+ * Create a new SetCookie object from a string
29
+ *
30
+ * @param string $cookie Set-Cookie header string
31
+ *
32
+ * @return self
33
+ */
34
+ public static function fromString($cookie)
35
+ {
36
+ // Create the default return array
37
+ $data = self::$defaults;
38
+ // Explode the cookie string using a series of semicolons
39
+ $pieces = array_filter(array_map('trim', explode(';', $cookie)));
40
+ // The name of the cookie (first kvp) must include an equal sign.
41
+ if (empty($pieces) || !strpos($pieces[0], '=')) {
42
+ return new self($data);
43
+ }
44
+
45
+ // Add the cookie pieces into the parsed data array
46
+ foreach ($pieces as $part) {
47
+
48
+ $cookieParts = explode('=', $part, 2);
49
+ $key = trim($cookieParts[0]);
50
+ $value = isset($cookieParts[1])
51
+ ? trim($cookieParts[1], " \n\r\t\0\x0B\"")
52
+ : true;
53
+
54
+ // Only check for non-cookies when cookies have been found
55
+ if (empty($data['Name'])) {
56
+ $data['Name'] = $key;
57
+ $data['Value'] = $value;
58
+ } else {
59
+ foreach (array_keys(self::$defaults) as $search) {
60
+ if (!strcasecmp($search, $key)) {
61
+ $data[$search] = $value;
62
+ continue 2;
63
+ }
64
+ }
65
+ $data[$key] = $value;
66
+ }
67
+ }
68
+
69
+ return new self($data);
70
+ }
71
+
72
+ /**
73
+ * @param array $data Array of cookie data provided by a Cookie parser
74
+ */
75
+ public function __construct(array $data = [])
76
+ {
77
+ $this->data = array_replace(self::$defaults, $data);
78
+ // Extract the Expires value and turn it into a UNIX timestamp if needed
79
+ if (!$this->getExpires() && $this->getMaxAge()) {
80
+ // Calculate the Expires date
81
+ $this->setExpires(time() + $this->getMaxAge());
82
+ } elseif ($this->getExpires() && !is_numeric($this->getExpires())) {
83
+ $this->setExpires($this->getExpires());
84
+ }
85
+ }
86
+
87
+ public function __toString()
88
+ {
89
+ $str = $this->data['Name'] . '=' . $this->data['Value'] . '; ';
90
+ foreach ($this->data as $k => $v) {
91
+ if ($k != 'Name' && $k != 'Value' && $v !== null && $v !== false) {
92
+ if ($k == 'Expires') {
93
+ $str .= 'Expires=' . gmdate('D, d M Y H:i:s \G\M\T', $v) . '; ';
94
+ } else {
95
+ $str .= ($v === true ? $k : "{$k}={$v}") . '; ';
96
+ }
97
+ }
98
+ }
99
+
100
+ return rtrim($str, '; ');
101
+ }
102
+
103
+ public function toArray()
104
+ {
105
+ return $this->data;
106
+ }
107
+
108
+ /**
109
+ * Get the cookie name
110
+ *
111
+ * @return string
112
+ */
113
+ public function getName()
114
+ {
115
+ return $this->data['Name'];
116
+ }
117
+
118
+ /**
119
+ * Set the cookie name
120
+ *
121
+ * @param string $name Cookie name
122
+ */
123
+ public function setName($name)
124
+ {
125
+ $this->data['Name'] = $name;
126
+ }
127
+
128
+ /**
129
+ * Get the cookie value
130
+ *
131
+ * @return string
132
+ */
133
+ public function getValue()
134
+ {
135
+ return $this->data['Value'];
136
+ }
137
+
138
+ /**
139
+ * Set the cookie value
140
+ *
141
+ * @param string $value Cookie value
142
+ */
143
+ public function setValue($value)
144
+ {
145
+ $this->data['Value'] = $value;
146
+ }
147
+
148
+ /**
149
+ * Get the domain
150
+ *
151
+ * @return string|null
152
+ */
153
+ public function getDomain()
154
+ {
155
+ return $this->data['Domain'];
156
+ }
157
+
158
+ /**
159
+ * Set the domain of the cookie
160
+ *
161
+ * @param string $domain
162
+ */
163
+ public function setDomain($domain)
164
+ {
165
+ $this->data['Domain'] = $domain;
166
+ }
167
+
168
+ /**
169
+ * Get the path
170
+ *
171
+ * @return string
172
+ */
173
+ public function getPath()
174
+ {
175
+ return $this->data['Path'];
176
+ }
177
+
178
+ /**
179
+ * Set the path of the cookie
180
+ *
181
+ * @param string $path Path of the cookie
182
+ */
183
+ public function setPath($path)
184
+ {
185
+ $this->data['Path'] = $path;
186
+ }
187
+
188
+ /**
189
+ * Maximum lifetime of the cookie in seconds
190
+ *
191
+ * @return int|null
192
+ */
193
+ public function getMaxAge()
194
+ {
195
+ return $this->data['Max-Age'];
196
+ }
197
+
198
+ /**
199
+ * Set the max-age of the cookie
200
+ *
201
+ * @param int $maxAge Max age of the cookie in seconds
202
+ */
203
+ public function setMaxAge($maxAge)
204
+ {
205
+ $this->data['Max-Age'] = $maxAge;
206
+ }
207
+
208
+ /**
209
+ * The UNIX timestamp when the cookie Expires
210
+ *
211
+ * @return mixed
212
+ */
213
+ public function getExpires()
214
+ {
215
+ return $this->data['Expires'];
216
+ }
217
+
218
+ /**
219
+ * Set the unix timestamp for which the cookie will expire
220
+ *
221
+ * @param int $timestamp Unix timestamp
222
+ */
223
+ public function setExpires($timestamp)
224
+ {
225
+ $this->data['Expires'] = is_numeric($timestamp)
226
+ ? (int) $timestamp
227
+ : strtotime($timestamp);
228
+ }
229
+
230
+ /**
231
+ * Get whether or not this is a secure cookie
232
+ *
233
+ * @return null|bool
234
+ */
235
+ public function getSecure()
236
+ {
237
+ return $this->data['Secure'];
238
+ }
239
+
240
+ /**
241
+ * Set whether or not the cookie is secure
242
+ *
243
+ * @param bool $secure Set to true or false if secure
244
+ */
245
+ public function setSecure($secure)
246
+ {
247
+ $this->data['Secure'] = $secure;
248
+ }
249
+
250
+ /**
251
+ * Get whether or not this is a session cookie
252
+ *
253
+ * @return null|bool
254
+ */
255
+ public function getDiscard()
256
+ {
257
+ return $this->data['Discard'];
258
+ }
259
+
260
+ /**
261
+ * Set whether or not this is a session cookie
262
+ *
263
+ * @param bool $discard Set to true or false if this is a session cookie
264
+ */
265
+ public function setDiscard($discard)
266
+ {
267
+ $this->data['Discard'] = $discard;
268
+ }
269
+
270
+ /**
271
+ * Get whether or not this is an HTTP only cookie
272
+ *
273
+ * @return bool
274
+ */
275
+ public function getHttpOnly()
276
+ {
277
+ return $this->data['HttpOnly'];
278
+ }
279
+
280
+ /**
281
+ * Set whether or not this is an HTTP only cookie
282
+ *
283
+ * @param bool $httpOnly Set to true or false if this is HTTP only
284
+ */
285
+ public function setHttpOnly($httpOnly)
286
+ {
287
+ $this->data['HttpOnly'] = $httpOnly;
288
+ }
289
+
290
+ /**
291
+ * Check if the cookie matches a path value
292
+ *
293
+ * @param string $path Path to check against
294
+ *
295
+ * @return bool
296
+ */
297
+ public function matchesPath($path)
298
+ {
299
+ return !$this->getPath() || 0 === stripos($path, $this->getPath());
300
+ }
301
+
302
+ /**
303
+ * Check if the cookie matches a domain value
304
+ *
305
+ * @param string $domain Domain to check against
306
+ *
307
+ * @return bool
308
+ */
309
+ public function matchesDomain($domain)
310
+ {
311
+ // Remove the leading '.' as per spec in RFC 6265.
312
+ // http://tools.ietf.org/html/rfc6265#section-5.2.3
313
+ $cookieDomain = ltrim($this->getDomain(), '.');
314
+
315
+ // Domain not set or exact match.
316
+ if (!$cookieDomain || !strcasecmp($domain, $cookieDomain)) {
317
+ return true;
318
+ }
319
+
320
+ // Matching the subdomain according to RFC 6265.
321
+ // http://tools.ietf.org/html/rfc6265#section-5.1.3
322
+ if (filter_var($domain, FILTER_VALIDATE_IP)) {
323
+ return false;
324
+ }
325
+
326
+ return (bool) preg_match('/\.' . preg_quote($cookieDomain) . '$/i', $domain);
327
+ }
328
+
329
+ /**
330
+ * Check if the cookie is expired
331
+ *
332
+ * @return bool
333
+ */
334
+ public function isExpired()
335
+ {
336
+ return $this->getExpires() && time() > $this->getExpires();
337
+ }
338
+
339
+ /**
340
+ * Check if the cookie is valid according to RFC 6265
341
+ *
342
+ * @return bool|string Returns true if valid or an error message if invalid
343
+ */
344
+ public function validate()
345
+ {
346
+ // Names must not be empty, but can be 0
347
+ $name = $this->getName();
348
+ if (empty($name) && !is_numeric($name)) {
349
+ return 'The cookie name must not be empty';
350
+ }
351
+
352
+ // Check if any of the invalid characters are present in the cookie name
353
+ if (preg_match("/[=,; \t\r\n\013\014]/", $name)) {
354
+ return "Cookie name must not cannot invalid characters: =,; \\t\\r\\n\\013\\014";
355
+ }
356
+
357
+ // Value must not be empty, but can be 0
358
+ $value = $this->getValue();
359
+ if (empty($value) && !is_numeric($value)) {
360
+ return 'The cookie value must not be empty';
361
+ }
362
+
363
+ // Domains must not be empty, but can be 0
364
+ // A "0" is not a valid internet domain, but may be used as server name
365
+ // in a private network.
366
+ $domain = $this->getDomain();
367
+ if (empty($domain) && !is_numeric($domain)) {
368
+ return 'The cookie domain must not be empty';
369
+ }
370
+
371
+ return true;
372
+ }
373
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Event/AbstractEvent.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Event;
3
+
4
+ /**
5
+ * Basic event class that can be extended.
6
+ */
7
+ abstract class AbstractEvent implements EventInterface
8
+ {
9
+ private $propagationStopped = false;
10
+
11
+ public function isPropagationStopped()
12
+ {
13
+ return $this->propagationStopped;
14
+ }
15
+
16
+ public function stopPropagation()
17
+ {
18
+ $this->propagationStopped = true;
19
+ }
20
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Event/AbstractRequestEvent.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Event;
3
+
4
+ use GuzzleHttp\Transaction;
5
+ use GuzzleHttp\ClientInterface;
6
+ use GuzzleHttp\Message\RequestInterface;
7
+
8
+ /**
9
+ * Base class for request events, providing a request and client getter.
10
+ */
11
+ abstract class AbstractRequestEvent extends AbstractEvent
12
+ {
13
+ /** @var Transaction */
14
+ protected $transaction;
15
+
16
+ /**
17
+ * @param Transaction $transaction
18
+ */
19
+ public function __construct(Transaction $transaction)
20
+ {
21
+ $this->transaction = $transaction;
22
+ }
23
+
24
+ /**
25
+ * Get the HTTP client associated with the event.
26
+ *
27
+ * @return ClientInterface
28
+ */
29
+ public function getClient()
30
+ {
31
+ return $this->transaction->client;
32
+ }
33
+
34
+ /**
35
+ * Get the request object
36
+ *
37
+ * @return RequestInterface
38
+ */
39
+ public function getRequest()
40
+ {
41
+ return $this->transaction->request;
42
+ }
43
+
44
+ /**
45
+ * Get the number of transaction retries.
46
+ *
47
+ * @return int
48
+ */
49
+ public function getRetryCount()
50
+ {
51
+ return $this->transaction->retries;
52
+ }
53
+
54
+ /**
55
+ * @return Transaction
56
+ */
57
+ public function getTransaction()
58
+ {
59
+ return $this->transaction;
60
+ }
61
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Event/AbstractRetryableEvent.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Event;
3
+
4
+ /**
5
+ * Abstract request event that can be retried.
6
+ */
7
+ class AbstractRetryableEvent extends AbstractTransferEvent
8
+ {
9
+ /**
10
+ * Mark the request as needing a retry and stop event propagation.
11
+ *
12
+ * This action allows you to retry a request without emitting the "end"
13
+ * event multiple times for a given request. When retried, the request
14
+ * emits a before event and is then sent again using the client that sent
15
+ * the original request.
16
+ *
17
+ * When retrying, it is important to limit the number of retries you allow
18
+ * to prevent infinite loops.
19
+ *
20
+ * This action can only be taken during the "complete" and "error" events.
21
+ *
22
+ * @param int $afterDelay If specified, the amount of time in milliseconds
23
+ * to delay before retrying. Note that this must
24
+ * be supported by the underlying RingPHP handler
25
+ * to work properly. Set to 0 or provide no value
26
+ * to retry immediately.
27
+ */
28
+ public function retry($afterDelay = 0)
29
+ {
30
+ // Setting the transition state to 'retry' will cause the next state
31
+ // transition of the transaction to retry the request.
32
+ $this->transaction->state = 'retry';
33
+
34
+ if ($afterDelay) {
35
+ $this->transaction->request->getConfig()->set('delay', $afterDelay);
36
+ }
37
+
38
+ $this->stopPropagation();
39
+ }
40
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Event/AbstractTransferEvent.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Event;
3
+
4
+ use GuzzleHttp\Message\ResponseInterface;
5
+ use GuzzleHttp\Ring\Future\FutureInterface;
6
+
7
+ /**
8
+ * Event that contains transfer statistics, and can be intercepted.
9
+ */
10
+ abstract class AbstractTransferEvent extends AbstractRequestEvent
11
+ {
12
+ /**
13
+ * Get all transfer information as an associative array if no $name
14
+ * argument is supplied, or gets a specific transfer statistic if
15
+ * a $name attribute is supplied (e.g., 'total_time').
16
+ *
17
+ * @param string $name Name of the transfer stat to retrieve
18
+ *
19
+ * @return mixed|null|array
20
+ */
21
+ public function getTransferInfo($name = null)
22
+ {
23
+ if (!$name) {
24
+ return $this->transaction->transferInfo;
25
+ }
26
+
27
+ return isset($this->transaction->transferInfo[$name])
28
+ ? $this->transaction->transferInfo[$name]
29
+ : null;
30
+ }
31
+
32
+ /**
33
+ * Returns true/false if a response is available.
34
+ *
35
+ * @return bool
36
+ */
37
+ public function hasResponse()
38
+ {
39
+ return !($this->transaction->response instanceof FutureInterface);
40
+ }
41
+
42
+ /**
43
+ * Get the response.
44
+ *
45
+ * @return ResponseInterface|null
46
+ */
47
+ public function getResponse()
48
+ {
49
+ return $this->hasResponse() ? $this->transaction->response : null;
50
+ }
51
+
52
+ /**
53
+ * Intercept the request and associate a response
54
+ *
55
+ * @param ResponseInterface $response Response to set
56
+ */
57
+ public function intercept(ResponseInterface $response)
58
+ {
59
+ $this->transaction->response = $response;
60
+ $this->transaction->exception = null;
61
+ $this->stopPropagation();
62
+ }
63
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Event/BeforeEvent.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Event;
3
+
4
+ use GuzzleHttp\Message\ResponseInterface;
5
+
6
+ /**
7
+ * Event object emitted before a request is sent.
8
+ *
9
+ * This event MAY be emitted multiple times (i.e., if a request is retried).
10
+ * You MAY change the Response associated with the request using the
11
+ * intercept() method of the event.
12
+ */
13
+ class BeforeEvent extends AbstractRequestEvent
14
+ {
15
+ /**
16
+ * Intercept the request and associate a response
17
+ *
18
+ * @param ResponseInterface $response Response to set
19
+ */
20
+ public function intercept(ResponseInterface $response)
21
+ {
22
+ $this->transaction->response = $response;
23
+ $this->transaction->exception = null;
24
+ $this->stopPropagation();
25
+ }
26
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Event/CompleteEvent.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Event;
3
+
4
+ /**
5
+ * Event object emitted after a request has been completed.
6
+ *
7
+ * This event MAY be emitted multiple times for a single request. You MAY
8
+ * change the Response associated with the request using the intercept()
9
+ * method of the event.
10
+ *
11
+ * This event allows the request to be retried if necessary using the retry()
12
+ * method of the event.
13
+ */
14
+ class CompleteEvent extends AbstractRetryableEvent {}
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Event/Emitter.php ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Event;
3
+
4
+ /**
5
+ * Guzzle event emitter.
6
+ *
7
+ * Some of this class is based on the Symfony EventDispatcher component, which
8
+ * ships with the following license:
9
+ *
10
+ * This file is part of the Symfony package.
11
+ *
12
+ * (c) Fabien Potencier <fabien@symfony.com>
13
+ *
14
+ * For the full copyright and license information, please view the LICENSE
15
+ * file that was distributed with this source code.
16
+ *
17
+ * @link https://github.com/symfony/symfony/tree/master/src/Symfony/Component/EventDispatcher
18
+ */
19
+ class Emitter implements EmitterInterface
20
+ {
21
+ /** @var array */
22
+ private $listeners = [];
23
+
24
+ /** @var array */
25
+ private $sorted = [];
26
+
27
+ public function on($eventName, callable $listener, $priority = 0)
28
+ {
29
+ if ($priority === 'first') {
30
+ $priority = isset($this->listeners[$eventName])
31
+ ? max(array_keys($this->listeners[$eventName])) + 1
32
+ : 1;
33
+ } elseif ($priority === 'last') {
34
+ $priority = isset($this->listeners[$eventName])
35
+ ? min(array_keys($this->listeners[$eventName])) - 1
36
+ : -1;
37
+ }
38
+
39
+ $this->listeners[$eventName][$priority][] = $listener;
40
+ unset($this->sorted[$eventName]);
41
+ }
42
+
43
+ public function once($eventName, callable $listener, $priority = 0)
44
+ {
45
+ $onceListener = function (
46
+ EventInterface $event,
47
+ $eventName
48
+ ) use (&$onceListener, $eventName, $listener, $priority) {
49
+ $this->removeListener($eventName, $onceListener);
50
+ $listener($event, $eventName);
51
+ };
52
+
53
+ $this->on($eventName, $onceListener, $priority);
54
+ }
55
+
56
+ public function removeListener($eventName, callable $listener)
57
+ {
58
+ if (empty($this->listeners[$eventName])) {
59
+ return;
60
+ }
61
+
62
+ foreach ($this->listeners[$eventName] as $priority => $listeners) {
63
+ if (false !== ($key = array_search($listener, $listeners, true))) {
64
+ unset(
65
+ $this->listeners[$eventName][$priority][$key],
66
+ $this->sorted[$eventName]
67
+ );
68
+ }
69
+ }
70
+ }
71
+
72
+ public function listeners($eventName = null)
73
+ {
74
+ // Return all events in a sorted priority order
75
+ if ($eventName === null) {
76
+ foreach (array_keys($this->listeners) as $eventName) {
77
+ if (empty($this->sorted[$eventName])) {
78
+ $this->listeners($eventName);
79
+ }
80
+ }
81
+ return $this->sorted;
82
+ }
83
+
84
+ // Return the listeners for a specific event, sorted in priority order
85
+ if (empty($this->sorted[$eventName])) {
86
+ $this->sorted[$eventName] = [];
87
+ if (isset($this->listeners[$eventName])) {
88
+ krsort($this->listeners[$eventName], SORT_NUMERIC);
89
+ foreach ($this->listeners[$eventName] as $listeners) {
90
+ foreach ($listeners as $listener) {
91
+ $this->sorted[$eventName][] = $listener;
92
+ }
93
+ }
94
+ }
95
+ }
96
+
97
+ return $this->sorted[$eventName];
98
+ }
99
+
100
+ public function hasListeners($eventName)
101
+ {
102
+ return !empty($this->listeners[$eventName]);
103
+ }
104
+
105
+ public function emit($eventName, EventInterface $event)
106
+ {
107
+ if (isset($this->listeners[$eventName])) {
108
+ foreach ($this->listeners($eventName) as $listener) {
109
+ $listener($event, $eventName);
110
+ if ($event->isPropagationStopped()) {
111
+ break;
112
+ }
113
+ }
114
+ }
115
+
116
+ return $event;
117
+ }
118
+
119
+ public function attach(SubscriberInterface $subscriber)
120
+ {
121
+ foreach ($subscriber->getEvents() as $eventName => $listeners) {
122
+ if (is_array($listeners[0])) {
123
+ foreach ($listeners as $listener) {
124
+ $this->on(
125
+ $eventName,
126
+ [$subscriber, $listener[0]],
127
+ isset($listener[1]) ? $listener[1] : 0
128
+ );
129
+ }
130
+ } else {
131
+ $this->on(
132
+ $eventName,
133
+ [$subscriber, $listeners[0]],
134
+ isset($listeners[1]) ? $listeners[1] : 0
135
+ );
136
+ }
137
+ }
138
+ }
139
+
140
+ public function detach(SubscriberInterface $subscriber)
141
+ {
142
+ foreach ($subscriber->getEvents() as $eventName => $listener) {
143
+ $this->removeListener($eventName, [$subscriber, $listener[0]]);
144
+ }
145
+ }
146
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Event/EmitterInterface.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Event;
3
+
4
+ /**
5
+ * Guzzle event emitter.
6
+ */
7
+ interface EmitterInterface
8
+ {
9
+ /**
10
+ * Binds a listener to a specific event.
11
+ *
12
+ * @param string $eventName Name of the event to bind to.
13
+ * @param callable $listener Listener to invoke when triggered.
14
+ * @param int|string $priority The higher this value, the earlier an event
15
+ * listener will be triggered in the chain (defaults to 0). You can
16
+ * pass "first" or "last" to dynamically specify the event priority
17
+ * based on the current event priorities associated with the given
18
+ * event name in the emitter. Use "first" to set the priority to the
19
+ * current highest priority plus one. Use "last" to set the priority to
20
+ * the current lowest event priority minus one.
21
+ */
22
+ public function on($eventName, callable $listener, $priority = 0);
23
+
24
+ /**
25
+ * Binds a listener to a specific event. After the listener is triggered
26
+ * once, it is removed as a listener.
27
+ *
28
+ * @param string $eventName Name of the event to bind to.
29
+ * @param callable $listener Listener to invoke when triggered.
30
+ * @param int $priority The higher this value, the earlier an event
31
+ * listener will be triggered in the chain (defaults to 0)
32
+ */
33
+ public function once($eventName, callable $listener, $priority = 0);
34
+
35
+ /**
36
+ * Removes an event listener from the specified event.
37
+ *
38
+ * @param string $eventName The event to remove a listener from
39
+ * @param callable $listener The listener to remove
40
+ */
41
+ public function removeListener($eventName, callable $listener);
42
+
43
+ /**
44
+ * Gets the listeners of a specific event or all listeners if no event is
45
+ * specified.
46
+ *
47
+ * @param string $eventName The name of the event. Pass null (the default)
48
+ * to retrieve all listeners.
49
+ *
50
+ * @return array The event listeners for the specified event, or all event
51
+ * listeners by event name. The format of the array when retrieving a
52
+ * specific event list is an array of callables. The format of the array
53
+ * when retrieving all listeners is an associative array of arrays of
54
+ * callables.
55
+ */
56
+ public function listeners($eventName = null);
57
+
58
+ /**
59
+ * Checks if the emitter has listeners by the given name.
60
+ *
61
+ * @param string $eventName The name of the event to check.
62
+ *
63
+ * @return bool
64
+ */
65
+ public function hasListeners($eventName);
66
+
67
+ /**
68
+ * Emits an event to all registered listeners.
69
+ *
70
+ * Each event that is bound to the emitted eventName receives a
71
+ * EventInterface, the name of the event, and the event emitter.
72
+ *
73
+ * @param string $eventName The name of the event to dispatch.
74
+ * @param EventInterface $event The event to pass to the event handlers/listeners.
75
+ *
76
+ * @return EventInterface Returns the provided event object
77
+ */
78
+ public function emit($eventName, EventInterface $event);
79
+
80
+ /**
81
+ * Attaches an event subscriber.
82
+ *
83
+ * The subscriber is asked for all the events it is interested in and added
84
+ * as an event listener for each event.
85
+ *
86
+ * @param SubscriberInterface $subscriber Subscriber to attach.
87
+ */
88
+ public function attach(SubscriberInterface $subscriber);
89
+
90
+ /**
91
+ * Detaches an event subscriber.
92
+ *
93
+ * @param SubscriberInterface $subscriber Subscriber to detach.
94
+ */
95
+ public function detach(SubscriberInterface $subscriber);
96
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Event/EndEvent.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Event;
3
+
4
+ /**
5
+ * A terminal event that is emitted when a request transaction has ended.
6
+ *
7
+ * This event is emitted for both successful responses and responses that
8
+ * encountered an exception. You need to check if an exception is present
9
+ * in your listener to know the difference.
10
+ *
11
+ * You MAY intercept the response associated with the event if needed, but keep
12
+ * in mind that the "complete" event will not be triggered as a result.
13
+ */
14
+ class EndEvent extends AbstractTransferEvent
15
+ {
16
+ /**
17
+ * Get the exception that was encountered (if any).
18
+ *
19
+ * This method should be used to check if the request was sent successfully
20
+ * or if it encountered errors.
21
+ *
22
+ * @return \Exception|null
23
+ */
24
+ public function getException()
25
+ {
26
+ return $this->transaction->exception;
27
+ }
28
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Event/ErrorEvent.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Event;
3
+
4
+ use GuzzleHttp\Exception\RequestException;
5
+
6
+ /**
7
+ * Event emitted when an error occurs while sending a request.
8
+ *
9
+ * This event MAY be emitted multiple times. You MAY intercept the exception
10
+ * and inject a response into the event to rescue the request using the
11
+ * intercept() method of the event.
12
+ *
13
+ * This event allows the request to be retried using the "retry" method of the
14
+ * event.
15
+ */
16
+ class ErrorEvent extends AbstractRetryableEvent
17
+ {
18
+ /**
19
+ * Get the exception that was encountered
20
+ *
21
+ * @return RequestException
22
+ */
23
+ public function getException()
24
+ {
25
+ return $this->transaction->exception;
26
+ }
27
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Event/EventInterface.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Event;
3
+
4
+ /**
5
+ * Base event interface used when dispatching events to listeners using an
6
+ * event emitter.
7
+ */
8
+ interface EventInterface
9
+ {
10
+ /**
11
+ * Returns whether or not stopPropagation was called on the event.
12
+ *
13
+ * @return bool
14
+ * @see Event::stopPropagation
15
+ */
16
+ public function isPropagationStopped();
17
+
18
+ /**
19
+ * Stops the propagation of the event, preventing subsequent listeners
20
+ * registered to the same event from being invoked.
21
+ */
22
+ public function stopPropagation();
23
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Event/HasEmitterInterface.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Event;
3
+
4
+ /**
5
+ * Holds an event emitter
6
+ */
7
+ interface HasEmitterInterface
8
+ {
9
+ /**
10
+ * Get the event emitter of the object
11
+ *
12
+ * @return EmitterInterface
13
+ */
14
+ public function getEmitter();
15
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Event/HasEmitterTrait.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Event;
3
+
4
+ /**
5
+ * Trait that implements the methods of HasEmitterInterface
6
+ */
7
+ trait HasEmitterTrait
8
+ {
9
+ /** @var EmitterInterface */
10
+ private $emitter;
11
+
12
+ public function getEmitter()
13
+ {
14
+ if (!$this->emitter) {
15
+ $this->emitter = new Emitter();
16
+ }
17
+
18
+ return $this->emitter;
19
+ }
20
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Event/ListenerAttacherTrait.php ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Event;
3
+
4
+ /**
5
+ * Trait that provides methods for extract event listeners specified in an array
6
+ * and attaching them to an emitter owned by the object or one of its direct
7
+ * dependencies.
8
+ */
9
+ trait ListenerAttacherTrait
10
+ {
11
+ /**
12
+ * Attaches event listeners and properly sets their priorities and whether
13
+ * or not they are are only executed once.
14
+ *
15
+ * @param HasEmitterInterface $object Object that has the event emitter.
16
+ * @param array $listeners Array of hashes representing event
17
+ * event listeners. Each item contains
18
+ * "name", "fn", "priority", & "once".
19
+ */
20
+ private function attachListeners(HasEmitterInterface $object, array $listeners)
21
+ {
22
+ $emitter = $object->getEmitter();
23
+ foreach ($listeners as $el) {
24
+ if ($el['once']) {
25
+ $emitter->once($el['name'], $el['fn'], $el['priority']);
26
+ } else {
27
+ $emitter->on($el['name'], $el['fn'], $el['priority']);
28
+ }
29
+ }
30
+ }
31
+
32
+ /**
33
+ * Extracts the allowed events from the provided array, and ignores anything
34
+ * else in the array. The event listener must be specified as a callable or
35
+ * as an array of event listener data ("name", "fn", "priority", "once").
36
+ *
37
+ * @param array $source Array containing callables or hashes of data to be
38
+ * prepared as event listeners.
39
+ * @param array $events Names of events to look for in the provided $source
40
+ * array. Other keys are ignored.
41
+ * @return array
42
+ */
43
+ private function prepareListeners(array $source, array $events)
44
+ {
45
+ $listeners = [];
46
+ foreach ($events as $name) {
47
+ if (isset($source[$name])) {
48
+ $this->buildListener($name, $source[$name], $listeners);
49
+ }
50
+ }
51
+
52
+ return $listeners;
53
+ }
54
+
55
+ /**
56
+ * Creates a complete event listener definition from the provided array of
57
+ * listener data. Also works recursively if more than one listeners are
58
+ * contained in the provided array.
59
+ *
60
+ * @param string $name Name of the event the listener is for.
61
+ * @param array|callable $data Event listener data to prepare.
62
+ * @param array $listeners Array of listeners, passed by reference.
63
+ *
64
+ * @throws \InvalidArgumentException if the event data is malformed.
65
+ */
66
+ private function buildListener($name, $data, &$listeners)
67
+ {
68
+ static $defaults = ['priority' => 0, 'once' => false];
69
+
70
+ // If a callable is provided, normalize it to the array format.
71
+ if (is_callable($data)) {
72
+ $data = ['fn' => $data];
73
+ }
74
+
75
+ // Prepare the listener and add it to the array, recursively.
76
+ if (isset($data['fn'])) {
77
+ $data['name'] = $name;
78
+ $listeners[] = $data + $defaults;
79
+ } elseif (is_array($data)) {
80
+ foreach ($data as $listenerData) {
81
+ $this->buildListener($name, $listenerData, $listeners);
82
+ }
83
+ } else {
84
+ throw new \InvalidArgumentException('Each event listener must be a '
85
+ . 'callable or an associative array containing a "fn" key.');
86
+ }
87
+ }
88
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Event/ProgressEvent.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Event;
3
+
4
+ use GuzzleHttp\Transaction;
5
+
6
+ /**
7
+ * Event object emitted when upload or download progress is made.
8
+ *
9
+ * You can access the progress values using their corresponding public
10
+ * properties:
11
+ *
12
+ * - $downloadSize: The number of bytes that will be downloaded (if known)
13
+ * - $downloaded: The number of bytes that have been downloaded
14
+ * - $uploadSize: The number of bytes that will be uploaded (if known)
15
+ * - $uploaded: The number of bytes that have been uploaded
16
+ */
17
+ class ProgressEvent extends AbstractRequestEvent
18
+ {
19
+ /** @var int Amount of data to be downloaded */
20
+ public $downloadSize;
21
+
22
+ /** @var int Amount of data that has been downloaded */
23
+ public $downloaded;
24
+
25
+ /** @var int Amount of data to upload */
26
+ public $uploadSize;
27
+
28
+ /** @var int Amount of data that has been uploaded */
29
+ public $uploaded;
30
+
31
+ /**
32
+ * @param Transaction $transaction Transaction being sent.
33
+ * @param int $downloadSize Amount of data to download (if known)
34
+ * @param int $downloaded Amount of data that has been downloaded
35
+ * @param int $uploadSize Amount of data to upload (if known)
36
+ * @param int $uploaded Amount of data that had been uploaded
37
+ */
38
+ public function __construct(
39
+ Transaction $transaction,
40
+ $downloadSize,
41
+ $downloaded,
42
+ $uploadSize,
43
+ $uploaded
44
+ ) {
45
+ parent::__construct($transaction);
46
+ $this->downloadSize = $downloadSize;
47
+ $this->downloaded = $downloaded;
48
+ $this->uploadSize = $uploadSize;
49
+ $this->uploaded = $uploaded;
50
+ }
51
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Event/RequestEvents.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Event;
3
+
4
+ /**
5
+ * Contains methods used to manage the request event lifecycle.
6
+ */
7
+ final class RequestEvents
8
+ {
9
+ // Generic event priorities
10
+ const EARLY = 10000;
11
+ const LATE = -10000;
12
+
13
+ // "before" priorities
14
+ const PREPARE_REQUEST = -100;
15
+ const SIGN_REQUEST = -10000;
16
+
17
+ // "complete" and "error" response priorities
18
+ const VERIFY_RESPONSE = 100;
19
+ const REDIRECT_RESPONSE = 200;
20
+
21
+ /**
22
+ * Converts an array of event options into a formatted array of valid event
23
+ * configuration.
24
+ *
25
+ * @param array $options Event array to convert
26
+ * @param array $events Event names to convert in the options array.
27
+ * @param mixed $handler Event handler to utilize
28
+ *
29
+ * @return array
30
+ * @throws \InvalidArgumentException if the event config is invalid
31
+ * @internal
32
+ */
33
+ public static function convertEventArray(
34
+ array $options,
35
+ array $events,
36
+ $handler
37
+ ) {
38
+ foreach ($events as $name) {
39
+ if (!isset($options[$name])) {
40
+ $options[$name] = [$handler];
41
+ } elseif (is_callable($options[$name])) {
42
+ $options[$name] = [$options[$name], $handler];
43
+ } elseif (is_array($options[$name])) {
44
+ if (isset($options[$name]['fn'])) {
45
+ $options[$name] = [$options[$name], $handler];
46
+ } else {
47
+ $options[$name][] = $handler;
48
+ }
49
+ } else {
50
+ throw new \InvalidArgumentException('Invalid event format');
51
+ }
52
+ }
53
+
54
+ return $options;
55
+ }
56
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Event/SubscriberInterface.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Event;
3
+
4
+ /**
5
+ * SubscriberInterface provides an array of events to an
6
+ * EventEmitterInterface when it is registered. The emitter then binds the
7
+ * listeners specified by the EventSubscriber.
8
+ *
9
+ * This interface is based on the SubscriberInterface of the Symfony.
10
+ * @link https://github.com/symfony/symfony/tree/master/src/Symfony/Component/EventDispatcher
11
+ */
12
+ interface SubscriberInterface
13
+ {
14
+ /**
15
+ * Returns an array of event names this subscriber wants to listen to.
16
+ *
17
+ * The returned array keys MUST map to an event name. Each array value
18
+ * MUST be an array in which the first element is the name of a function
19
+ * on the EventSubscriber OR an array of arrays in the aforementioned
20
+ * format. The second element in the array is optional, and if specified,
21
+ * designates the event priority.
22
+ *
23
+ * For example, the following are all valid:
24
+ *
25
+ * - ['eventName' => ['methodName']]
26
+ * - ['eventName' => ['methodName', $priority]]
27
+ * - ['eventName' => [['methodName'], ['otherMethod']]
28
+ * - ['eventName' => [['methodName'], ['otherMethod', $priority]]
29
+ * - ['eventName' => [['methodName', $priority], ['otherMethod', $priority]]
30
+ *
31
+ * @return array
32
+ */
33
+ public function getEvents();
34
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Exception/BadResponseException.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Exception;
3
+
4
+ /**
5
+ * Exception when an HTTP error occurs (4xx or 5xx error)
6
+ */
7
+ class BadResponseException extends RequestException {}
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Exception/ClientException.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Exception;
3
+
4
+ /**
5
+ * Exception when a client error is encountered (4xx codes)
6
+ */
7
+ class ClientException extends BadResponseException {}
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Exception/ConnectException.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Exception;
3
+
4
+ class ConnectException extends RequestException {}
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Exception/CouldNotRewindStreamException.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Exception;
3
+
4
+ class CouldNotRewindStreamException extends RequestException {}
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Exception/ParseException.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Exception;
3
+
4
+ use GuzzleHttp\Message\ResponseInterface;
5
+
6
+ /**
7
+ * Exception when a client is unable to parse the response body as XML or JSON
8
+ */
9
+ class ParseException extends TransferException
10
+ {
11
+ /** @var ResponseInterface */
12
+ private $response;
13
+
14
+ public function __construct(
15
+ $message = '',
16
+ ResponseInterface $response = null,
17
+ \Exception $previous = null
18
+ ) {
19
+ parent::__construct($message, 0, $previous);
20
+ $this->response = $response;
21
+ }
22
+ /**
23
+ * Get the associated response
24
+ *
25
+ * @return ResponseInterface|null
26
+ */
27
+ public function getResponse()
28
+ {
29
+ return $this->response;
30
+ }
31
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Exception;
3
+
4
+ use GuzzleHttp\Message\RequestInterface;
5
+ use GuzzleHttp\Message\ResponseInterface;
6
+ use GuzzleHttp\Ring\Exception\ConnectException;
7
+ use GuzzleHttp\Exception\ConnectException as HttpConnectException;
8
+ use GuzzleHttp\Ring\Future\FutureInterface;
9
+
10
+ /**
11
+ * HTTP Request exception
12
+ */
13
+ class RequestException extends TransferException
14
+ {
15
+ /** @var RequestInterface */
16
+ private $request;
17
+
18
+ /** @var ResponseInterface */
19
+ private $response;
20
+
21
+ public function __construct(
22
+ $message,
23
+ RequestInterface $request,
24
+ ResponseInterface $response = null,
25
+ \Exception $previous = null
26
+ ) {
27
+ // Set the code of the exception if the response is set and not future.
28
+ $code = $response && !($response instanceof FutureInterface)
29
+ ? $response->getStatusCode()
30
+ : 0;
31
+ parent::__construct($message, $code, $previous);
32
+ $this->request = $request;
33
+ $this->response = $response;
34
+ }
35
+
36
+ /**
37
+ * Wrap non-RequestExceptions with a RequestException
38
+ *
39
+ * @param RequestInterface $request
40
+ * @param \Exception $e
41
+ *
42
+ * @return RequestException
43
+ */
44
+ public static function wrapException(RequestInterface $request, \Exception $e)
45
+ {
46
+ if ($e instanceof RequestException) {
47
+ return $e;
48
+ } elseif ($e instanceof ConnectException) {
49
+ return new HttpConnectException($e->getMessage(), $request, null, $e);
50
+ } else {
51
+ return new RequestException($e->getMessage(), $request, null, $e);
52
+ }
53
+ }
54
+
55
+ /**
56
+ * Factory method to create a new exception with a normalized error message
57
+ *
58
+ * @param RequestInterface $request Request
59
+ * @param ResponseInterface $response Response received
60
+ * @param \Exception $previous Previous exception
61
+ *
62
+ * @return self
63
+ */
64
+ public static function create(
65
+ RequestInterface $request,
66
+ ResponseInterface $response = null,
67
+ \Exception $previous = null
68
+ ) {
69
+ if (!$response) {
70
+ return new self('Error completing request', $request, null, $previous);
71
+ }
72
+
73
+ $level = floor($response->getStatusCode() / 100);
74
+ if ($level == '4') {
75
+ $label = 'Client error response';
76
+ $className = __NAMESPACE__ . '\\ClientException';
77
+ } elseif ($level == '5') {
78
+ $label = 'Server error response';
79
+ $className = __NAMESPACE__ . '\\ServerException';
80
+ } else {
81
+ $label = 'Unsuccessful response';
82
+ $className = __CLASS__;
83
+ }
84
+
85
+ $message = $label . ' [url] ' . $request->getUrl()
86
+ . ' [status code] ' . $response->getStatusCode()
87
+ . ' [reason phrase] ' . $response->getReasonPhrase();
88
+
89
+ return new $className($message, $request, $response, $previous);
90
+ }
91
+
92
+ /**
93
+ * Get the request that caused the exception
94
+ *
95
+ * @return RequestInterface
96
+ */
97
+ public function getRequest()
98
+ {
99
+ return $this->request;
100
+ }
101
+
102
+ /**
103
+ * Get the associated response
104
+ *
105
+ * @return ResponseInterface|null
106
+ */
107
+ public function getResponse()
108
+ {
109
+ return $this->response;
110
+ }
111
+
112
+ /**
113
+ * Check if a response was received
114
+ *
115
+ * @return bool
116
+ */
117
+ public function hasResponse()
118
+ {
119
+ return $this->response !== null;
120
+ }
121
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Exception/ServerException.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Exception;
3
+
4
+ /**
5
+ * Exception when a server error is encountered (5xx codes)
6
+ */
7
+ class ServerException extends BadResponseException {}
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Exception/StateException.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Exception;
3
+
4
+ class StateException extends TransferException {};
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Exception/TooManyRedirectsException.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Exception;
3
+
4
+ class TooManyRedirectsException extends RequestException {}
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Exception/TransferException.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Exception;
3
+
4
+ class TransferException extends \RuntimeException {}
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Exception/XmlParseException.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace GuzzleHttp\Exception;
4
+
5
+ use GuzzleHttp\Message\ResponseInterface;
6
+
7
+ /**
8
+ * Exception when a client is unable to parse the response body as XML
9
+ */
10
+ class XmlParseException extends ParseException
11
+ {
12
+ /** @var \LibXMLError */
13
+ protected $error;
14
+
15
+ public function __construct(
16
+ $message = '',
17
+ ResponseInterface $response = null,
18
+ \Exception $previous = null,
19
+ \LibXMLError $error = null
20
+ ) {
21
+ parent::__construct($message, $response, $previous);
22
+ $this->error = $error;
23
+ }
24
+
25
+ /**
26
+ * Get the associated error
27
+ *
28
+ * @return \LibXMLError|null
29
+ */
30
+ public function getError()
31
+ {
32
+ return $this->error;
33
+ }
34
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/HasDataTrait.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ /**
5
+ * Trait implementing ToArrayInterface, \ArrayAccess, \Countable,
6
+ * \IteratorAggregate, and some path style methods.
7
+ */
8
+ trait HasDataTrait
9
+ {
10
+ /** @var array */
11
+ protected $data = [];
12
+
13
+ public function getIterator()
14
+ {
15
+ return new \ArrayIterator($this->data);
16
+ }
17
+
18
+ public function offsetGet($offset)
19
+ {
20
+ return isset($this->data[$offset]) ? $this->data[$offset] : null;
21
+ }
22
+
23
+ public function offsetSet($offset, $value)
24
+ {
25
+ $this->data[$offset] = $value;
26
+ }
27
+
28
+ public function offsetExists($offset)
29
+ {
30
+ return isset($this->data[$offset]);
31
+ }
32
+
33
+ public function offsetUnset($offset)
34
+ {
35
+ unset($this->data[$offset]);
36
+ }
37
+
38
+ public function toArray()
39
+ {
40
+ return $this->data;
41
+ }
42
+
43
+ public function count()
44
+ {
45
+ return count($this->data);
46
+ }
47
+
48
+ /**
49
+ * Get a value from the collection using a path syntax to retrieve nested
50
+ * data.
51
+ *
52
+ * @param string $path Path to traverse and retrieve a value from
53
+ *
54
+ * @return mixed|null
55
+ */
56
+ public function getPath($path)
57
+ {
58
+ return Utils::getPath($this->data, $path);
59
+ }
60
+
61
+ /**
62
+ * Set a value into a nested array key. Keys will be created as needed to
63
+ * set the value.
64
+ *
65
+ * @param string $path Path to set
66
+ * @param mixed $value Value to set at the key
67
+ *
68
+ * @throws \RuntimeException when trying to setPath using a nested path
69
+ * that travels through a scalar value
70
+ */
71
+ public function setPath($path, $value)
72
+ {
73
+ Utils::setPath($this->data, $path, $value);
74
+ }
75
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Message/AbstractMessage.php ADDED
@@ -0,0 +1,253 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Message;
3
+
4
+ use GuzzleHttp\Stream\StreamInterface;
5
+
6
+ abstract class AbstractMessage implements MessageInterface
7
+ {
8
+ /** @var array HTTP header collection */
9
+ private $headers = [];
10
+
11
+ /** @var array mapping a lowercase header name to its name over the wire */
12
+ private $headerNames = [];
13
+
14
+ /** @var StreamInterface Message body */
15
+ private $body;
16
+
17
+ /** @var string HTTP protocol version of the message */
18
+ private $protocolVersion = '1.1';
19
+
20
+ public function __toString()
21
+ {
22
+ return static::getStartLineAndHeaders($this)
23
+ . "\r\n\r\n" . $this->getBody();
24
+ }
25
+
26
+ public function getProtocolVersion()
27
+ {
28
+ return $this->protocolVersion;
29
+ }
30
+
31
+ public function getBody()
32
+ {
33
+ return $this->body;
34
+ }
35
+
36
+ public function setBody(StreamInterface $body = null)
37
+ {
38
+ if ($body === null) {
39
+ // Setting a null body will remove the body of the request
40
+ $this->removeHeader('Content-Length');
41
+ $this->removeHeader('Transfer-Encoding');
42
+ }
43
+
44
+ $this->body = $body;
45
+ }
46
+
47
+ public function addHeader($header, $value)
48
+ {
49
+ if (is_array($value)) {
50
+ $current = array_merge($this->getHeaderAsArray($header), $value);
51
+ } else {
52
+ $current = $this->getHeaderAsArray($header);
53
+ $current[] = (string) $value;
54
+ }
55
+
56
+ $this->setHeader($header, $current);
57
+ }
58
+
59
+ public function addHeaders(array $headers)
60
+ {
61
+ foreach ($headers as $name => $header) {
62
+ $this->addHeader($name, $header);
63
+ }
64
+ }
65
+
66
+ public function getHeader($header)
67
+ {
68
+ $name = strtolower($header);
69
+ return isset($this->headers[$name])
70
+ ? implode(', ', $this->headers[$name])
71
+ : '';
72
+ }
73
+
74
+ public function getHeaderAsArray($header)
75
+ {
76
+ $name = strtolower($header);
77
+ return isset($this->headers[$name]) ? $this->headers[$name] : [];
78
+ }
79
+
80
+ public function getHeaders()
81
+ {
82
+ $headers = [];
83
+ foreach ($this->headers as $name => $values) {
84
+ $headers[$this->headerNames[$name]] = $values;
85
+ }
86
+
87
+ return $headers;
88
+ }
89
+
90
+ public function setHeader($header, $value)
91
+ {
92
+ $header = trim($header);
93
+ $name = strtolower($header);
94
+ $this->headerNames[$name] = $header;
95
+
96
+ if (is_array($value)) {
97
+ foreach ($value as &$v) {
98
+ $v = trim($v);
99
+ }
100
+ $this->headers[$name] = $value;
101
+ } else {
102
+ $this->headers[$name] = [trim($value)];
103
+ }
104
+ }
105
+
106
+ public function setHeaders(array $headers)
107
+ {
108
+ $this->headers = $this->headerNames = [];
109
+ foreach ($headers as $key => $value) {
110
+ $this->setHeader($key, $value);
111
+ }
112
+ }
113
+
114
+ public function hasHeader($header)
115
+ {
116
+ return isset($this->headers[strtolower($header)]);
117
+ }
118
+
119
+ public function removeHeader($header)
120
+ {
121
+ $name = strtolower($header);
122
+ unset($this->headers[$name], $this->headerNames[$name]);
123
+ }
124
+
125
+ /**
126
+ * Parse an array of header values containing ";" separated data into an
127
+ * array of associative arrays representing the header key value pair
128
+ * data of the header. When a parameter does not contain a value, but just
129
+ * contains a key, this function will inject a key with a '' string value.
130
+ *
131
+ * @param MessageInterface $message That contains the header
132
+ * @param string $header Header to retrieve from the message
133
+ *
134
+ * @return array Returns the parsed header values.
135
+ */
136
+ public static function parseHeader(MessageInterface $message, $header)
137
+ {
138
+ static $trimmed = "\"' \n\t\r";
139
+ $params = $matches = [];
140
+
141
+ foreach (self::normalizeHeader($message, $header) as $val) {
142
+ $part = [];
143
+ foreach (preg_split('/;(?=([^"]*"[^"]*")*[^"]*$)/', $val) as $kvp) {
144
+ if (preg_match_all('/<[^>]+>|[^=]+/', $kvp, $matches)) {
145
+ $m = $matches[0];
146
+ if (isset($m[1])) {
147
+ $part[trim($m[0], $trimmed)] = trim($m[1], $trimmed);
148
+ } else {
149
+ $part[] = trim($m[0], $trimmed);
150
+ }
151
+ }
152
+ }
153
+ if ($part) {
154
+ $params[] = $part;
155
+ }
156
+ }
157
+
158
+ return $params;
159
+ }
160
+
161
+ /**
162
+ * Converts an array of header values that may contain comma separated
163
+ * headers into an array of headers with no comma separated values.
164
+ *
165
+ * @param MessageInterface $message That contains the header
166
+ * @param string $header Header to retrieve from the message
167
+ *
168
+ * @return array Returns the normalized header field values.
169
+ */
170
+ public static function normalizeHeader(MessageInterface $message, $header)
171
+ {
172
+ $h = $message->getHeaderAsArray($header);
173
+ for ($i = 0, $total = count($h); $i < $total; $i++) {
174
+ if (strpos($h[$i], ',') === false) {
175
+ continue;
176
+ }
177
+ foreach (preg_split('/,(?=([^"]*"[^"]*")*[^"]*$)/', $h[$i]) as $v) {
178
+ $h[] = trim($v);
179
+ }
180
+ unset($h[$i]);
181
+ }
182
+
183
+ return $h;
184
+ }
185
+
186
+ /**
187
+ * Gets the start-line and headers of a message as a string
188
+ *
189
+ * @param MessageInterface $message
190
+ *
191
+ * @return string
192
+ */
193
+ public static function getStartLineAndHeaders(MessageInterface $message)
194
+ {
195
+ return static::getStartLine($message)
196
+ . self::getHeadersAsString($message);
197
+ }
198
+
199
+ /**
200
+ * Gets the headers of a message as a string
201
+ *
202
+ * @param MessageInterface $message
203
+ *
204
+ * @return string
205
+ */
206
+ public static function getHeadersAsString(MessageInterface $message)
207
+ {
208
+ $result = '';
209
+ foreach ($message->getHeaders() as $name => $values) {
210
+ $result .= "\r\n{$name}: " . implode(', ', $values);
211
+ }
212
+
213
+ return $result;
214
+ }
215
+
216
+ /**
217
+ * Gets the start line of a message
218
+ *
219
+ * @param MessageInterface $message
220
+ *
221
+ * @return string
222
+ * @throws \InvalidArgumentException
223
+ */
224
+ public static function getStartLine(MessageInterface $message)
225
+ {
226
+ if ($message instanceof RequestInterface) {
227
+ return trim($message->getMethod() . ' '
228
+ . $message->getResource())
229
+ . ' HTTP/' . $message->getProtocolVersion();
230
+ } elseif ($message instanceof ResponseInterface) {
231
+ return 'HTTP/' . $message->getProtocolVersion() . ' '
232
+ . $message->getStatusCode() . ' '
233
+ . $message->getReasonPhrase();
234
+ } else {
235
+ throw new \InvalidArgumentException('Unknown message type');
236
+ }
237
+ }
238
+
239
+ /**
240
+ * Accepts and modifies the options provided to the message in the
241
+ * constructor.
242
+ *
243
+ * Can be overridden in subclasses as necessary.
244
+ *
245
+ * @param array $options Options array passed by reference.
246
+ */
247
+ protected function handleOptions(array &$options)
248
+ {
249
+ if (isset($options['protocol_version'])) {
250
+ $this->protocolVersion = $options['protocol_version'];
251
+ }
252
+ }
253
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Message/AppliesHeadersInterface.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Message;
3
+
4
+ /**
5
+ * Applies headers to a request.
6
+ *
7
+ * This interface can be used with Guzzle streams to apply body specific
8
+ * headers to a request during the PREPARE_REQUEST priority of the before event
9
+ *
10
+ * NOTE: a body that implements this interface will prevent a default
11
+ * content-type from being added to a request during the before event. If you
12
+ * want a default content-type to be added, then it will need to be done
13
+ * manually (e.g., using {@see GuzzleHttp\Mimetypes}).
14
+ */
15
+ interface AppliesHeadersInterface
16
+ {
17
+ /**
18
+ * Apply headers to a request appropriate for the current state of the
19
+ * object.
20
+ *
21
+ * @param RequestInterface $request Request
22
+ */
23
+ public function applyRequestHeaders(RequestInterface $request);
24
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Message/FutureResponse.php ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Message;
3
+
4
+ use GuzzleHttp\Ring\Future\MagicFutureTrait;
5
+ use GuzzleHttp\Ring\Future\FutureInterface;
6
+ use GuzzleHttp\Stream\StreamInterface;
7
+
8
+ /**
9
+ * Represents a response that has not been fulfilled.
10
+ *
11
+ * When created, you must provide a function that is used to dereference the
12
+ * future result and return it's value. The function has no arguments and MUST
13
+ * return an instance of a {@see GuzzleHttp\Message\ResponseInterface} object.
14
+ *
15
+ * You can optionally provide a function in the constructor that can be used to
16
+ * cancel the future from completing if possible. This function has no
17
+ * arguments and returns a boolean value representing whether or not the
18
+ * response could be cancelled.
19
+ *
20
+ * @property ResponseInterface $_value
21
+ */
22
+ class FutureResponse implements ResponseInterface, FutureInterface
23
+ {
24
+ use MagicFutureTrait;
25
+
26
+ /**
27
+ * Returns a FutureResponse that wraps another future.
28
+ *
29
+ * @param FutureInterface $future Future to wrap with a new future
30
+ * @param callable $onFulfilled Invoked when the future fulfilled
31
+ * @param callable $onRejected Invoked when the future rejected
32
+ * @param callable $onProgress Invoked when the future progresses
33
+ *
34
+ * @return FutureResponse
35
+ */
36
+ public static function proxy(
37
+ FutureInterface $future,
38
+ callable $onFulfilled = null,
39
+ callable $onRejected = null,
40
+ callable $onProgress = null
41
+ ) {
42
+ return new FutureResponse(
43
+ $future->then($onFulfilled, $onRejected, $onProgress),
44
+ [$future, 'wait'],
45
+ [$future, 'cancel']
46
+ );
47
+ }
48
+
49
+ public function getStatusCode()
50
+ {
51
+ return $this->_value->getStatusCode();
52
+ }
53
+
54
+ public function setStatusCode($code)
55
+ {
56
+ $this->_value->setStatusCode($code);
57
+ }
58
+
59
+ public function getReasonPhrase()
60
+ {
61
+ return $this->_value->getReasonPhrase();
62
+ }
63
+
64
+ public function setReasonPhrase($phrase)
65
+ {
66
+ $this->_value->setReasonPhrase($phrase);
67
+ }
68
+
69
+ public function getEffectiveUrl()
70
+ {
71
+ return $this->_value->getEffectiveUrl();
72
+ }
73
+
74
+ public function setEffectiveUrl($url)
75
+ {
76
+ $this->_value->setEffectiveUrl($url);
77
+ }
78
+
79
+ public function json(array $config = [])
80
+ {
81
+ return $this->_value->json($config);
82
+ }
83
+
84
+ public function xml(array $config = [])
85
+ {
86
+ return $this->_value->xml($config);
87
+ }
88
+
89
+ public function __toString()
90
+ {
91
+ try {
92
+ return $this->_value->__toString();
93
+ } catch (\Exception $e) {
94
+ trigger_error($e->getMessage(), E_USER_WARNING);
95
+ return '';
96
+ }
97
+ }
98
+
99
+ public function getProtocolVersion()
100
+ {
101
+ return $this->_value->getProtocolVersion();
102
+ }
103
+
104
+ public function setBody(StreamInterface $body = null)
105
+ {
106
+ $this->_value->setBody($body);
107
+ }
108
+
109
+ public function getBody()
110
+ {
111
+ return $this->_value->getBody();
112
+ }
113
+
114
+ public function getHeaders()
115
+ {
116
+ return $this->_value->getHeaders();
117
+ }
118
+
119
+ public function getHeader($header)
120
+ {
121
+ return $this->_value->getHeader($header);
122
+ }
123
+
124
+ public function getHeaderAsArray($header)
125
+ {
126
+ return $this->_value->getHeaderAsArray($header);
127
+ }
128
+
129
+ public function hasHeader($header)
130
+ {
131
+ return $this->_value->hasHeader($header);
132
+ }
133
+
134
+ public function removeHeader($header)
135
+ {
136
+ $this->_value->removeHeader($header);
137
+ }
138
+
139
+ public function addHeader($header, $value)
140
+ {
141
+ $this->_value->addHeader($header, $value);
142
+ }
143
+
144
+ public function addHeaders(array $headers)
145
+ {
146
+ $this->_value->addHeaders($headers);
147
+ }
148
+
149
+ public function setHeader($header, $value)
150
+ {
151
+ $this->_value->setHeader($header, $value);
152
+ }
153
+
154
+ public function setHeaders(array $headers)
155
+ {
156
+ $this->_value->setHeaders($headers);
157
+ }
158
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Message/MessageFactory.php ADDED
@@ -0,0 +1,364 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Message;
3
+
4
+ use GuzzleHttp\Cookie\CookieJar;
5
+ use GuzzleHttp\Cookie\CookieJarInterface;
6
+ use GuzzleHttp\Event\ListenerAttacherTrait;
7
+ use GuzzleHttp\Post\PostBody;
8
+ use GuzzleHttp\Post\PostFile;
9
+ use GuzzleHttp\Post\PostFileInterface;
10
+ use GuzzleHttp\Query;
11
+ use GuzzleHttp\Stream\Stream;
12
+ use GuzzleHttp\Subscriber\Cookie;
13
+ use GuzzleHttp\Subscriber\HttpError;
14
+ use GuzzleHttp\Subscriber\Redirect;
15
+ use GuzzleHttp\Url;
16
+ use \InvalidArgumentException as Iae;
17
+
18
+ /**
19
+ * Default HTTP request factory used to create Request and Response objects.
20
+ */
21
+ class MessageFactory implements MessageFactoryInterface
22
+ {
23
+ use ListenerAttacherTrait;
24
+
25
+ /** @var HttpError */
26
+ private $errorPlugin;
27
+
28
+ /** @var Redirect */
29
+ private $redirectPlugin;
30
+
31
+ /** @var array */
32
+ private $customOptions;
33
+
34
+ /** @var array Request options passed through to request Config object */
35
+ private static $configMap = [
36
+ 'connect_timeout' => 1, 'timeout' => 1, 'verify' => 1, 'ssl_key' => 1,
37
+ 'cert' => 1, 'proxy' => 1, 'debug' => 1, 'save_to' => 1, 'stream' => 1,
38
+ 'expect' => 1, 'future' => 1
39
+ ];
40
+
41
+ /** @var array Default allow_redirects request option settings */
42
+ private static $defaultRedirect = [
43
+ 'max' => 5,
44
+ 'strict' => false,
45
+ 'referer' => false,
46
+ 'protocols' => ['http', 'https']
47
+ ];
48
+
49
+ /**
50
+ * @param array $customOptions Associative array of custom request option
51
+ * names mapping to functions used to apply
52
+ * the option. The function accepts the request
53
+ * and the option value to apply.
54
+ */
55
+ public function __construct(array $customOptions = [])
56
+ {
57
+ $this->errorPlugin = new HttpError();
58
+ $this->redirectPlugin = new Redirect();
59
+ $this->customOptions = $customOptions;
60
+ }
61
+
62
+ public function createResponse(
63
+ $statusCode,
64
+ array $headers = [],
65
+ $body = null,
66
+ array $options = []
67
+ ) {
68
+ if (null !== $body) {
69
+ $body = Stream::factory($body);
70
+ }
71
+
72
+ return new Response($statusCode, $headers, $body, $options);
73
+ }
74
+
75
+ public function createRequest($method, $url, array $options = [])
76
+ {
77
+ // Handle the request protocol version option that needs to be
78
+ // specified in the request constructor.
79
+ if (isset($options['version'])) {
80
+ $options['config']['protocol_version'] = $options['version'];
81
+ unset($options['version']);
82
+ }
83
+
84
+ $request = new Request($method, $url, [], null,
85
+ isset($options['config']) ? $options['config'] : []);
86
+
87
+ unset($options['config']);
88
+
89
+ // Use a POST body by default
90
+ if ($method == 'POST'
91
+ && !isset($options['body'])
92
+ && !isset($options['json'])
93
+ ) {
94
+ $options['body'] = [];
95
+ }
96
+
97
+ if ($options) {
98
+ $this->applyOptions($request, $options);
99
+ }
100
+
101
+ return $request;
102
+ }
103
+
104
+ /**
105
+ * Create a request or response object from an HTTP message string
106
+ *
107
+ * @param string $message Message to parse
108
+ *
109
+ * @return RequestInterface|ResponseInterface
110
+ * @throws \InvalidArgumentException if unable to parse a message
111
+ */
112
+ public function fromMessage($message)
113
+ {
114
+ static $parser;
115
+ if (!$parser) {
116
+ $parser = new MessageParser();
117
+ }
118
+
119
+ // Parse a response
120
+ if (strtoupper(substr($message, 0, 4)) == 'HTTP') {
121
+ $data = $parser->parseResponse($message);
122
+ return $this->createResponse(
123
+ $data['code'],
124
+ $data['headers'],
125
+ $data['body'] === '' ? null : $data['body'],
126
+ $data
127
+ );
128
+ }
129
+
130
+ // Parse a request
131
+ if (!($data = ($parser->parseRequest($message)))) {
132
+ throw new \InvalidArgumentException('Unable to parse request');
133
+ }
134
+
135
+ return $this->createRequest(
136
+ $data['method'],
137
+ Url::buildUrl($data['request_url']),
138
+ [
139
+ 'headers' => $data['headers'],
140
+ 'body' => $data['body'] === '' ? null : $data['body'],
141
+ 'config' => [
142
+ 'protocol_version' => $data['protocol_version']
143
+ ]
144
+ ]
145
+ );
146
+ }
147
+
148
+ /**
149
+ * Apply POST fields and files to a request to attempt to give an accurate
150
+ * representation.
151
+ *
152
+ * @param RequestInterface $request Request to update
153
+ * @param array $body Body to apply
154
+ */
155
+ protected function addPostData(RequestInterface $request, array $body)
156
+ {
157
+ static $fields = ['string' => true, 'array' => true, 'NULL' => true,
158
+ 'boolean' => true, 'double' => true, 'integer' => true];
159
+
160
+ $post = new PostBody();
161
+ foreach ($body as $key => $value) {
162
+ if (isset($fields[gettype($value)])) {
163
+ $post->setField($key, $value);
164
+ } elseif ($value instanceof PostFileInterface) {
165
+ $post->addFile($value);
166
+ } else {
167
+ $post->addFile(new PostFile($key, $value));
168
+ }
169
+ }
170
+
171
+ if ($request->getHeader('Content-Type') == 'multipart/form-data') {
172
+ $post->forceMultipartUpload(true);
173
+ }
174
+
175
+ $request->setBody($post);
176
+ }
177
+
178
+ protected function applyOptions(
179
+ RequestInterface $request,
180
+ array $options = []
181
+ ) {
182
+ $config = $request->getConfig();
183
+ $emitter = $request->getEmitter();
184
+
185
+ foreach ($options as $key => $value) {
186
+
187
+ if (isset(self::$configMap[$key])) {
188
+ $config[$key] = $value;
189
+ continue;
190
+ }
191
+
192
+ switch ($key) {
193
+
194
+ case 'allow_redirects':
195
+
196
+ if ($value === false) {
197
+ continue;
198
+ }
199
+
200
+ if ($value === true) {
201
+ $value = self::$defaultRedirect;
202
+ } elseif (!is_array($value)) {
203
+ throw new Iae('allow_redirects must be true, false, or array');
204
+ } else {
205
+ // Merge the default settings with the provided settings
206
+ $value += self::$defaultRedirect;
207
+ }
208
+
209
+ $config['redirect'] = $value;
210
+ $emitter->attach($this->redirectPlugin);
211
+ break;
212
+
213
+ case 'decode_content':
214
+
215
+ if ($value === false) {
216
+ continue;
217
+ }
218
+
219
+ $config['decode_content'] = true;
220
+ if ($value !== true) {
221
+ $request->setHeader('Accept-Encoding', $value);
222
+ }
223
+ break;
224
+
225
+ case 'headers':
226
+
227
+ if (!is_array($value)) {
228
+ throw new Iae('header value must be an array');
229
+ }
230
+ foreach ($value as $k => $v) {
231
+ $request->setHeader($k, $v);
232
+ }
233
+ break;
234
+
235
+ case 'exceptions':
236
+
237
+ if ($value === true) {
238
+ $emitter->attach($this->errorPlugin);
239
+ }
240
+ break;
241
+
242
+ case 'body':
243
+
244
+ if (is_array($value)) {
245
+ $this->addPostData($request, $value);
246
+ } elseif ($value !== null) {
247
+ $request->setBody(Stream::factory($value));
248
+ }
249
+ break;
250
+
251
+ case 'auth':
252
+
253
+ if (!$value) {
254
+ continue;
255
+ }
256
+
257
+ if (is_array($value)) {
258
+ $type = isset($value[2]) ? strtolower($value[2]) : 'basic';
259
+ } else {
260
+ $type = strtolower($value);
261
+ }
262
+
263
+ $config['auth'] = $value;
264
+
265
+ if ($type == 'basic') {
266
+ $request->setHeader(
267
+ 'Authorization',
268
+ 'Basic ' . base64_encode("$value[0]:$value[1]")
269
+ );
270
+ } elseif ($type == 'digest') {
271
+ // @todo: Do not rely on curl
272
+ $config->setPath('curl/' . CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
273
+ $config->setPath('curl/' . CURLOPT_USERPWD, "$value[0]:$value[1]");
274
+ }
275
+ break;
276
+
277
+ case 'query':
278
+
279
+ if ($value instanceof Query) {
280
+ $original = $request->getQuery();
281
+ // Do not overwrite existing query string variables by
282
+ // overwriting the object with the query string data passed
283
+ // in the URL
284
+ $value->overwriteWith($original->toArray());
285
+ $request->setQuery($value);
286
+ } elseif (is_array($value)) {
287
+ // Do not overwrite existing query string variables
288
+ $query = $request->getQuery();
289
+ foreach ($value as $k => $v) {
290
+ if (!isset($query[$k])) {
291
+ $query[$k] = $v;
292
+ }
293
+ }
294
+ } else {
295
+ throw new Iae('query must be an array or Query object');
296
+ }
297
+ break;
298
+
299
+ case 'cookies':
300
+
301
+ if ($value === true) {
302
+ static $cookie = null;
303
+ if (!$cookie) {
304
+ $cookie = new Cookie();
305
+ }
306
+ $emitter->attach($cookie);
307
+ } elseif (is_array($value)) {
308
+ $emitter->attach(
309
+ new Cookie(CookieJar::fromArray($value, $request->getHost()))
310
+ );
311
+ } elseif ($value instanceof CookieJarInterface) {
312
+ $emitter->attach(new Cookie($value));
313
+ } elseif ($value !== false) {
314
+ throw new Iae('cookies must be an array, true, or CookieJarInterface');
315
+ }
316
+ break;
317
+
318
+ case 'events':
319
+
320
+ if (!is_array($value)) {
321
+ throw new Iae('events must be an array');
322
+ }
323
+
324
+ $this->attachListeners($request,
325
+ $this->prepareListeners(
326
+ $value,
327
+ ['before', 'complete', 'error', 'progress', 'end']
328
+ )
329
+ );
330
+ break;
331
+
332
+ case 'subscribers':
333
+
334
+ if (!is_array($value)) {
335
+ throw new Iae('subscribers must be an array');
336
+ }
337
+
338
+ foreach ($value as $subscribers) {
339
+ $emitter->attach($subscribers);
340
+ }
341
+ break;
342
+
343
+ case 'json':
344
+
345
+ $request->setBody(Stream::factory(json_encode($value)));
346
+ if (!$request->hasHeader('Content-Type')) {
347
+ $request->setHeader('Content-Type', 'application/json');
348
+ }
349
+ break;
350
+
351
+ default:
352
+
353
+ // Check for custom handler functions.
354
+ if (isset($this->customOptions[$key])) {
355
+ $fn = $this->customOptions[$key];
356
+ $fn($request, $value);
357
+ continue;
358
+ }
359
+
360
+ throw new Iae("No method can handle the {$key} config key");
361
+ }
362
+ }
363
+ }
364
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Message/MessageFactoryInterface.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Message;
3
+
4
+ use GuzzleHttp\Url;
5
+
6
+ /**
7
+ * Request and response factory
8
+ */
9
+ interface MessageFactoryInterface
10
+ {
11
+ /**
12
+ * Creates a response
13
+ *
14
+ * @param string $statusCode HTTP status code
15
+ * @param array $headers Response headers
16
+ * @param mixed $body Response body
17
+ * @param array $options Response options
18
+ * - protocol_version: HTTP protocol version
19
+ * - header_factory: Factory used to create headers
20
+ * - And any other options used by a concrete message implementation
21
+ *
22
+ * @return ResponseInterface
23
+ */
24
+ public function createResponse(
25
+ $statusCode,
26
+ array $headers = [],
27
+ $body = null,
28
+ array $options = []
29
+ );
30
+
31
+ /**
32
+ * Create a new request based on the HTTP method.
33
+ *
34
+ * This method accepts an associative array of request options. Below is a
35
+ * brief description of each parameter. See
36
+ * http://docs.guzzlephp.org/en/latest/clients.html#request-options for a much more
37
+ * in-depth description of each parameter.
38
+ *
39
+ * - headers: Associative array of headers to add to the request
40
+ * - body: string|resource|array|StreamInterface request body to send
41
+ * - json: mixed Uploads JSON encoded data using an application/json Content-Type header.
42
+ * - query: Associative array of query string values to add to the request
43
+ * - auth: array|string HTTP auth settings (user, pass[, type="basic"])
44
+ * - version: The HTTP protocol version to use with the request
45
+ * - cookies: true|false|CookieJarInterface To enable or disable cookies
46
+ * - allow_redirects: true|false|array Controls HTTP redirects
47
+ * - save_to: string|resource|StreamInterface Where the response is saved
48
+ * - events: Associative array of event names to callables or arrays
49
+ * - subscribers: Array of event subscribers to add to the request
50
+ * - exceptions: Specifies whether or not exceptions are thrown for HTTP protocol errors
51
+ * - timeout: Timeout of the request in seconds. Use 0 to wait indefinitely
52
+ * - connect_timeout: Number of seconds to wait while trying to connect. (0 to wait indefinitely)
53
+ * - verify: SSL validation. True/False or the path to a PEM file
54
+ * - cert: Path a SSL cert or array of (path, pwd)
55
+ * - ssl_key: Path to a private SSL key or array of (path, pwd)
56
+ * - proxy: Specify an HTTP proxy or hash of protocols to proxies
57
+ * - debug: Set to true or a resource to view handler specific debug info
58
+ * - stream: Set to true to stream a response body rather than download it all up front
59
+ * - expect: true/false/integer Controls the "Expect: 100-Continue" header
60
+ * - config: Associative array of request config collection options
61
+ * - decode_content: true/false/string to control decoding content-encoding responses
62
+ *
63
+ * @param string $method HTTP method (GET, POST, PUT, etc.)
64
+ * @param string|Url $url HTTP URL to connect to
65
+ * @param array $options Array of options to apply to the request
66
+ *
67
+ * @return RequestInterface
68
+ * @link http://docs.guzzlephp.org/en/latest/clients.html#request-options
69
+ */
70
+ public function createRequest($method, $url, array $options = []);
71
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Message/MessageInterface.php ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Message;
3
+
4
+ use GuzzleHttp\Stream\StreamInterface;
5
+
6
+ /**
7
+ * Request and response message interface
8
+ */
9
+ interface MessageInterface
10
+ {
11
+ /**
12
+ * Get a string representation of the message
13
+ *
14
+ * @return string
15
+ */
16
+ public function __toString();
17
+
18
+ /**
19
+ * Get the HTTP protocol version of the message
20
+ *
21
+ * @return string
22
+ */
23
+ public function getProtocolVersion();
24
+
25
+ /**
26
+ * Sets the body of the message.
27
+ *
28
+ * The body MUST be a StreamInterface object. Setting the body to null MUST
29
+ * remove the existing body.
30
+ *
31
+ * @param StreamInterface|null $body Body.
32
+ */
33
+ public function setBody(StreamInterface $body = null);
34
+
35
+ /**
36
+ * Get the body of the message
37
+ *
38
+ * @return StreamInterface|null
39
+ */
40
+ public function getBody();
41
+
42
+ /**
43
+ * Gets all message headers.
44
+ *
45
+ * The keys represent the header name as it will be sent over the wire, and
46
+ * each value is an array of strings associated with the header.
47
+ *
48
+ * // Represent the headers as a string
49
+ * foreach ($message->getHeaders() as $name => $values) {
50
+ * echo $name . ": " . implode(", ", $values);
51
+ * }
52
+ *
53
+ * @return array Returns an associative array of the message's headers.
54
+ */
55
+ public function getHeaders();
56
+
57
+ /**
58
+ * Retrieve a header by the given case-insensitive name.
59
+ *
60
+ * @param string $header Case-insensitive header name.
61
+ *
62
+ * @return string
63
+ */
64
+ public function getHeader($header);
65
+
66
+ /**
67
+ * Retrieves a header by the given case-insensitive name as an array of strings.
68
+ *
69
+ * @param string $header Case-insensitive header name.
70
+ *
71
+ * @return string[]
72
+ */
73
+ public function getHeaderAsArray($header);
74
+
75
+ /**
76
+ * Checks if a header exists by the given case-insensitive name.
77
+ *
78
+ * @param string $header Case-insensitive header name.
79
+ *
80
+ * @return bool Returns true if any header names match the given header
81
+ * name using a case-insensitive string comparison. Returns false if
82
+ * no matching header name is found in the message.
83
+ */
84
+ public function hasHeader($header);
85
+
86
+ /**
87
+ * Remove a specific header by case-insensitive name.
88
+ *
89
+ * @param string $header Case-insensitive header name.
90
+ */
91
+ public function removeHeader($header);
92
+
93
+ /**
94
+ * Appends a header value to any existing values associated with the
95
+ * given header name.
96
+ *
97
+ * @param string $header Header name to add
98
+ * @param string $value Value of the header
99
+ */
100
+ public function addHeader($header, $value);
101
+
102
+ /**
103
+ * Merges in an associative array of headers.
104
+ *
105
+ * Each array key MUST be a string representing the case-insensitive name
106
+ * of a header. Each value MUST be either a string or an array of strings.
107
+ * For each value, the value is appended to any existing header of the same
108
+ * name, or, if a header does not already exist by the given name, then the
109
+ * header is added.
110
+ *
111
+ * @param array $headers Associative array of headers to add to the message
112
+ */
113
+ public function addHeaders(array $headers);
114
+
115
+ /**
116
+ * Sets a header, replacing any existing values of any headers with the
117
+ * same case-insensitive name.
118
+ *
119
+ * The header values MUST be a string or an array of strings.
120
+ *
121
+ * @param string $header Header name
122
+ * @param string|array $value Header value(s)
123
+ */
124
+ public function setHeader($header, $value);
125
+
126
+ /**
127
+ * Sets headers, replacing any headers that have already been set on the
128
+ * message.
129
+ *
130
+ * The array keys MUST be a string. The array values must be either a
131
+ * string or an array of strings.
132
+ *
133
+ * @param array $headers Headers to set.
134
+ */
135
+ public function setHeaders(array $headers);
136
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Message/MessageParser.php ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Message;
3
+
4
+ /**
5
+ * Request and response parser used by Guzzle
6
+ */
7
+ class MessageParser
8
+ {
9
+ /**
10
+ * Parse an HTTP request message into an associative array of parts.
11
+ *
12
+ * @param string $message HTTP request to parse
13
+ *
14
+ * @return array|bool Returns false if the message is invalid
15
+ */
16
+ public function parseRequest($message)
17
+ {
18
+ if (!($parts = $this->parseMessage($message))) {
19
+ return false;
20
+ }
21
+
22
+ // Parse the protocol and protocol version
23
+ if (isset($parts['start_line'][2])) {
24
+ $startParts = explode('/', $parts['start_line'][2]);
25
+ $protocol = strtoupper($startParts[0]);
26
+ $version = isset($startParts[1]) ? $startParts[1] : '1.1';
27
+ } else {
28
+ $protocol = 'HTTP';
29
+ $version = '1.1';
30
+ }
31
+
32
+ $parsed = [
33
+ 'method' => strtoupper($parts['start_line'][0]),
34
+ 'protocol' => $protocol,
35
+ 'protocol_version' => $version,
36
+ 'headers' => $parts['headers'],
37
+ 'body' => $parts['body']
38
+ ];
39
+
40
+ $parsed['request_url'] = $this->getUrlPartsFromMessage(
41
+ (isset($parts['start_line'][1]) ? $parts['start_line'][1] : ''), $parsed);
42
+
43
+ return $parsed;
44
+ }
45
+
46
+ /**
47
+ * Parse an HTTP response message into an associative array of parts.
48
+ *
49
+ * @param string $message HTTP response to parse
50
+ *
51
+ * @return array|bool Returns false if the message is invalid
52
+ */
53
+ public function parseResponse($message)
54
+ {
55
+ if (!($parts = $this->parseMessage($message))) {
56
+ return false;
57
+ }
58
+
59
+ list($protocol, $version) = explode('/', trim($parts['start_line'][0]));
60
+
61
+ return [
62
+ 'protocol' => $protocol,
63
+ 'protocol_version' => $version,
64
+ 'code' => $parts['start_line'][1],
65
+ 'reason_phrase' => isset($parts['start_line'][2]) ? $parts['start_line'][2] : '',
66
+ 'headers' => $parts['headers'],
67
+ 'body' => $parts['body']
68
+ ];
69
+ }
70
+
71
+ /**
72
+ * Parse a message into parts
73
+ *
74
+ * @param string $message Message to parse
75
+ *
76
+ * @return array|bool
77
+ */
78
+ private function parseMessage($message)
79
+ {
80
+ if (!$message) {
81
+ return false;
82
+ }
83
+
84
+ $startLine = null;
85
+ $headers = [];
86
+ $body = '';
87
+
88
+ // Iterate over each line in the message, accounting for line endings
89
+ $lines = preg_split('/(\\r?\\n)/', $message, -1, PREG_SPLIT_DELIM_CAPTURE);
90
+ for ($i = 0, $totalLines = count($lines); $i < $totalLines; $i += 2) {
91
+
92
+ $line = $lines[$i];
93
+
94
+ // If two line breaks were encountered, then this is the end of body
95
+ if (empty($line)) {
96
+ if ($i < $totalLines - 1) {
97
+ $body = implode('', array_slice($lines, $i + 2));
98
+ }
99
+ break;
100
+ }
101
+
102
+ // Parse message headers
103
+ if (!$startLine) {
104
+ $startLine = explode(' ', $line, 3);
105
+ } elseif (strpos($line, ':')) {
106
+ $parts = explode(':', $line, 2);
107
+ $key = trim($parts[0]);
108
+ $value = isset($parts[1]) ? trim($parts[1]) : '';
109
+ if (!isset($headers[$key])) {
110
+ $headers[$key] = $value;
111
+ } elseif (!is_array($headers[$key])) {
112
+ $headers[$key] = [$headers[$key], $value];
113
+ } else {
114
+ $headers[$key][] = $value;
115
+ }
116
+ }
117
+ }
118
+
119
+ return [
120
+ 'start_line' => $startLine,
121
+ 'headers' => $headers,
122
+ 'body' => $body
123
+ ];
124
+ }
125
+
126
+ /**
127
+ * Create URL parts from HTTP message parts
128
+ *
129
+ * @param string $requestUrl Associated URL
130
+ * @param array $parts HTTP message parts
131
+ *
132
+ * @return array
133
+ */
134
+ private function getUrlPartsFromMessage($requestUrl, array $parts)
135
+ {
136
+ // Parse the URL information from the message
137
+ $urlParts = ['path' => $requestUrl, 'scheme' => 'http'];
138
+
139
+ // Check for the Host header
140
+ if (isset($parts['headers']['Host'])) {
141
+ $urlParts['host'] = $parts['headers']['Host'];
142
+ } elseif (isset($parts['headers']['host'])) {
143
+ $urlParts['host'] = $parts['headers']['host'];
144
+ } else {
145
+ $urlParts['host'] = null;
146
+ }
147
+
148
+ if (false === strpos($urlParts['host'], ':')) {
149
+ $urlParts['port'] = '';
150
+ } else {
151
+ $hostParts = explode(':', $urlParts['host']);
152
+ $urlParts['host'] = trim($hostParts[0]);
153
+ $urlParts['port'] = (int) trim($hostParts[1]);
154
+ if ($urlParts['port'] == 443) {
155
+ $urlParts['scheme'] = 'https';
156
+ }
157
+ }
158
+
159
+ // Check if a query is present
160
+ $path = $urlParts['path'];
161
+ $qpos = strpos($path, '?');
162
+ if ($qpos) {
163
+ $urlParts['query'] = substr($path, $qpos + 1);
164
+ $urlParts['path'] = substr($path, 0, $qpos);
165
+ } else {
166
+ $urlParts['query'] = '';
167
+ }
168
+
169
+ return $urlParts;
170
+ }
171
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Message/Request.php ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Message;
3
+
4
+ use GuzzleHttp\Collection;
5
+ use GuzzleHttp\Event\HasEmitterTrait;
6
+ use GuzzleHttp\Subscriber\Prepare;
7
+ use GuzzleHttp\Url;
8
+
9
+ /**
10
+ * HTTP request class to send requests
11
+ */
12
+ class Request extends AbstractMessage implements RequestInterface
13
+ {
14
+ use HasEmitterTrait;
15
+
16
+ /** @var Url HTTP Url */
17
+ private $url;
18
+
19
+ /** @var string HTTP method */
20
+ private $method;
21
+
22
+ /** @var Collection Transfer options */
23
+ private $transferOptions;
24
+
25
+ /**
26
+ * @param string $method HTTP method
27
+ * @param string|Url $url HTTP URL to connect to. The URI scheme,
28
+ * host header, and URI are parsed from the full URL. If query string
29
+ * parameters are present they will be parsed as well.
30
+ * @param array|Collection $headers HTTP headers
31
+ * @param mixed $body Body to send with the request
32
+ * @param array $options Array of options to use with the request
33
+ * - emitter: Event emitter to use with the request
34
+ */
35
+ public function __construct(
36
+ $method,
37
+ $url,
38
+ $headers = [],
39
+ $body = null,
40
+ array $options = []
41
+ ) {
42
+ $this->setUrl($url);
43
+ $this->method = strtoupper($method);
44
+ $this->handleOptions($options);
45
+ $this->transferOptions = new Collection($options);
46
+ $this->addPrepareEvent();
47
+
48
+ if ($body !== null) {
49
+ $this->setBody($body);
50
+ }
51
+
52
+ if ($headers) {
53
+ foreach ($headers as $key => $value) {
54
+ $this->addHeader($key, $value);
55
+ }
56
+ }
57
+ }
58
+
59
+ public function __clone()
60
+ {
61
+ if ($this->emitter) {
62
+ $this->emitter = clone $this->emitter;
63
+ }
64
+ $this->transferOptions = clone $this->transferOptions;
65
+ $this->url = clone $this->url;
66
+ }
67
+
68
+ public function setUrl($url)
69
+ {
70
+ $this->url = $url instanceof Url ? $url : Url::fromString($url);
71
+ $this->updateHostHeaderFromUrl();
72
+ }
73
+
74
+ public function getUrl()
75
+ {
76
+ return (string) $this->url;
77
+ }
78
+
79
+ public function setQuery($query)
80
+ {
81
+ $this->url->setQuery($query);
82
+ }
83
+
84
+ public function getQuery()
85
+ {
86
+ return $this->url->getQuery();
87
+ }
88
+
89
+ public function setMethod($method)
90
+ {
91
+ $this->method = strtoupper($method);
92
+ }
93
+
94
+ public function getMethod()
95
+ {
96
+ return $this->method;
97
+ }
98
+
99
+ public function getScheme()
100
+ {
101
+ return $this->url->getScheme();
102
+ }
103
+
104
+ public function setScheme($scheme)
105
+ {
106
+ $this->url->setScheme($scheme);
107
+ }
108
+
109
+ public function getPort()
110
+ {
111
+ return $this->url->getPort();
112
+ }
113
+
114
+ public function setPort($port)
115
+ {
116
+ $this->url->setPort($port);
117
+ $this->updateHostHeaderFromUrl();
118
+ }
119
+
120
+ public function getHost()
121
+ {
122
+ return $this->url->getHost();
123
+ }
124
+
125
+ public function setHost($host)
126
+ {
127
+ $this->url->setHost($host);
128
+ $this->updateHostHeaderFromUrl();
129
+ }
130
+
131
+ public function getPath()
132
+ {
133
+ return '/' . ltrim($this->url->getPath(), '/');
134
+ }
135
+
136
+ public function setPath($path)
137
+ {
138
+ $this->url->setPath($path);
139
+ }
140
+
141
+ public function getResource()
142
+ {
143
+ $resource = $this->getPath();
144
+ if ($query = (string) $this->url->getQuery()) {
145
+ $resource .= '?' . $query;
146
+ }
147
+
148
+ return $resource;
149
+ }
150
+
151
+ public function getConfig()
152
+ {
153
+ return $this->transferOptions;
154
+ }
155
+
156
+ protected function handleOptions(array &$options)
157
+ {
158
+ parent::handleOptions($options);
159
+ // Use a custom emitter if one is specified, and remove it from
160
+ // options that are exposed through getConfig()
161
+ if (isset($options['emitter'])) {
162
+ $this->emitter = $options['emitter'];
163
+ unset($options['emitter']);
164
+ }
165
+ }
166
+
167
+ /**
168
+ * Adds a subscriber that ensures a request's body is prepared before
169
+ * sending.
170
+ */
171
+ private function addPrepareEvent()
172
+ {
173
+ static $subscriber;
174
+ if (!$subscriber) {
175
+ $subscriber = new Prepare();
176
+ }
177
+
178
+ $this->getEmitter()->attach($subscriber);
179
+ }
180
+
181
+ private function updateHostHeaderFromUrl()
182
+ {
183
+ $port = $this->url->getPort();
184
+ $scheme = $this->url->getScheme();
185
+ if ($host = $this->url->getHost()) {
186
+ if (($port == 80 && $scheme == 'http') ||
187
+ ($port == 443 && $scheme == 'https')
188
+ ) {
189
+ $this->setHeader('Host', $host);
190
+ } else {
191
+ $this->setHeader('Host', "{$host}:{$port}");
192
+ }
193
+ }
194
+ }
195
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Message/RequestInterface.php ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Message;
3
+
4
+ use GuzzleHttp\Event\HasEmitterInterface;
5
+ use GuzzleHttp\Query;
6
+
7
+ /**
8
+ * Generic HTTP request interface
9
+ */
10
+ interface RequestInterface extends MessageInterface, HasEmitterInterface
11
+ {
12
+ /**
13
+ * Sets the request URL.
14
+ *
15
+ * The URL MUST be a string, or an object that implements the
16
+ * `__toString()` method.
17
+ *
18
+ * @param string $url Request URL.
19
+ *
20
+ * @throws \InvalidArgumentException If the URL is invalid.
21
+ */
22
+ public function setUrl($url);
23
+
24
+ /**
25
+ * Gets the request URL as a string.
26
+ *
27
+ * @return string Returns the URL as a string.
28
+ */
29
+ public function getUrl();
30
+
31
+ /**
32
+ * Get the resource part of the the request, including the path, query
33
+ * string, and fragment.
34
+ *
35
+ * @return string
36
+ */
37
+ public function getResource();
38
+
39
+ /**
40
+ * Get the collection of key value pairs that will be used as the query
41
+ * string in the request.
42
+ *
43
+ * @return Query
44
+ */
45
+ public function getQuery();
46
+
47
+ /**
48
+ * Set the query string used by the request
49
+ *
50
+ * @param array|Query $query Query to set
51
+ */
52
+ public function setQuery($query);
53
+
54
+ /**
55
+ * Get the HTTP method of the request.
56
+ *
57
+ * @return string
58
+ */
59
+ public function getMethod();
60
+
61
+ /**
62
+ * Set the HTTP method of the request.
63
+ *
64
+ * @param string $method HTTP method
65
+ */
66
+ public function setMethod($method);
67
+
68
+ /**
69
+ * Get the URI scheme of the request (http, https, etc.).
70
+ *
71
+ * @return string
72
+ */
73
+ public function getScheme();
74
+
75
+ /**
76
+ * Set the URI scheme of the request (http, https, etc.).
77
+ *
78
+ * @param string $scheme Scheme to set
79
+ */
80
+ public function setScheme($scheme);
81
+
82
+ /**
83
+ * Get the port scheme of the request (e.g., 80, 443, etc.).
84
+ *
85
+ * @return int
86
+ */
87
+ public function getPort();
88
+
89
+ /**
90
+ * Set the port of the request.
91
+ *
92
+ * Setting a port modifies the Host header of a request as necessary.
93
+ *
94
+ * @param int $port Port to set
95
+ */
96
+ public function setPort($port);
97
+
98
+ /**
99
+ * Get the host of the request.
100
+ *
101
+ * @return string
102
+ */
103
+ public function getHost();
104
+
105
+ /**
106
+ * Set the host of the request including an optional port.
107
+ *
108
+ * Including a port in the host argument will explicitly change the port of
109
+ * the request. If no port is found, the default port of the current
110
+ * request scheme will be utilized.
111
+ *
112
+ * @param string $host Host to set (e.g. www.yahoo.com, www.yahoo.com:80)
113
+ */
114
+ public function setHost($host);
115
+
116
+ /**
117
+ * Get the path of the request (e.g. '/', '/index.html').
118
+ *
119
+ * @return string
120
+ */
121
+ public function getPath();
122
+
123
+ /**
124
+ * Set the path of the request (e.g. '/', '/index.html').
125
+ *
126
+ * @param string|array $path Path to set or array of segments to implode
127
+ */
128
+ public function setPath($path);
129
+
130
+ /**
131
+ * Get the request's configuration options.
132
+ *
133
+ * @return \GuzzleHttp\Collection
134
+ */
135
+ public function getConfig();
136
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Message/Response.php ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Message;
3
+
4
+ use GuzzleHttp\Exception\ParseException;
5
+ use GuzzleHttp\Exception\XmlParseException;
6
+ use GuzzleHttp\Stream\StreamInterface;
7
+ use GuzzleHttp\Utils;
8
+
9
+ /**
10
+ * Guzzle HTTP response object
11
+ */
12
+ class Response extends AbstractMessage implements ResponseInterface
13
+ {
14
+ /** @var array Mapping of status codes to reason phrases */
15
+ private static $statusTexts = [
16
+ 100 => 'Continue',
17
+ 101 => 'Switching Protocols',
18
+ 102 => 'Processing',
19
+ 200 => 'OK',
20
+ 201 => 'Created',
21
+ 202 => 'Accepted',
22
+ 203 => 'Non-Authoritative Information',
23
+ 204 => 'No Content',
24
+ 205 => 'Reset Content',
25
+ 206 => 'Partial Content',
26
+ 207 => 'Multi-Status',
27
+ 208 => 'Already Reported',
28
+ 226 => 'IM Used',
29
+ 300 => 'Multiple Choices',
30
+ 301 => 'Moved Permanently',
31
+ 302 => 'Found',
32
+ 303 => 'See Other',
33
+ 304 => 'Not Modified',
34
+ 305 => 'Use Proxy',
35
+ 307 => 'Temporary Redirect',
36
+ 308 => 'Permanent Redirect',
37
+ 400 => 'Bad Request',
38
+ 401 => 'Unauthorized',
39
+ 402 => 'Payment Required',
40
+ 403 => 'Forbidden',
41
+ 404 => 'Not Found',
42
+ 405 => 'Method Not Allowed',
43
+ 406 => 'Not Acceptable',
44
+ 407 => 'Proxy Authentication Required',
45
+ 408 => 'Request Timeout',
46
+ 409 => 'Conflict',
47
+ 410 => 'Gone',
48
+ 411 => 'Length Required',
49
+ 412 => 'Precondition Failed',
50
+ 413 => 'Request Entity Too Large',
51
+ 414 => 'Request-URI Too Long',
52
+ 415 => 'Unsupported Media Type',
53
+ 416 => 'Requested Range Not Satisfiable',
54
+ 417 => 'Expectation Failed',
55
+ 422 => 'Unprocessable Entity',
56
+ 423 => 'Locked',
57
+ 424 => 'Failed Dependency',
58
+ 425 => 'Reserved for WebDAV advanced collections expired proposal',
59
+ 426 => 'Upgrade required',
60
+ 428 => 'Precondition Required',
61
+ 429 => 'Too Many Requests',
62
+ 431 => 'Request Header Fields Too Large',
63
+ 500 => 'Internal Server Error',
64
+ 501 => 'Not Implemented',
65
+ 502 => 'Bad Gateway',
66
+ 503 => 'Service Unavailable',
67
+ 504 => 'Gateway Timeout',
68
+ 505 => 'HTTP Version Not Supported',
69
+ 506 => 'Variant Also Negotiates (Experimental)',
70
+ 507 => 'Insufficient Storage',
71
+ 508 => 'Loop Detected',
72
+ 510 => 'Not Extended',
73
+ 511 => 'Network Authentication Required',
74
+ ];
75
+
76
+ /** @var string The reason phrase of the response (human readable code) */
77
+ private $reasonPhrase;
78
+
79
+ /** @var string The status code of the response */
80
+ private $statusCode;
81
+
82
+ /** @var string The effective URL that returned this response */
83
+ private $effectiveUrl;
84
+
85
+ /**
86
+ * @param int|string $statusCode The response status code (e.g. 200)
87
+ * @param array $headers The response headers
88
+ * @param StreamInterface $body The body of the response
89
+ * @param array $options Response message options
90
+ * - reason_phrase: Set a custom reason phrase
91
+ * - protocol_version: Set a custom protocol version
92
+ */
93
+ public function __construct(
94
+ $statusCode,
95
+ array $headers = [],
96
+ StreamInterface $body = null,
97
+ array $options = []
98
+ ) {
99
+ $this->statusCode = (int) $statusCode;
100
+ $this->handleOptions($options);
101
+
102
+ // Assume a reason phrase if one was not applied as an option
103
+ if (!$this->reasonPhrase &&
104
+ isset(self::$statusTexts[$this->statusCode])
105
+ ) {
106
+ $this->reasonPhrase = self::$statusTexts[$this->statusCode];
107
+ }
108
+
109
+ if ($headers) {
110
+ $this->setHeaders($headers);
111
+ }
112
+
113
+ if ($body) {
114
+ $this->setBody($body);
115
+ }
116
+ }
117
+
118
+ public function getStatusCode()
119
+ {
120
+ return $this->statusCode;
121
+ }
122
+
123
+ public function setStatusCode($code)
124
+ {
125
+ return $this->statusCode = (int) $code;
126
+ }
127
+
128
+ public function getReasonPhrase()
129
+ {
130
+ return $this->reasonPhrase;
131
+ }
132
+
133
+ public function setReasonPhrase($phrase)
134
+ {
135
+ return $this->reasonPhrase = $phrase;
136
+ }
137
+
138
+ public function json(array $config = [])
139
+ {
140
+ try {
141
+ return Utils::jsonDecode(
142
+ (string) $this->getBody(),
143
+ isset($config['object']) ? !$config['object'] : true,
144
+ 512,
145
+ isset($config['big_int_strings']) ? JSON_BIGINT_AS_STRING : 0
146
+ );
147
+ } catch (\InvalidArgumentException $e) {
148
+ throw new ParseException(
149
+ $e->getMessage(),
150
+ $this
151
+ );
152
+ }
153
+ }
154
+
155
+ public function xml(array $config = [])
156
+ {
157
+ $disableEntities = libxml_disable_entity_loader(true);
158
+ $internalErrors = libxml_use_internal_errors(true);
159
+
160
+ try {
161
+ // Allow XML to be retrieved even if there is no response body
162
+ $xml = new \SimpleXMLElement(
163
+ (string) $this->getBody() ?: '<root />',
164
+ isset($config['libxml_options']) ? $config['libxml_options'] : LIBXML_NONET,
165
+ false,
166
+ isset($config['ns']) ? $config['ns'] : '',
167
+ isset($config['ns_is_prefix']) ? $config['ns_is_prefix'] : false
168
+ );
169
+ libxml_disable_entity_loader($disableEntities);
170
+ libxml_use_internal_errors($internalErrors);
171
+ } catch (\Exception $e) {
172
+ libxml_disable_entity_loader($disableEntities);
173
+ libxml_use_internal_errors($internalErrors);
174
+ throw new XmlParseException(
175
+ 'Unable to parse response body into XML: ' . $e->getMessage(),
176
+ $this,
177
+ $e,
178
+ (libxml_get_last_error()) ?: null
179
+ );
180
+ }
181
+
182
+ return $xml;
183
+ }
184
+
185
+ public function getEffectiveUrl()
186
+ {
187
+ return $this->effectiveUrl;
188
+ }
189
+
190
+ public function setEffectiveUrl($url)
191
+ {
192
+ $this->effectiveUrl = $url;
193
+ }
194
+
195
+ /**
196
+ * Accepts and modifies the options provided to the response in the
197
+ * constructor.
198
+ *
199
+ * @param array $options Options array passed by reference.
200
+ */
201
+ protected function handleOptions(array &$options = [])
202
+ {
203
+ parent::handleOptions($options);
204
+ if (isset($options['reason_phrase'])) {
205
+ $this->reasonPhrase = $options['reason_phrase'];
206
+ }
207
+ }
208
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Message/ResponseInterface.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Message;
3
+
4
+ /**
5
+ * Represents an HTTP response message.
6
+ */
7
+ interface ResponseInterface extends MessageInterface
8
+ {
9
+ /**
10
+ * Gets the response Status-Code.
11
+ *
12
+ * The Status-Code is a 3-digit integer result code of the server's attempt
13
+ * to understand and satisfy the request.
14
+ *
15
+ * @return int Status code.
16
+ */
17
+ public function getStatusCode();
18
+
19
+ /**
20
+ * Sets the status code of this response.
21
+ *
22
+ * @param int $code The 3-digit integer result code to set.
23
+ */
24
+ public function setStatusCode($code);
25
+
26
+ /**
27
+ * Gets the response Reason-Phrase, a short textual description of the
28
+ * Status-Code.
29
+ *
30
+ * Because a Reason-Phrase is not a required element in response
31
+ * Status-Line, the Reason-Phrase value MAY be null. Implementations MAY
32
+ * choose to return the default RFC 2616 recommended reason phrase for the
33
+ * response's Status-Code.
34
+ *
35
+ * @return string|null Reason phrase, or null if unknown.
36
+ */
37
+ public function getReasonPhrase();
38
+
39
+ /**
40
+ * Sets the Reason-Phrase of the response.
41
+ *
42
+ * If no Reason-Phrase is specified, implementations MAY choose to default
43
+ * to the RFC 2616 recommended reason phrase for the response's Status-Code.
44
+ *
45
+ * @param string $phrase The Reason-Phrase to set.
46
+ */
47
+ public function setReasonPhrase($phrase);
48
+
49
+ /**
50
+ * Get the effective URL that resulted in this response (e.g. the last
51
+ * redirect URL).
52
+ *
53
+ * @return string
54
+ */
55
+ public function getEffectiveUrl();
56
+
57
+ /**
58
+ * Set the effective URL that resulted in this response (e.g. the last
59
+ * redirect URL).
60
+ *
61
+ * @param string $url Effective URL
62
+ */
63
+ public function setEffectiveUrl($url);
64
+
65
+ /**
66
+ * Parse the JSON response body and return the JSON decoded data.
67
+ *
68
+ * @param array $config Associative array of configuration settings used
69
+ * to control how the JSON data is parsed. Concrete implementations MAY
70
+ * add further configuration settings as needed, but they MUST implement
71
+ * functionality for the following options:
72
+ *
73
+ * - object: Set to true to parse JSON objects as PHP objects rather
74
+ * than associative arrays. Defaults to false.
75
+ * - big_int_strings: When set to true, large integers are converted to
76
+ * strings rather than floats. Defaults to false.
77
+ *
78
+ * Implementations are free to add further configuration settings as
79
+ * needed.
80
+ *
81
+ * @return mixed Returns the JSON decoded data based on the provided
82
+ * parse settings.
83
+ * @throws \RuntimeException if the response body is not in JSON format
84
+ */
85
+ public function json(array $config = []);
86
+
87
+ /**
88
+ * Parse the XML response body and return a \SimpleXMLElement.
89
+ *
90
+ * In order to prevent XXE attacks, this method disables loading external
91
+ * entities. If you rely on external entities, then you must parse the
92
+ * XML response manually by accessing the response body directly.
93
+ *
94
+ * @param array $config Associative array of configuration settings used
95
+ * to control how the XML is parsed. Concrete implementations MAY add
96
+ * further configuration settings as needed, but they MUST implement
97
+ * functionality for the following options:
98
+ *
99
+ * - ns: Set to a string to represent the namespace prefix or URI
100
+ * - ns_is_prefix: Set to true to specify that the NS is a prefix rather
101
+ * than a URI (defaults to false).
102
+ * - libxml_options: Bitwise OR of the libxml option constants
103
+ * listed at http://php.net/manual/en/libxml.constants.php
104
+ * (defaults to LIBXML_NONET)
105
+ *
106
+ * @return \SimpleXMLElement
107
+ * @throws \RuntimeException if the response body is not in XML format
108
+ * @link http://websec.io/2012/08/27/Preventing-XXE-in-PHP.html
109
+ */
110
+ public function xml(array $config = []);
111
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Mimetypes.php ADDED
@@ -0,0 +1,963 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ /**
5
+ * Provides mappings of file extensions to mimetypes
6
+ * @link http://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x/conf/mime.types
7
+ */
8
+ class Mimetypes
9
+ {
10
+ /** @var self */
11
+ protected static $instance;
12
+
13
+ /** @var array Mapping of extension to mimetype */
14
+ protected $mimetypes = array(
15
+ '3dml' => 'text/vnd.in3d.3dml',
16
+ '3g2' => 'video/3gpp2',
17
+ '3gp' => 'video/3gpp',
18
+ '7z' => 'application/x-7z-compressed',
19
+ 'aab' => 'application/x-authorware-bin',
20
+ 'aac' => 'audio/x-aac',
21
+ 'aam' => 'application/x-authorware-map',
22
+ 'aas' => 'application/x-authorware-seg',
23
+ 'abw' => 'application/x-abiword',
24
+ 'ac' => 'application/pkix-attr-cert',
25
+ 'acc' => 'application/vnd.americandynamics.acc',
26
+ 'ace' => 'application/x-ace-compressed',
27
+ 'acu' => 'application/vnd.acucobol',
28
+ 'acutc' => 'application/vnd.acucorp',
29
+ 'adp' => 'audio/adpcm',
30
+ 'aep' => 'application/vnd.audiograph',
31
+ 'afm' => 'application/x-font-type1',
32
+ 'afp' => 'application/vnd.ibm.modcap',
33
+ 'ahead' => 'application/vnd.ahead.space',
34
+ 'ai' => 'application/postscript',
35
+ 'aif' => 'audio/x-aiff',
36
+ 'aifc' => 'audio/x-aiff',
37
+ 'aiff' => 'audio/x-aiff',
38
+ 'air' => 'application/vnd.adobe.air-application-installer-package+zip',
39
+ 'ait' => 'application/vnd.dvb.ait',
40
+ 'ami' => 'application/vnd.amiga.ami',
41
+ 'apk' => 'application/vnd.android.package-archive',
42
+ 'application' => 'application/x-ms-application',
43
+ 'apr' => 'application/vnd.lotus-approach',
44
+ 'asa' => 'text/plain',
45
+ 'asax' => 'application/octet-stream',
46
+ 'asc' => 'application/pgp-signature',
47
+ 'ascx' => 'text/plain',
48
+ 'asf' => 'video/x-ms-asf',
49
+ 'ashx' => 'text/plain',
50
+ 'asm' => 'text/x-asm',
51
+ 'asmx' => 'text/plain',
52
+ 'aso' => 'application/vnd.accpac.simply.aso',
53
+ 'asp' => 'text/plain',
54
+ 'aspx' => 'text/plain',
55
+ 'asx' => 'video/x-ms-asf',
56
+ 'atc' => 'application/vnd.acucorp',
57
+ 'atom' => 'application/atom+xml',
58
+ 'atomcat' => 'application/atomcat+xml',
59
+ 'atomsvc' => 'application/atomsvc+xml',
60
+ 'atx' => 'application/vnd.antix.game-component',
61
+ 'au' => 'audio/basic',
62
+ 'avi' => 'video/x-msvideo',
63
+ 'aw' => 'application/applixware',
64
+ 'axd' => 'text/plain',
65
+ 'azf' => 'application/vnd.airzip.filesecure.azf',
66
+ 'azs' => 'application/vnd.airzip.filesecure.azs',
67
+ 'azw' => 'application/vnd.amazon.ebook',
68
+ 'bat' => 'application/x-msdownload',
69
+ 'bcpio' => 'application/x-bcpio',
70
+ 'bdf' => 'application/x-font-bdf',
71
+ 'bdm' => 'application/vnd.syncml.dm+wbxml',
72
+ 'bed' => 'application/vnd.realvnc.bed',
73
+ 'bh2' => 'application/vnd.fujitsu.oasysprs',
74
+ 'bin' => 'application/octet-stream',
75
+ 'bmi' => 'application/vnd.bmi',
76
+ 'bmp' => 'image/bmp',
77
+ 'book' => 'application/vnd.framemaker',
78
+ 'box' => 'application/vnd.previewsystems.box',
79
+ 'boz' => 'application/x-bzip2',
80
+ 'bpk' => 'application/octet-stream',
81
+ 'btif' => 'image/prs.btif',
82
+ 'bz' => 'application/x-bzip',
83
+ 'bz2' => 'application/x-bzip2',
84
+ 'c' => 'text/x-c',
85
+ 'c11amc' => 'application/vnd.cluetrust.cartomobile-config',
86
+ 'c11amz' => 'application/vnd.cluetrust.cartomobile-config-pkg',
87
+ 'c4d' => 'application/vnd.clonk.c4group',
88
+ 'c4f' => 'application/vnd.clonk.c4group',
89
+ 'c4g' => 'application/vnd.clonk.c4group',
90
+ 'c4p' => 'application/vnd.clonk.c4group',
91
+ 'c4u' => 'application/vnd.clonk.c4group',
92
+ 'cab' => 'application/vnd.ms-cab-compressed',
93
+ 'car' => 'application/vnd.curl.car',
94
+ 'cat' => 'application/vnd.ms-pki.seccat',
95
+ 'cc' => 'text/x-c',
96
+ 'cct' => 'application/x-director',
97
+ 'ccxml' => 'application/ccxml+xml',
98
+ 'cdbcmsg' => 'application/vnd.contact.cmsg',
99
+ 'cdf' => 'application/x-netcdf',
100
+ 'cdkey' => 'application/vnd.mediastation.cdkey',
101
+ 'cdmia' => 'application/cdmi-capability',
102
+ 'cdmic' => 'application/cdmi-container',
103
+ 'cdmid' => 'application/cdmi-domain',
104
+ 'cdmio' => 'application/cdmi-object',
105
+ 'cdmiq' => 'application/cdmi-queue',
106
+ 'cdx' => 'chemical/x-cdx',
107
+ 'cdxml' => 'application/vnd.chemdraw+xml',
108
+ 'cdy' => 'application/vnd.cinderella',
109
+ 'cer' => 'application/pkix-cert',
110
+ 'cfc' => 'application/x-coldfusion',
111
+ 'cfm' => 'application/x-coldfusion',
112
+ 'cgm' => 'image/cgm',
113
+ 'chat' => 'application/x-chat',
114
+ 'chm' => 'application/vnd.ms-htmlhelp',
115
+ 'chrt' => 'application/vnd.kde.kchart',
116
+ 'cif' => 'chemical/x-cif',
117
+ 'cii' => 'application/vnd.anser-web-certificate-issue-initiation',
118
+ 'cil' => 'application/vnd.ms-artgalry',
119
+ 'cla' => 'application/vnd.claymore',
120
+ 'class' => 'application/java-vm',
121
+ 'clkk' => 'application/vnd.crick.clicker.keyboard',
122
+ 'clkp' => 'application/vnd.crick.clicker.palette',
123
+ 'clkt' => 'application/vnd.crick.clicker.template',
124
+ 'clkw' => 'application/vnd.crick.clicker.wordbank',
125
+ 'clkx' => 'application/vnd.crick.clicker',
126
+ 'clp' => 'application/x-msclip',
127
+ 'cmc' => 'application/vnd.cosmocaller',
128
+ 'cmdf' => 'chemical/x-cmdf',
129
+ 'cml' => 'chemical/x-cml',
130
+ 'cmp' => 'application/vnd.yellowriver-custom-menu',
131
+ 'cmx' => 'image/x-cmx',
132
+ 'cod' => 'application/vnd.rim.cod',
133
+ 'com' => 'application/x-msdownload',
134
+ 'conf' => 'text/plain',
135
+ 'cpio' => 'application/x-cpio',
136
+ 'cpp' => 'text/x-c',
137
+ 'cpt' => 'application/mac-compactpro',
138
+ 'crd' => 'application/x-mscardfile',
139
+ 'crl' => 'application/pkix-crl',
140
+ 'crt' => 'application/x-x509-ca-cert',
141
+ 'cryptonote' => 'application/vnd.rig.cryptonote',
142
+ 'cs' => 'text/plain',
143
+ 'csh' => 'application/x-csh',
144
+ 'csml' => 'chemical/x-csml',
145
+ 'csp' => 'application/vnd.commonspace',
146
+ 'css' => 'text/css',
147
+ 'cst' => 'application/x-director',
148
+ 'csv' => 'text/csv',
149
+ 'cu' => 'application/cu-seeme',
150
+ 'curl' => 'text/vnd.curl',
151
+ 'cww' => 'application/prs.cww',
152
+ 'cxt' => 'application/x-director',
153
+ 'cxx' => 'text/x-c',
154
+ 'dae' => 'model/vnd.collada+xml',
155
+ 'daf' => 'application/vnd.mobius.daf',
156
+ 'dataless' => 'application/vnd.fdsn.seed',
157
+ 'davmount' => 'application/davmount+xml',
158
+ 'dcr' => 'application/x-director',
159
+ 'dcurl' => 'text/vnd.curl.dcurl',
160
+ 'dd2' => 'application/vnd.oma.dd2+xml',
161
+ 'ddd' => 'application/vnd.fujixerox.ddd',
162
+ 'deb' => 'application/x-debian-package',
163
+ 'def' => 'text/plain',
164
+ 'deploy' => 'application/octet-stream',
165
+ 'der' => 'application/x-x509-ca-cert',
166
+ 'dfac' => 'application/vnd.dreamfactory',
167
+ 'dic' => 'text/x-c',
168
+ 'dir' => 'application/x-director',
169
+ 'dis' => 'application/vnd.mobius.dis',
170
+ 'dist' => 'application/octet-stream',
171
+ 'distz' => 'application/octet-stream',
172
+ 'djv' => 'image/vnd.djvu',
173
+ 'djvu' => 'image/vnd.djvu',
174
+ 'dll' => 'application/x-msdownload',
175
+ 'dmg' => 'application/octet-stream',
176
+ 'dms' => 'application/octet-stream',
177
+ 'dna' => 'application/vnd.dna',
178
+ 'doc' => 'application/msword',
179
+ 'docm' => 'application/vnd.ms-word.document.macroenabled.12',
180
+ 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
181
+ 'dot' => 'application/msword',
182
+ 'dotm' => 'application/vnd.ms-word.template.macroenabled.12',
183
+ 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
184
+ 'dp' => 'application/vnd.osgi.dp',
185
+ 'dpg' => 'application/vnd.dpgraph',
186
+ 'dra' => 'audio/vnd.dra',
187
+ 'dsc' => 'text/prs.lines.tag',
188
+ 'dssc' => 'application/dssc+der',
189
+ 'dtb' => 'application/x-dtbook+xml',
190
+ 'dtd' => 'application/xml-dtd',
191
+ 'dts' => 'audio/vnd.dts',
192
+ 'dtshd' => 'audio/vnd.dts.hd',
193
+ 'dump' => 'application/octet-stream',
194
+ 'dvi' => 'application/x-dvi',
195
+ 'dwf' => 'model/vnd.dwf',
196
+ 'dwg' => 'image/vnd.dwg',
197
+ 'dxf' => 'image/vnd.dxf',
198
+ 'dxp' => 'application/vnd.spotfire.dxp',
199
+ 'dxr' => 'application/x-director',
200
+ 'ecelp4800' => 'audio/vnd.nuera.ecelp4800',
201
+ 'ecelp7470' => 'audio/vnd.nuera.ecelp7470',
202
+ 'ecelp9600' => 'audio/vnd.nuera.ecelp9600',
203
+ 'ecma' => 'application/ecmascript',
204
+ 'edm' => 'application/vnd.novadigm.edm',
205
+ 'edx' => 'application/vnd.novadigm.edx',
206
+ 'efif' => 'application/vnd.picsel',
207
+ 'ei6' => 'application/vnd.pg.osasli',
208
+ 'elc' => 'application/octet-stream',
209
+ 'eml' => 'message/rfc822',
210
+ 'emma' => 'application/emma+xml',
211
+ 'eol' => 'audio/vnd.digital-winds',
212
+ 'eot' => 'application/vnd.ms-fontobject',
213
+ 'eps' => 'application/postscript',
214
+ 'epub' => 'application/epub+zip',
215
+ 'es3' => 'application/vnd.eszigno3+xml',
216
+ 'esf' => 'application/vnd.epson.esf',
217
+ 'et3' => 'application/vnd.eszigno3+xml',
218
+ 'etx' => 'text/x-setext',
219
+ 'exe' => 'application/x-msdownload',
220
+ 'exi' => 'application/exi',
221
+ 'ext' => 'application/vnd.novadigm.ext',
222
+ 'ez' => 'application/andrew-inset',
223
+ 'ez2' => 'application/vnd.ezpix-album',
224
+ 'ez3' => 'application/vnd.ezpix-package',
225
+ 'f' => 'text/x-fortran',
226
+ 'f4v' => 'video/x-f4v',
227
+ 'f77' => 'text/x-fortran',
228
+ 'f90' => 'text/x-fortran',
229
+ 'fbs' => 'image/vnd.fastbidsheet',
230
+ 'fcs' => 'application/vnd.isac.fcs',
231
+ 'fdf' => 'application/vnd.fdf',
232
+ 'fe_launch' => 'application/vnd.denovo.fcselayout-link',
233
+ 'fg5' => 'application/vnd.fujitsu.oasysgp',
234
+ 'fgd' => 'application/x-director',
235
+ 'fh' => 'image/x-freehand',
236
+ 'fh4' => 'image/x-freehand',
237
+ 'fh5' => 'image/x-freehand',
238
+ 'fh7' => 'image/x-freehand',
239
+ 'fhc' => 'image/x-freehand',
240
+ 'fig' => 'application/x-xfig',
241
+ 'fli' => 'video/x-fli',
242
+ 'flo' => 'application/vnd.micrografx.flo',
243
+ 'flv' => 'video/x-flv',
244
+ 'flw' => 'application/vnd.kde.kivio',
245
+ 'flx' => 'text/vnd.fmi.flexstor',
246
+ 'fly' => 'text/vnd.fly',
247
+ 'fm' => 'application/vnd.framemaker',
248
+ 'fnc' => 'application/vnd.frogans.fnc',
249
+ 'for' => 'text/x-fortran',
250
+ 'fpx' => 'image/vnd.fpx',
251
+ 'frame' => 'application/vnd.framemaker',
252
+ 'fsc' => 'application/vnd.fsc.weblaunch',
253
+ 'fst' => 'image/vnd.fst',
254
+ 'ftc' => 'application/vnd.fluxtime.clip',
255
+ 'fti' => 'application/vnd.anser-web-funds-transfer-initiation',
256
+ 'fvt' => 'video/vnd.fvt',
257
+ 'fxp' => 'application/vnd.adobe.fxp',
258
+ 'fxpl' => 'application/vnd.adobe.fxp',
259
+ 'fzs' => 'application/vnd.fuzzysheet',
260
+ 'g2w' => 'application/vnd.geoplan',
261
+ 'g3' => 'image/g3fax',
262
+ 'g3w' => 'application/vnd.geospace',
263
+ 'gac' => 'application/vnd.groove-account',
264
+ 'gdl' => 'model/vnd.gdl',
265
+ 'geo' => 'application/vnd.dynageo',
266
+ 'gex' => 'application/vnd.geometry-explorer',
267
+ 'ggb' => 'application/vnd.geogebra.file',
268
+ 'ggt' => 'application/vnd.geogebra.tool',
269
+ 'ghf' => 'application/vnd.groove-help',
270
+ 'gif' => 'image/gif',
271
+ 'gim' => 'application/vnd.groove-identity-message',
272
+ 'gmx' => 'application/vnd.gmx',
273
+ 'gnumeric' => 'application/x-gnumeric',
274
+ 'gph' => 'application/vnd.flographit',
275
+ 'gqf' => 'application/vnd.grafeq',
276
+ 'gqs' => 'application/vnd.grafeq',
277
+ 'gram' => 'application/srgs',
278
+ 'gre' => 'application/vnd.geometry-explorer',
279
+ 'grv' => 'application/vnd.groove-injector',
280
+ 'grxml' => 'application/srgs+xml',
281
+ 'gsf' => 'application/x-font-ghostscript',
282
+ 'gtar' => 'application/x-gtar',
283
+ 'gtm' => 'application/vnd.groove-tool-message',
284
+ 'gtw' => 'model/vnd.gtw',
285
+ 'gv' => 'text/vnd.graphviz',
286
+ 'gxt' => 'application/vnd.geonext',
287
+ 'h' => 'text/x-c',
288
+ 'h261' => 'video/h261',
289
+ 'h263' => 'video/h263',
290
+ 'h264' => 'video/h264',
291
+ 'hal' => 'application/vnd.hal+xml',
292
+ 'hbci' => 'application/vnd.hbci',
293
+ 'hdf' => 'application/x-hdf',
294
+ 'hh' => 'text/x-c',
295
+ 'hlp' => 'application/winhlp',
296
+ 'hpgl' => 'application/vnd.hp-hpgl',
297
+ 'hpid' => 'application/vnd.hp-hpid',
298
+ 'hps' => 'application/vnd.hp-hps',
299
+ 'hqx' => 'application/mac-binhex40',
300
+ 'hta' => 'application/octet-stream',
301
+ 'htc' => 'text/html',
302
+ 'htke' => 'application/vnd.kenameaapp',
303
+ 'htm' => 'text/html',
304
+ 'html' => 'text/html',
305
+ 'hvd' => 'application/vnd.yamaha.hv-dic',
306
+ 'hvp' => 'application/vnd.yamaha.hv-voice',
307
+ 'hvs' => 'application/vnd.yamaha.hv-script',
308
+ 'i2g' => 'application/vnd.intergeo',
309
+ 'icc' => 'application/vnd.iccprofile',
310
+ 'ice' => 'x-conference/x-cooltalk',
311
+ 'icm' => 'application/vnd.iccprofile',
312
+ 'ico' => 'image/x-icon',
313
+ 'ics' => 'text/calendar',
314
+ 'ief' => 'image/ief',
315
+ 'ifb' => 'text/calendar',
316
+ 'ifm' => 'application/vnd.shana.informed.formdata',
317
+ 'iges' => 'model/iges',
318
+ 'igl' => 'application/vnd.igloader',
319
+ 'igm' => 'application/vnd.insors.igm',
320
+ 'igs' => 'model/iges',
321
+ 'igx' => 'application/vnd.micrografx.igx',
322
+ 'iif' => 'application/vnd.shana.informed.interchange',
323
+ 'imp' => 'application/vnd.accpac.simply.imp',
324
+ 'ims' => 'application/vnd.ms-ims',
325
+ 'in' => 'text/plain',
326
+ 'ini' => 'text/plain',
327
+ 'ipfix' => 'application/ipfix',
328
+ 'ipk' => 'application/vnd.shana.informed.package',
329
+ 'irm' => 'application/vnd.ibm.rights-management',
330
+ 'irp' => 'application/vnd.irepository.package+xml',
331
+ 'iso' => 'application/octet-stream',
332
+ 'itp' => 'application/vnd.shana.informed.formtemplate',
333
+ 'ivp' => 'application/vnd.immervision-ivp',
334
+ 'ivu' => 'application/vnd.immervision-ivu',
335
+ 'jad' => 'text/vnd.sun.j2me.app-descriptor',
336
+ 'jam' => 'application/vnd.jam',
337
+ 'jar' => 'application/java-archive',
338
+ 'java' => 'text/x-java-source',
339
+ 'jisp' => 'application/vnd.jisp',
340
+ 'jlt' => 'application/vnd.hp-jlyt',
341
+ 'jnlp' => 'application/x-java-jnlp-file',
342
+ 'joda' => 'application/vnd.joost.joda-archive',
343
+ 'jpe' => 'image/jpeg',
344
+ 'jpeg' => 'image/jpeg',
345
+ 'jpg' => 'image/jpeg',
346
+ 'jpgm' => 'video/jpm',
347
+ 'jpgv' => 'video/jpeg',
348
+ 'jpm' => 'video/jpm',
349
+ 'js' => 'text/javascript',
350
+ 'json' => 'application/json',
351
+ 'kar' => 'audio/midi',
352
+ 'karbon' => 'application/vnd.kde.karbon',
353
+ 'kfo' => 'application/vnd.kde.kformula',
354
+ 'kia' => 'application/vnd.kidspiration',
355
+ 'kml' => 'application/vnd.google-earth.kml+xml',
356
+ 'kmz' => 'application/vnd.google-earth.kmz',
357
+ 'kne' => 'application/vnd.kinar',
358
+ 'knp' => 'application/vnd.kinar',
359
+ 'kon' => 'application/vnd.kde.kontour',
360
+ 'kpr' => 'application/vnd.kde.kpresenter',
361
+ 'kpt' => 'application/vnd.kde.kpresenter',
362
+ 'ksp' => 'application/vnd.kde.kspread',
363
+ 'ktr' => 'application/vnd.kahootz',
364
+ 'ktx' => 'image/ktx',
365
+ 'ktz' => 'application/vnd.kahootz',
366
+ 'kwd' => 'application/vnd.kde.kword',
367
+ 'kwt' => 'application/vnd.kde.kword',
368
+ 'lasxml' => 'application/vnd.las.las+xml',
369
+ 'latex' => 'application/x-latex',
370
+ 'lbd' => 'application/vnd.llamagraphics.life-balance.desktop',
371
+ 'lbe' => 'application/vnd.llamagraphics.life-balance.exchange+xml',
372
+ 'les' => 'application/vnd.hhe.lesson-player',
373
+ 'lha' => 'application/octet-stream',
374
+ 'link66' => 'application/vnd.route66.link66+xml',
375
+ 'list' => 'text/plain',
376
+ 'list3820' => 'application/vnd.ibm.modcap',
377
+ 'listafp' => 'application/vnd.ibm.modcap',
378
+ 'log' => 'text/plain',
379
+ 'lostxml' => 'application/lost+xml',
380
+ 'lrf' => 'application/octet-stream',
381
+ 'lrm' => 'application/vnd.ms-lrm',
382
+ 'ltf' => 'application/vnd.frogans.ltf',
383
+ 'lvp' => 'audio/vnd.lucent.voice',
384
+ 'lwp' => 'application/vnd.lotus-wordpro',
385
+ 'lzh' => 'application/octet-stream',
386
+ 'm13' => 'application/x-msmediaview',
387
+ 'm14' => 'application/x-msmediaview',
388
+ 'm1v' => 'video/mpeg',
389
+ 'm21' => 'application/mp21',
390
+ 'm2a' => 'audio/mpeg',
391
+ 'm2v' => 'video/mpeg',
392
+ 'm3a' => 'audio/mpeg',
393
+ 'm3u' => 'audio/x-mpegurl',
394
+ 'm3u8' => 'application/vnd.apple.mpegurl',
395
+ 'm4a' => 'audio/mp4',
396
+ 'm4u' => 'video/vnd.mpegurl',
397
+ 'm4v' => 'video/mp4',
398
+ 'ma' => 'application/mathematica',
399
+ 'mads' => 'application/mads+xml',
400
+ 'mag' => 'application/vnd.ecowin.chart',
401
+ 'maker' => 'application/vnd.framemaker',
402
+ 'man' => 'text/troff',
403
+ 'mathml' => 'application/mathml+xml',
404
+ 'mb' => 'application/mathematica',
405
+ 'mbk' => 'application/vnd.mobius.mbk',
406
+ 'mbox' => 'application/mbox',
407
+ 'mc1' => 'application/vnd.medcalcdata',
408
+ 'mcd' => 'application/vnd.mcd',
409
+ 'mcurl' => 'text/vnd.curl.mcurl',
410
+ 'mdb' => 'application/x-msaccess',
411
+ 'mdi' => 'image/vnd.ms-modi',
412
+ 'me' => 'text/troff',
413
+ 'mesh' => 'model/mesh',
414
+ 'meta4' => 'application/metalink4+xml',
415
+ 'mets' => 'application/mets+xml',
416
+ 'mfm' => 'application/vnd.mfmp',
417
+ 'mgp' => 'application/vnd.osgeo.mapguide.package',
418
+ 'mgz' => 'application/vnd.proteus.magazine',
419
+ 'mid' => 'audio/midi',
420
+ 'midi' => 'audio/midi',
421
+ 'mif' => 'application/vnd.mif',
422
+ 'mime' => 'message/rfc822',
423
+ 'mj2' => 'video/mj2',
424
+ 'mjp2' => 'video/mj2',
425
+ 'mlp' => 'application/vnd.dolby.mlp',
426
+ 'mmd' => 'application/vnd.chipnuts.karaoke-mmd',
427
+ 'mmf' => 'application/vnd.smaf',
428
+ 'mmr' => 'image/vnd.fujixerox.edmics-mmr',
429
+ 'mny' => 'application/x-msmoney',
430
+ 'mobi' => 'application/x-mobipocket-ebook',
431
+ 'mods' => 'application/mods+xml',
432
+ 'mov' => 'video/quicktime',
433
+ 'movie' => 'video/x-sgi-movie',
434
+ 'mp2' => 'audio/mpeg',
435
+ 'mp21' => 'application/mp21',
436
+ 'mp2a' => 'audio/mpeg',
437
+ 'mp3' => 'audio/mpeg',
438
+ 'mp4' => 'video/mp4',
439
+ 'mp4a' => 'audio/mp4',
440
+ 'mp4s' => 'application/mp4',
441
+ 'mp4v' => 'video/mp4',
442
+ 'mpc' => 'application/vnd.mophun.certificate',
443
+ 'mpe' => 'video/mpeg',
444
+ 'mpeg' => 'video/mpeg',
445
+ 'mpg' => 'video/mpeg',
446
+ 'mpg4' => 'video/mp4',
447
+ 'mpga' => 'audio/mpeg',
448
+ 'mpkg' => 'application/vnd.apple.installer+xml',
449
+ 'mpm' => 'application/vnd.blueice.multipass',
450
+ 'mpn' => 'application/vnd.mophun.application',
451
+ 'mpp' => 'application/vnd.ms-project',
452
+ 'mpt' => 'application/vnd.ms-project',
453
+ 'mpy' => 'application/vnd.ibm.minipay',
454
+ 'mqy' => 'application/vnd.mobius.mqy',
455
+ 'mrc' => 'application/marc',
456
+ 'mrcx' => 'application/marcxml+xml',
457
+ 'ms' => 'text/troff',
458
+ 'mscml' => 'application/mediaservercontrol+xml',
459
+ 'mseed' => 'application/vnd.fdsn.mseed',
460
+ 'mseq' => 'application/vnd.mseq',
461
+ 'msf' => 'application/vnd.epson.msf',
462
+ 'msh' => 'model/mesh',
463
+ 'msi' => 'application/x-msdownload',
464
+ 'msl' => 'application/vnd.mobius.msl',
465
+ 'msty' => 'application/vnd.muvee.style',
466
+ 'mts' => 'model/vnd.mts',
467
+ 'mus' => 'application/vnd.musician',
468
+ 'musicxml' => 'application/vnd.recordare.musicxml+xml',
469
+ 'mvb' => 'application/x-msmediaview',
470
+ 'mwf' => 'application/vnd.mfer',
471
+ 'mxf' => 'application/mxf',
472
+ 'mxl' => 'application/vnd.recordare.musicxml',
473
+ 'mxml' => 'application/xv+xml',
474
+ 'mxs' => 'application/vnd.triscape.mxs',
475
+ 'mxu' => 'video/vnd.mpegurl',
476
+ 'n-gage' => 'application/vnd.nokia.n-gage.symbian.install',
477
+ 'n3' => 'text/n3',
478
+ 'nb' => 'application/mathematica',
479
+ 'nbp' => 'application/vnd.wolfram.player',
480
+ 'nc' => 'application/x-netcdf',
481
+ 'ncx' => 'application/x-dtbncx+xml',
482
+ 'ngdat' => 'application/vnd.nokia.n-gage.data',
483
+ 'nlu' => 'application/vnd.neurolanguage.nlu',
484
+ 'nml' => 'application/vnd.enliven',
485
+ 'nnd' => 'application/vnd.noblenet-directory',
486
+ 'nns' => 'application/vnd.noblenet-sealer',
487
+ 'nnw' => 'application/vnd.noblenet-web',
488
+ 'npx' => 'image/vnd.net-fpx',
489
+ 'nsf' => 'application/vnd.lotus-notes',
490
+ 'oa2' => 'application/vnd.fujitsu.oasys2',
491
+ 'oa3' => 'application/vnd.fujitsu.oasys3',
492
+ 'oas' => 'application/vnd.fujitsu.oasys',
493
+ 'obd' => 'application/x-msbinder',
494
+ 'oda' => 'application/oda',
495
+ 'odb' => 'application/vnd.oasis.opendocument.database',
496
+ 'odc' => 'application/vnd.oasis.opendocument.chart',
497
+ 'odf' => 'application/vnd.oasis.opendocument.formula',
498
+ 'odft' => 'application/vnd.oasis.opendocument.formula-template',
499
+ 'odg' => 'application/vnd.oasis.opendocument.graphics',
500
+ 'odi' => 'application/vnd.oasis.opendocument.image',
501
+ 'odm' => 'application/vnd.oasis.opendocument.text-master',
502
+ 'odp' => 'application/vnd.oasis.opendocument.presentation',
503
+ 'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
504
+ 'odt' => 'application/vnd.oasis.opendocument.text',
505
+ 'oga' => 'audio/ogg',
506
+ 'ogg' => 'audio/ogg',
507
+ 'ogv' => 'video/ogg',
508
+ 'ogx' => 'application/ogg',
509
+ 'onepkg' => 'application/onenote',
510
+ 'onetmp' => 'application/onenote',
511
+ 'onetoc' => 'application/onenote',
512
+ 'onetoc2' => 'application/onenote',
513
+ 'opf' => 'application/oebps-package+xml',
514
+ 'oprc' => 'application/vnd.palm',
515
+ 'org' => 'application/vnd.lotus-organizer',
516
+ 'osf' => 'application/vnd.yamaha.openscoreformat',
517
+ 'osfpvg' => 'application/vnd.yamaha.openscoreformat.osfpvg+xml',
518
+ 'otc' => 'application/vnd.oasis.opendocument.chart-template',
519
+ 'otf' => 'application/x-font-otf',
520
+ 'otg' => 'application/vnd.oasis.opendocument.graphics-template',
521
+ 'oth' => 'application/vnd.oasis.opendocument.text-web',
522
+ 'oti' => 'application/vnd.oasis.opendocument.image-template',
523
+ 'otp' => 'application/vnd.oasis.opendocument.presentation-template',
524
+ 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template',
525
+ 'ott' => 'application/vnd.oasis.opendocument.text-template',
526
+ 'oxt' => 'application/vnd.openofficeorg.extension',
527
+ 'p' => 'text/x-pascal',
528
+ 'p10' => 'application/pkcs10',
529
+ 'p12' => 'application/x-pkcs12',
530
+ 'p7b' => 'application/x-pkcs7-certificates',
531
+ 'p7c' => 'application/pkcs7-mime',
532
+ 'p7m' => 'application/pkcs7-mime',
533
+ 'p7r' => 'application/x-pkcs7-certreqresp',
534
+ 'p7s' => 'application/pkcs7-signature',
535
+ 'p8' => 'application/pkcs8',
536
+ 'pas' => 'text/x-pascal',
537
+ 'paw' => 'application/vnd.pawaafile',
538
+ 'pbd' => 'application/vnd.powerbuilder6',
539
+ 'pbm' => 'image/x-portable-bitmap',
540
+ 'pcf' => 'application/x-font-pcf',
541
+ 'pcl' => 'application/vnd.hp-pcl',
542
+ 'pclxl' => 'application/vnd.hp-pclxl',
543
+ 'pct' => 'image/x-pict',
544
+ 'pcurl' => 'application/vnd.curl.pcurl',
545
+ 'pcx' => 'image/x-pcx',
546
+ 'pdb' => 'application/vnd.palm',
547
+ 'pdf' => 'application/pdf',
548
+ 'pfa' => 'application/x-font-type1',
549
+ 'pfb' => 'application/x-font-type1',
550
+ 'pfm' => 'application/x-font-type1',
551
+ 'pfr' => 'application/font-tdpfr',
552
+ 'pfx' => 'application/x-pkcs12',
553
+ 'pgm' => 'image/x-portable-graymap',
554
+ 'pgn' => 'application/x-chess-pgn',
555
+ 'pgp' => 'application/pgp-encrypted',
556
+ 'php' => 'text/x-php',
557
+ 'phps' => 'application/x-httpd-phps',
558
+ 'pic' => 'image/x-pict',
559
+ 'pkg' => 'application/octet-stream',
560
+ 'pki' => 'application/pkixcmp',
561
+ 'pkipath' => 'application/pkix-pkipath',
562
+ 'plb' => 'application/vnd.3gpp.pic-bw-large',
563
+ 'plc' => 'application/vnd.mobius.plc',
564
+ 'plf' => 'application/vnd.pocketlearn',
565
+ 'pls' => 'application/pls+xml',
566
+ 'pml' => 'application/vnd.ctc-posml',
567
+ 'png' => 'image/png',
568
+ 'pnm' => 'image/x-portable-anymap',
569
+ 'portpkg' => 'application/vnd.macports.portpkg',
570
+ 'pot' => 'application/vnd.ms-powerpoint',
571
+ 'potm' => 'application/vnd.ms-powerpoint.template.macroenabled.12',
572
+ 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template',
573
+ 'ppam' => 'application/vnd.ms-powerpoint.addin.macroenabled.12',
574
+ 'ppd' => 'application/vnd.cups-ppd',
575
+ 'ppm' => 'image/x-portable-pixmap',
576
+ 'pps' => 'application/vnd.ms-powerpoint',
577
+ 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroenabled.12',
578
+ 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
579
+ 'ppt' => 'application/vnd.ms-powerpoint',
580
+ 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroenabled.12',
581
+ 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
582
+ 'pqa' => 'application/vnd.palm',
583
+ 'prc' => 'application/x-mobipocket-ebook',
584
+ 'pre' => 'application/vnd.lotus-freelance',
585
+ 'prf' => 'application/pics-rules',
586
+ 'ps' => 'application/postscript',
587
+ 'psb' => 'application/vnd.3gpp.pic-bw-small',
588
+ 'psd' => 'image/vnd.adobe.photoshop',
589
+ 'psf' => 'application/x-font-linux-psf',
590
+ 'pskcxml' => 'application/pskc+xml',
591
+ 'ptid' => 'application/vnd.pvi.ptid1',
592
+ 'pub' => 'application/x-mspublisher',
593
+ 'pvb' => 'application/vnd.3gpp.pic-bw-var',
594
+ 'pwn' => 'application/vnd.3m.post-it-notes',
595
+ 'pya' => 'audio/vnd.ms-playready.media.pya',
596
+ 'pyv' => 'video/vnd.ms-playready.media.pyv',
597
+ 'qam' => 'application/vnd.epson.quickanime',
598
+ 'qbo' => 'application/vnd.intu.qbo',
599
+ 'qfx' => 'application/vnd.intu.qfx',
600
+ 'qps' => 'application/vnd.publishare-delta-tree',
601
+ 'qt' => 'video/quicktime',
602
+ 'qwd' => 'application/vnd.quark.quarkxpress',
603
+ 'qwt' => 'application/vnd.quark.quarkxpress',
604
+ 'qxb' => 'application/vnd.quark.quarkxpress',
605
+ 'qxd' => 'application/vnd.quark.quarkxpress',
606
+ 'qxl' => 'application/vnd.quark.quarkxpress',
607
+ 'qxt' => 'application/vnd.quark.quarkxpress',
608
+ 'ra' => 'audio/x-pn-realaudio',
609
+ 'ram' => 'audio/x-pn-realaudio',
610
+ 'rar' => 'application/x-rar-compressed',
611
+ 'ras' => 'image/x-cmu-raster',
612
+ 'rb' => 'text/plain',
613
+ 'rcprofile' => 'application/vnd.ipunplugged.rcprofile',
614
+ 'rdf' => 'application/rdf+xml',
615
+ 'rdz' => 'application/vnd.data-vision.rdz',
616
+ 'rep' => 'application/vnd.businessobjects',
617
+ 'res' => 'application/x-dtbresource+xml',
618
+ 'resx' => 'text/xml',
619
+ 'rgb' => 'image/x-rgb',
620
+ 'rif' => 'application/reginfo+xml',
621
+ 'rip' => 'audio/vnd.rip',
622
+ 'rl' => 'application/resource-lists+xml',
623
+ 'rlc' => 'image/vnd.fujixerox.edmics-rlc',
624
+ 'rld' => 'application/resource-lists-diff+xml',
625
+ 'rm' => 'application/vnd.rn-realmedia',
626
+ 'rmi' => 'audio/midi',
627
+ 'rmp' => 'audio/x-pn-realaudio-plugin',
628
+ 'rms' => 'application/vnd.jcp.javame.midlet-rms',
629
+ 'rnc' => 'application/relax-ng-compact-syntax',
630
+ 'roff' => 'text/troff',
631
+ 'rp9' => 'application/vnd.cloanto.rp9',
632
+ 'rpss' => 'application/vnd.nokia.radio-presets',
633
+ 'rpst' => 'application/vnd.nokia.radio-preset',
634
+ 'rq' => 'application/sparql-query',
635
+ 'rs' => 'application/rls-services+xml',
636
+ 'rsd' => 'application/rsd+xml',
637
+ 'rss' => 'application/rss+xml',
638
+ 'rtf' => 'application/rtf',
639
+ 'rtx' => 'text/richtext',
640
+ 's' => 'text/x-asm',
641
+ 'saf' => 'application/vnd.yamaha.smaf-audio',
642
+ 'sbml' => 'application/sbml+xml',
643
+ 'sc' => 'application/vnd.ibm.secure-container',
644
+ 'scd' => 'application/x-msschedule',
645
+ 'scm' => 'application/vnd.lotus-screencam',
646
+ 'scq' => 'application/scvp-cv-request',
647
+ 'scs' => 'application/scvp-cv-response',
648
+ 'scurl' => 'text/vnd.curl.scurl',
649
+ 'sda' => 'application/vnd.stardivision.draw',
650
+ 'sdc' => 'application/vnd.stardivision.calc',
651
+ 'sdd' => 'application/vnd.stardivision.impress',
652
+ 'sdkd' => 'application/vnd.solent.sdkm+xml',
653
+ 'sdkm' => 'application/vnd.solent.sdkm+xml',
654
+ 'sdp' => 'application/sdp',
655
+ 'sdw' => 'application/vnd.stardivision.writer',
656
+ 'see' => 'application/vnd.seemail',
657
+ 'seed' => 'application/vnd.fdsn.seed',
658
+ 'sema' => 'application/vnd.sema',
659
+ 'semd' => 'application/vnd.semd',
660
+ 'semf' => 'application/vnd.semf',
661
+ 'ser' => 'application/java-serialized-object',
662
+ 'setpay' => 'application/set-payment-initiation',
663
+ 'setreg' => 'application/set-registration-initiation',
664
+ 'sfd-hdstx' => 'application/vnd.hydrostatix.sof-data',
665
+ 'sfs' => 'application/vnd.spotfire.sfs',
666
+ 'sgl' => 'application/vnd.stardivision.writer-global',
667
+ 'sgm' => 'text/sgml',
668
+ 'sgml' => 'text/sgml',
669
+ 'sh' => 'application/x-sh',
670
+ 'shar' => 'application/x-shar',
671
+ 'shf' => 'application/shf+xml',
672
+ 'sig' => 'application/pgp-signature',
673
+ 'silo' => 'model/mesh',
674
+ 'sis' => 'application/vnd.symbian.install',
675
+ 'sisx' => 'application/vnd.symbian.install',
676
+ 'sit' => 'application/x-stuffit',
677
+ 'sitx' => 'application/x-stuffitx',
678
+ 'skd' => 'application/vnd.koan',
679
+ 'skm' => 'application/vnd.koan',
680
+ 'skp' => 'application/vnd.koan',
681
+ 'skt' => 'application/vnd.koan',
682
+ 'sldm' => 'application/vnd.ms-powerpoint.slide.macroenabled.12',
683
+ 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide',
684
+ 'slt' => 'application/vnd.epson.salt',
685
+ 'sm' => 'application/vnd.stepmania.stepchart',
686
+ 'smf' => 'application/vnd.stardivision.math',
687
+ 'smi' => 'application/smil+xml',
688
+ 'smil' => 'application/smil+xml',
689
+ 'snd' => 'audio/basic',
690
+ 'snf' => 'application/x-font-snf',
691
+ 'so' => 'application/octet-stream',
692
+ 'spc' => 'application/x-pkcs7-certificates',
693
+ 'spf' => 'application/vnd.yamaha.smaf-phrase',
694
+ 'spl' => 'application/x-futuresplash',
695
+ 'spot' => 'text/vnd.in3d.spot',
696
+ 'spp' => 'application/scvp-vp-response',
697
+ 'spq' => 'application/scvp-vp-request',
698
+ 'spx' => 'audio/ogg',
699
+ 'src' => 'application/x-wais-source',
700
+ 'sru' => 'application/sru+xml',
701
+ 'srx' => 'application/sparql-results+xml',
702
+ 'sse' => 'application/vnd.kodak-descriptor',
703
+ 'ssf' => 'application/vnd.epson.ssf',
704
+ 'ssml' => 'application/ssml+xml',
705
+ 'st' => 'application/vnd.sailingtracker.track',
706
+ 'stc' => 'application/vnd.sun.xml.calc.template',
707
+ 'std' => 'application/vnd.sun.xml.draw.template',
708
+ 'stf' => 'application/vnd.wt.stf',
709
+ 'sti' => 'application/vnd.sun.xml.impress.template',
710
+ 'stk' => 'application/hyperstudio',
711
+ 'stl' => 'application/vnd.ms-pki.stl',
712
+ 'str' => 'application/vnd.pg.format',
713
+ 'stw' => 'application/vnd.sun.xml.writer.template',
714
+ 'sub' => 'image/vnd.dvb.subtitle',
715
+ 'sus' => 'application/vnd.sus-calendar',
716
+ 'susp' => 'application/vnd.sus-calendar',
717
+ 'sv4cpio' => 'application/x-sv4cpio',
718
+ 'sv4crc' => 'application/x-sv4crc',
719
+ 'svc' => 'application/vnd.dvb.service',
720
+ 'svd' => 'application/vnd.svd',
721
+ 'svg' => 'image/svg+xml',
722
+ 'svgz' => 'image/svg+xml',
723
+ 'swa' => 'application/x-director',
724
+ 'swf' => 'application/x-shockwave-flash',
725
+ 'swi' => 'application/vnd.aristanetworks.swi',
726
+ 'sxc' => 'application/vnd.sun.xml.calc',
727
+ 'sxd' => 'application/vnd.sun.xml.draw',
728
+ 'sxg' => 'application/vnd.sun.xml.writer.global',
729
+ 'sxi' => 'application/vnd.sun.xml.impress',
730
+ 'sxm' => 'application/vnd.sun.xml.math',
731
+ 'sxw' => 'application/vnd.sun.xml.writer',
732
+ 't' => 'text/troff',
733
+ 'tao' => 'application/vnd.tao.intent-module-archive',
734
+ 'tar' => 'application/x-tar',
735
+ 'tcap' => 'application/vnd.3gpp2.tcap',
736
+ 'tcl' => 'application/x-tcl',
737
+ 'teacher' => 'application/vnd.smart.teacher',
738
+ 'tei' => 'application/tei+xml',
739
+ 'teicorpus' => 'application/tei+xml',
740
+ 'tex' => 'application/x-tex',
741
+ 'texi' => 'application/x-texinfo',
742
+ 'texinfo' => 'application/x-texinfo',
743
+ 'text' => 'text/plain',
744
+ 'tfi' => 'application/thraud+xml',
745
+ 'tfm' => 'application/x-tex-tfm',
746
+ 'thmx' => 'application/vnd.ms-officetheme',
747
+ 'tif' => 'image/tiff',
748
+ 'tiff' => 'image/tiff',
749
+ 'tmo' => 'application/vnd.tmobile-livetv',
750
+ 'torrent' => 'application/x-bittorrent',
751
+ 'tpl' => 'application/vnd.groove-tool-template',
752
+ 'tpt' => 'application/vnd.trid.tpt',
753
+ 'tr' => 'text/troff',
754
+ 'tra' => 'application/vnd.trueapp',
755
+ 'trm' => 'application/x-msterminal',
756
+ 'tsd' => 'application/timestamped-data',
757
+ 'tsv' => 'text/tab-separated-values',
758
+ 'ttc' => 'application/x-font-ttf',
759
+ 'ttf' => 'application/x-font-ttf',
760
+ 'ttl' => 'text/turtle',
761
+ 'twd' => 'application/vnd.simtech-mindmapper',
762
+ 'twds' => 'application/vnd.simtech-mindmapper',
763
+ 'txd' => 'application/vnd.genomatix.tuxedo',
764
+ 'txf' => 'application/vnd.mobius.txf',
765
+ 'txt' => 'text/plain',
766
+ 'u32' => 'application/x-authorware-bin',
767
+ 'udeb' => 'application/x-debian-package',
768
+ 'ufd' => 'application/vnd.ufdl',
769
+ 'ufdl' => 'application/vnd.ufdl',
770
+ 'umj' => 'application/vnd.umajin',
771
+ 'unityweb' => 'application/vnd.unity',
772
+ 'uoml' => 'application/vnd.uoml+xml',
773
+ 'uri' => 'text/uri-list',
774
+ 'uris' => 'text/uri-list',
775
+ 'urls' => 'text/uri-list',
776
+ 'ustar' => 'application/x-ustar',
777
+ 'utz' => 'application/vnd.uiq.theme',
778
+ 'uu' => 'text/x-uuencode',
779
+ 'uva' => 'audio/vnd.dece.audio',
780
+ 'uvd' => 'application/vnd.dece.data',
781
+ 'uvf' => 'application/vnd.dece.data',
782
+ 'uvg' => 'image/vnd.dece.graphic',
783
+ 'uvh' => 'video/vnd.dece.hd',
784
+ 'uvi' => 'image/vnd.dece.graphic',
785
+ 'uvm' => 'video/vnd.dece.mobile',
786
+ 'uvp' => 'video/vnd.dece.pd',
787
+ 'uvs' => 'video/vnd.dece.sd',
788
+ 'uvt' => 'application/vnd.dece.ttml+xml',
789
+ 'uvu' => 'video/vnd.uvvu.mp4',
790
+ 'uvv' => 'video/vnd.dece.video',
791
+ 'uvva' => 'audio/vnd.dece.audio',
792
+ 'uvvd' => 'application/vnd.dece.data',
793
+ 'uvvf' => 'application/vnd.dece.data',
794
+ 'uvvg' => 'image/vnd.dece.graphic',
795
+ 'uvvh' => 'video/vnd.dece.hd',
796
+ 'uvvi' => 'image/vnd.dece.graphic',
797
+ 'uvvm' => 'video/vnd.dece.mobile',
798
+ 'uvvp' => 'video/vnd.dece.pd',
799
+ 'uvvs' => 'video/vnd.dece.sd',
800
+ 'uvvt' => 'application/vnd.dece.ttml+xml',
801
+ 'uvvu' => 'video/vnd.uvvu.mp4',
802
+ 'uvvv' => 'video/vnd.dece.video',
803
+ 'uvvx' => 'application/vnd.dece.unspecified',
804
+ 'uvx' => 'application/vnd.dece.unspecified',
805
+ 'vcd' => 'application/x-cdlink',
806
+ 'vcf' => 'text/x-vcard',
807
+ 'vcg' => 'application/vnd.groove-vcard',
808
+ 'vcs' => 'text/x-vcalendar',
809
+ 'vcx' => 'application/vnd.vcx',
810
+ 'vis' => 'application/vnd.visionary',
811
+ 'viv' => 'video/vnd.vivo',
812
+ 'vor' => 'application/vnd.stardivision.writer',
813
+ 'vox' => 'application/x-authorware-bin',
814
+ 'vrml' => 'model/vrml',
815
+ 'vsd' => 'application/vnd.visio',
816
+ 'vsf' => 'application/vnd.vsf',
817
+ 'vss' => 'application/vnd.visio',
818
+ 'vst' => 'application/vnd.visio',
819
+ 'vsw' => 'application/vnd.visio',
820
+ 'vtu' => 'model/vnd.vtu',
821
+ 'vxml' => 'application/voicexml+xml',
822
+ 'w3d' => 'application/x-director',
823
+ 'wad' => 'application/x-doom',
824
+ 'wav' => 'audio/x-wav',
825
+ 'wax' => 'audio/x-ms-wax',
826
+ 'wbmp' => 'image/vnd.wap.wbmp',
827
+ 'wbs' => 'application/vnd.criticaltools.wbs+xml',
828
+ 'wbxml' => 'application/vnd.wap.wbxml',
829
+ 'wcm' => 'application/vnd.ms-works',
830
+ 'wdb' => 'application/vnd.ms-works',
831
+ 'weba' => 'audio/webm',
832
+ 'webm' => 'video/webm',
833
+ 'webp' => 'image/webp',
834
+ 'wg' => 'application/vnd.pmi.widget',
835
+ 'wgt' => 'application/widget',
836
+ 'wks' => 'application/vnd.ms-works',
837
+ 'wm' => 'video/x-ms-wm',
838
+ 'wma' => 'audio/x-ms-wma',
839
+ 'wmd' => 'application/x-ms-wmd',
840
+ 'wmf' => 'application/x-msmetafile',
841
+ 'wml' => 'text/vnd.wap.wml',
842
+ 'wmlc' => 'application/vnd.wap.wmlc',
843
+ 'wmls' => 'text/vnd.wap.wmlscript',
844
+ 'wmlsc' => 'application/vnd.wap.wmlscriptc',
845
+ 'wmv' => 'video/x-ms-wmv',
846
+ 'wmx' => 'video/x-ms-wmx',
847
+ 'wmz' => 'application/x-ms-wmz',
848
+ 'woff' => 'application/x-font-woff',
849
+ 'wpd' => 'application/vnd.wordperfect',
850
+ 'wpl' => 'application/vnd.ms-wpl',
851
+ 'wps' => 'application/vnd.ms-works',
852
+ 'wqd' => 'application/vnd.wqd',
853
+ 'wri' => 'application/x-mswrite',
854
+ 'wrl' => 'model/vrml',
855
+ 'wsdl' => 'application/wsdl+xml',
856
+ 'wspolicy' => 'application/wspolicy+xml',
857
+ 'wtb' => 'application/vnd.webturbo',
858
+ 'wvx' => 'video/x-ms-wvx',
859
+ 'x32' => 'application/x-authorware-bin',
860
+ 'x3d' => 'application/vnd.hzn-3d-crossword',
861
+ 'xap' => 'application/x-silverlight-app',
862
+ 'xar' => 'application/vnd.xara',
863
+ 'xbap' => 'application/x-ms-xbap',
864
+ 'xbd' => 'application/vnd.fujixerox.docuworks.binder',
865
+ 'xbm' => 'image/x-xbitmap',
866
+ 'xdf' => 'application/xcap-diff+xml',
867
+ 'xdm' => 'application/vnd.syncml.dm+xml',
868
+ 'xdp' => 'application/vnd.adobe.xdp+xml',
869
+ 'xdssc' => 'application/dssc+xml',
870
+ 'xdw' => 'application/vnd.fujixerox.docuworks',
871
+ 'xenc' => 'application/xenc+xml',
872
+ 'xer' => 'application/patch-ops-error+xml',
873
+ 'xfdf' => 'application/vnd.adobe.xfdf',
874
+ 'xfdl' => 'application/vnd.xfdl',
875
+ 'xht' => 'application/xhtml+xml',
876
+ 'xhtml' => 'application/xhtml+xml',
877
+ 'xhvml' => 'application/xv+xml',
878
+ 'xif' => 'image/vnd.xiff',
879
+ 'xla' => 'application/vnd.ms-excel',
880
+ 'xlam' => 'application/vnd.ms-excel.addin.macroenabled.12',
881
+ 'xlc' => 'application/vnd.ms-excel',
882
+ 'xlm' => 'application/vnd.ms-excel',
883
+ 'xls' => 'application/vnd.ms-excel',
884
+ 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroenabled.12',
885
+ 'xlsm' => 'application/vnd.ms-excel.sheet.macroenabled.12',
886
+ 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
887
+ 'xlt' => 'application/vnd.ms-excel',
888
+ 'xltm' => 'application/vnd.ms-excel.template.macroenabled.12',
889
+ 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
890
+ 'xlw' => 'application/vnd.ms-excel',
891
+ 'xml' => 'application/xml',
892
+ 'xo' => 'application/vnd.olpc-sugar',
893
+ 'xop' => 'application/xop+xml',
894
+ 'xpi' => 'application/x-xpinstall',
895
+ 'xpm' => 'image/x-xpixmap',
896
+ 'xpr' => 'application/vnd.is-xpr',
897
+ 'xps' => 'application/vnd.ms-xpsdocument',
898
+ 'xpw' => 'application/vnd.intercon.formnet',
899
+ 'xpx' => 'application/vnd.intercon.formnet',
900
+ 'xsl' => 'application/xml',
901
+ 'xslt' => 'application/xslt+xml',
902
+ 'xsm' => 'application/vnd.syncml+xml',
903
+ 'xspf' => 'application/xspf+xml',
904
+ 'xul' => 'application/vnd.mozilla.xul+xml',
905
+ 'xvm' => 'application/xv+xml',
906
+ 'xvml' => 'application/xv+xml',
907
+ 'xwd' => 'image/x-xwindowdump',
908
+ 'xyz' => 'chemical/x-xyz',
909
+ 'yaml' => 'text/yaml',
910
+ 'yang' => 'application/yang',
911
+ 'yin' => 'application/yin+xml',
912
+ 'yml' => 'text/yaml',
913
+ 'zaz' => 'application/vnd.zzazz.deck+xml',
914
+ 'zip' => 'application/zip',
915
+ 'zir' => 'application/vnd.zul',
916
+ 'zirz' => 'application/vnd.zul',
917
+ 'zmm' => 'application/vnd.handheld-entertainment+xml'
918
+ );
919
+
920
+ /**
921
+ * Get a singleton instance of the class
922
+ *
923
+ * @return self
924
+ * @codeCoverageIgnore
925
+ */
926
+ public static function getInstance()
927
+ {
928
+ if (!self::$instance) {
929
+ self::$instance = new self();
930
+ }
931
+
932
+ return self::$instance;
933
+ }
934
+
935
+ /**
936
+ * Get a mimetype value from a file extension
937
+ *
938
+ * @param string $extension File extension
939
+ *
940
+ * @return string|null
941
+ *
942
+ */
943
+ public function fromExtension($extension)
944
+ {
945
+ $extension = strtolower($extension);
946
+
947
+ return isset($this->mimetypes[$extension])
948
+ ? $this->mimetypes[$extension]
949
+ : null;
950
+ }
951
+
952
+ /**
953
+ * Get a mimetype from a filename
954
+ *
955
+ * @param string $filename Filename to generate a mimetype from
956
+ *
957
+ * @return string|null
958
+ */
959
+ public function fromFilename($filename)
960
+ {
961
+ return $this->fromExtension(pathinfo($filename, PATHINFO_EXTENSION));
962
+ }
963
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Pool.php ADDED
@@ -0,0 +1,333 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ use GuzzleHttp\Event\BeforeEvent;
5
+ use GuzzleHttp\Event\RequestEvents;
6
+ use GuzzleHttp\Message\RequestInterface;
7
+ use GuzzleHttp\Message\ResponseInterface;
8
+ use GuzzleHttp\Ring\Core;
9
+ use GuzzleHttp\Ring\Future\FutureInterface;
10
+ use GuzzleHttp\Event\ListenerAttacherTrait;
11
+ use GuzzleHttp\Event\EndEvent;
12
+ use React\Promise\Deferred;
13
+ use React\Promise\FulfilledPromise;
14
+ use React\Promise\PromiseInterface;
15
+ use React\Promise\RejectedPromise;
16
+
17
+ /**
18
+ * Sends and iterator of requests concurrently using a capped pool size.
19
+ *
20
+ * The Pool object implements FutureInterface, meaning it can be used later
21
+ * when necessary, the requests provided to the pool can be cancelled, and
22
+ * you can check the state of the pool to know if it has been dereferenced
23
+ * (sent) or has been cancelled.
24
+ *
25
+ * When sending the pool, keep in mind that no results are returned: callers
26
+ * are expected to handle results asynchronously using Guzzle's event system.
27
+ * When requests complete, more are added to the pool to ensure that the
28
+ * requested pool size is always filled as much as possible.
29
+ *
30
+ * IMPORTANT: Do not provide a pool size greater that what the utilized
31
+ * underlying RingPHP handler can support. This will result is extremely poor
32
+ * performance.
33
+ */
34
+ class Pool implements FutureInterface
35
+ {
36
+ use ListenerAttacherTrait;
37
+
38
+ /** @var \GuzzleHttp\ClientInterface */
39
+ private $client;
40
+
41
+ /** @var \Iterator Yields requests */
42
+ private $iter;
43
+
44
+ /** @var Deferred */
45
+ private $deferred;
46
+
47
+ /** @var PromiseInterface */
48
+ private $promise;
49
+
50
+ private $waitQueue = [];
51
+ private $eventListeners = [];
52
+ private $poolSize;
53
+ private $isRealized = false;
54
+
55
+ /**
56
+ * The option values for 'before', 'complete', 'error' and 'end' can be a
57
+ * callable, an associative array containing event data, or an array of
58
+ * event data arrays. Event data arrays contain the following keys:
59
+ *
60
+ * - fn: callable to invoke that receives the event
61
+ * - priority: Optional event priority (defaults to 0)
62
+ * - once: Set to true so that the event is removed after it is triggered
63
+ *
64
+ * @param ClientInterface $client Client used to send the requests.
65
+ * @param array|\Iterator $requests Requests to send in parallel
66
+ * @param array $options Associative array of options
67
+ * - pool_size: (callable|int) Maximum number of requests to send
68
+ * concurrently, or a callback that receives
69
+ * the current queue size and returns the
70
+ * number of new requests to send
71
+ * - before: (callable|array) Receives a BeforeEvent
72
+ * - complete: (callable|array) Receives a CompleteEvent
73
+ * - error: (callable|array) Receives a ErrorEvent
74
+ * - end: (callable|array) Receives an EndEvent
75
+ */
76
+ public function __construct(
77
+ ClientInterface $client,
78
+ $requests,
79
+ array $options = []
80
+ ) {
81
+ $this->client = $client;
82
+ $this->iter = $this->coerceIterable($requests);
83
+ $this->deferred = new Deferred();
84
+ $this->promise = $this->deferred->promise();
85
+ $this->poolSize = isset($options['pool_size'])
86
+ ? $options['pool_size'] : 25;
87
+ $this->eventListeners = $this->prepareListeners(
88
+ $options,
89
+ ['before', 'complete', 'error', 'end']
90
+ );
91
+ }
92
+
93
+ /**
94
+ * Sends multiple requests in parallel and returns an array of responses
95
+ * and exceptions that uses the same ordering as the provided requests.
96
+ *
97
+ * IMPORTANT: This method keeps every request and response in memory, and
98
+ * as such, is NOT recommended when sending a large number or an
99
+ * indeterminate number of requests concurrently.
100
+ *
101
+ * @param ClientInterface $client Client used to send the requests
102
+ * @param array|\Iterator $requests Requests to send in parallel
103
+ * @param array $options Passes through the options available in
104
+ * {@see GuzzleHttp\Pool::__construct}
105
+ *
106
+ * @return BatchResults Returns a container for the results.
107
+ * @throws \InvalidArgumentException if the event format is incorrect.
108
+ */
109
+ public static function batch(
110
+ ClientInterface $client,
111
+ $requests,
112
+ array $options = []
113
+ ) {
114
+ $hash = new \SplObjectStorage();
115
+ foreach ($requests as $request) {
116
+ $hash->attach($request);
117
+ }
118
+
119
+ // In addition to the normally run events when requests complete, add
120
+ // and event to continuously track the results of transfers in the hash.
121
+ (new self($client, $requests, RequestEvents::convertEventArray(
122
+ $options,
123
+ ['end'],
124
+ [
125
+ 'priority' => RequestEvents::LATE,
126
+ 'fn' => function (EndEvent $e) use ($hash) {
127
+ $hash[$e->getRequest()] = $e->getException()
128
+ ? $e->getException()
129
+ : $e->getResponse();
130
+ }
131
+ ]
132
+ )))->wait();
133
+
134
+ return new BatchResults($hash);
135
+ }
136
+
137
+ /**
138
+ * Creates a Pool and immediately sends the requests.
139
+ *
140
+ * @param ClientInterface $client Client used to send the requests
141
+ * @param array|\Iterator $requests Requests to send in parallel
142
+ * @param array $options Passes through the options available in
143
+ * {@see GuzzleHttp\Pool::__construct}
144
+ */
145
+ public static function send(
146
+ ClientInterface $client,
147
+ $requests,
148
+ array $options = []
149
+ ) {
150
+ $pool = new self($client, $requests, $options);
151
+ $pool->wait();
152
+ }
153
+
154
+ private function getPoolSize()
155
+ {
156
+ return is_callable($this->poolSize)
157
+ ? call_user_func($this->poolSize, count($this->waitQueue))
158
+ : $this->poolSize;
159
+ }
160
+
161
+ /**
162
+ * Add as many requests as possible up to the current pool limit.
163
+ */
164
+ private function addNextRequests()
165
+ {
166
+ $limit = max($this->getPoolSize() - count($this->waitQueue), 0);
167
+ while ($limit--) {
168
+ if (!$this->addNextRequest()) {
169
+ break;
170
+ }
171
+ }
172
+ }
173
+
174
+ public function wait()
175
+ {
176
+ if ($this->isRealized) {
177
+ return false;
178
+ }
179
+
180
+ // Seed the pool with N number of requests.
181
+ $this->addNextRequests();
182
+
183
+ // Stop if the pool was cancelled while transferring requests.
184
+ if ($this->isRealized) {
185
+ return false;
186
+ }
187
+
188
+ // Wait on any outstanding FutureResponse objects.
189
+ while ($response = array_pop($this->waitQueue)) {
190
+ try {
191
+ $response->wait();
192
+ } catch (\Exception $e) {
193
+ // Eat exceptions because they should be handled asynchronously
194
+ }
195
+ $this->addNextRequests();
196
+ }
197
+
198
+ // Clean up no longer needed state.
199
+ $this->isRealized = true;
200
+ $this->waitQueue = $this->eventListeners = [];
201
+ $this->client = $this->iter = null;
202
+ $this->deferred->resolve(true);
203
+
204
+ return true;
205
+ }
206
+
207
+ /**
208
+ * {@inheritdoc}
209
+ *
210
+ * Attempt to cancel all outstanding requests (requests that are queued for
211
+ * dereferencing). Returns true if all outstanding requests can be
212
+ * cancelled.
213
+ *
214
+ * @return bool
215
+ */
216
+ public function cancel()
217
+ {
218
+ if ($this->isRealized) {
219
+ return false;
220
+ }
221
+
222
+ $success = $this->isRealized = true;
223
+ foreach ($this->waitQueue as $response) {
224
+ if (!$response->cancel()) {
225
+ $success = false;
226
+ }
227
+ }
228
+
229
+ return $success;
230
+ }
231
+
232
+ /**
233
+ * Returns a promise that is invoked when the pool completed. There will be
234
+ * no passed value.
235
+ *
236
+ * {@inheritdoc}
237
+ */
238
+ public function then(
239
+ callable $onFulfilled = null,
240
+ callable $onRejected = null,
241
+ callable $onProgress = null
242
+ ) {
243
+ return $this->promise->then($onFulfilled, $onRejected, $onProgress);
244
+ }
245
+
246
+ public function promise()
247
+ {
248
+ return $this->promise;
249
+ }
250
+
251
+ private function coerceIterable($requests)
252
+ {
253
+ if ($requests instanceof \Iterator) {
254
+ return $requests;
255
+ } elseif (is_array($requests)) {
256
+ return new \ArrayIterator($requests);
257
+ }
258
+
259
+ throw new \InvalidArgumentException('Expected Iterator or array. '
260
+ . 'Found ' . Core::describeType($requests));
261
+ }
262
+
263
+ /**
264
+ * Adds the next request to pool and tracks what requests need to be
265
+ * dereferenced when completing the pool.
266
+ */
267
+ private function addNextRequest()
268
+ {
269
+ add_next:
270
+
271
+ if ($this->isRealized || !$this->iter || !$this->iter->valid()) {
272
+ return false;
273
+ }
274
+
275
+ $request = $this->iter->current();
276
+ $this->iter->next();
277
+
278
+ if (!($request instanceof RequestInterface)) {
279
+ throw new \InvalidArgumentException(sprintf(
280
+ 'All requests in the provided iterator must implement '
281
+ . 'RequestInterface. Found %s',
282
+ Core::describeType($request)
283
+ ));
284
+ }
285
+
286
+ // Be sure to use "lazy" futures, meaning they do not send right away.
287
+ $request->getConfig()->set('future', 'lazy');
288
+ $hash = spl_object_hash($request);
289
+ $this->attachListeners($request, $this->eventListeners);
290
+ $request->getEmitter()->on('before', [$this, '_trackRetries'], RequestEvents::EARLY);
291
+ $response = $this->client->send($request);
292
+ $this->waitQueue[$hash] = $response;
293
+ $promise = $response->promise();
294
+
295
+ // Don't recursively call itself for completed or rejected responses.
296
+ if ($promise instanceof FulfilledPromise
297
+ || $promise instanceof RejectedPromise
298
+ ) {
299
+ try {
300
+ $this->finishResponse($request, $response->wait(), $hash);
301
+ } catch (\Exception $e) {
302
+ $this->finishResponse($request, $e, $hash);
303
+ }
304
+ goto add_next;
305
+ }
306
+
307
+ // Use this function for both resolution and rejection.
308
+ $thenFn = function ($value) use ($request, $hash) {
309
+ $this->finishResponse($request, $value, $hash);
310
+ if (!$request->getConfig()->get('_pool_retries')) {
311
+ $this->addNextRequests();
312
+ }
313
+ };
314
+
315
+ $promise->then($thenFn, $thenFn);
316
+
317
+ return true;
318
+ }
319
+
320
+ public function _trackRetries(BeforeEvent $e)
321
+ {
322
+ $e->getRequest()->getConfig()->set('_pool_retries', $e->getRetryCount());
323
+ }
324
+
325
+ private function finishResponse($request, $value, $hash)
326
+ {
327
+ unset($this->waitQueue[$hash]);
328
+ $result = $value instanceof ResponseInterface
329
+ ? ['request' => $request, 'response' => $value, 'error' => null]
330
+ : ['request' => $request, 'response' => null, 'error' => $value];
331
+ $this->deferred->notify($result);
332
+ }
333
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Post/MultipartBody.php ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Post;
3
+
4
+ use GuzzleHttp\Stream\AppendStream;
5
+ use GuzzleHttp\Stream\Stream;
6
+ use GuzzleHttp\Stream\StreamDecoratorTrait;
7
+ use GuzzleHttp\Stream\StreamInterface;
8
+
9
+ /**
10
+ * Stream that when read returns bytes for a streaming multipart/form-data body
11
+ */
12
+ class MultipartBody implements StreamInterface
13
+ {
14
+ use StreamDecoratorTrait;
15
+
16
+ private $boundary;
17
+
18
+ /**
19
+ * @param array $fields Associative array of field names to values where
20
+ * each value is a string or array of strings.
21
+ * @param array $files Associative array of PostFileInterface objects
22
+ * @param string $boundary You can optionally provide a specific boundary
23
+ * @throws \InvalidArgumentException
24
+ */
25
+ public function __construct(
26
+ array $fields = [],
27
+ array $files = [],
28
+ $boundary = null
29
+ ) {
30
+ $this->boundary = $boundary ?: uniqid();
31
+ $this->stream = $this->createStream($fields, $files);
32
+ }
33
+
34
+ /**
35
+ * Get the boundary
36
+ *
37
+ * @return string
38
+ */
39
+ public function getBoundary()
40
+ {
41
+ return $this->boundary;
42
+ }
43
+
44
+ public function isWritable()
45
+ {
46
+ return false;
47
+ }
48
+
49
+ /**
50
+ * Get the string needed to transfer a POST field
51
+ */
52
+ private function getFieldString($name, $value)
53
+ {
54
+ return sprintf(
55
+ "--%s\r\nContent-Disposition: form-data; name=\"%s\"\r\n\r\n%s\r\n",
56
+ $this->boundary,
57
+ $name,
58
+ $value
59
+ );
60
+ }
61
+
62
+ /**
63
+ * Get the headers needed before transferring the content of a POST file
64
+ */
65
+ private function getFileHeaders(PostFileInterface $file)
66
+ {
67
+ $headers = '';
68
+ foreach ($file->getHeaders() as $key => $value) {
69
+ $headers .= "{$key}: {$value}\r\n";
70
+ }
71
+
72
+ return "--{$this->boundary}\r\n" . trim($headers) . "\r\n\r\n";
73
+ }
74
+
75
+ /**
76
+ * Create the aggregate stream that will be used to upload the POST data
77
+ */
78
+ protected function createStream(array $fields, array $files)
79
+ {
80
+ $stream = new AppendStream();
81
+
82
+ foreach ($fields as $name => $fieldValues) {
83
+ foreach ((array) $fieldValues as $value) {
84
+ $stream->addStream(
85
+ Stream::factory($this->getFieldString($name, $value))
86
+ );
87
+ }
88
+ }
89
+
90
+ foreach ($files as $file) {
91
+
92
+ if (!$file instanceof PostFileInterface) {
93
+ throw new \InvalidArgumentException('All POST fields must '
94
+ . 'implement PostFieldInterface');
95
+ }
96
+
97
+ $stream->addStream(
98
+ Stream::factory($this->getFileHeaders($file))
99
+ );
100
+ $stream->addStream($file->getContent());
101
+ $stream->addStream(Stream::factory("\r\n"));
102
+ }
103
+
104
+ // Add the trailing boundary with CRLF
105
+ $stream->addStream(Stream::factory("--{$this->boundary}--\r\n"));
106
+
107
+ return $stream;
108
+ }
109
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Post/PostBody.php ADDED
@@ -0,0 +1,287 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Post;
3
+
4
+ use GuzzleHttp\Message\RequestInterface;
5
+ use GuzzleHttp\Stream\Exception\CannotAttachException;
6
+ use GuzzleHttp\Stream\StreamInterface;
7
+ use GuzzleHttp\Stream\Stream;
8
+ use GuzzleHttp\Query;
9
+
10
+ /**
11
+ * Holds POST fields and files and creates a streaming body when read methods
12
+ * are called on the object.
13
+ */
14
+ class PostBody implements PostBodyInterface
15
+ {
16
+ /** @var StreamInterface */
17
+ private $body;
18
+
19
+ /** @var callable */
20
+ private $aggregator;
21
+
22
+ private $fields = [];
23
+
24
+ /** @var PostFileInterface[] */
25
+ private $files = [];
26
+ private $forceMultipart = false;
27
+ private $detached = false;
28
+
29
+ /**
30
+ * Applies request headers to a request based on the POST state
31
+ *
32
+ * @param RequestInterface $request Request to update
33
+ */
34
+ public function applyRequestHeaders(RequestInterface $request)
35
+ {
36
+ if ($this->files || $this->forceMultipart) {
37
+ $request->setHeader(
38
+ 'Content-Type',
39
+ 'multipart/form-data; boundary=' . $this->getBody()->getBoundary()
40
+ );
41
+ } elseif ($this->fields && !$request->hasHeader('Content-Type')) {
42
+ $request->setHeader(
43
+ 'Content-Type',
44
+ 'application/x-www-form-urlencoded'
45
+ );
46
+ }
47
+
48
+ if ($size = $this->getSize()) {
49
+ $request->setHeader('Content-Length', $size);
50
+ }
51
+ }
52
+
53
+ public function forceMultipartUpload($force)
54
+ {
55
+ $this->forceMultipart = $force;
56
+ }
57
+
58
+ public function setAggregator(callable $aggregator)
59
+ {
60
+ $this->aggregator = $aggregator;
61
+ }
62
+
63
+ public function setField($name, $value)
64
+ {
65
+ $this->fields[$name] = $value;
66
+ $this->mutate();
67
+ }
68
+
69
+ public function replaceFields(array $fields)
70
+ {
71
+ $this->fields = $fields;
72
+ $this->mutate();
73
+ }
74
+
75
+ public function getField($name)
76
+ {
77
+ return isset($this->fields[$name]) ? $this->fields[$name] : null;
78
+ }
79
+
80
+ public function removeField($name)
81
+ {
82
+ unset($this->fields[$name]);
83
+ $this->mutate();
84
+ }
85
+
86
+ public function getFields($asString = false)
87
+ {
88
+ if (!$asString) {
89
+ return $this->fields;
90
+ }
91
+
92
+ $query = new Query($this->fields);
93
+ $query->setEncodingType(Query::RFC1738);
94
+ $query->setAggregator($this->getAggregator());
95
+
96
+ return (string) $query;
97
+ }
98
+
99
+ public function hasField($name)
100
+ {
101
+ return isset($this->fields[$name]);
102
+ }
103
+
104
+ public function getFile($name)
105
+ {
106
+ foreach ($this->files as $file) {
107
+ if ($file->getName() == $name) {
108
+ return $file;
109
+ }
110
+ }
111
+
112
+ return null;
113
+ }
114
+
115
+ public function getFiles()
116
+ {
117
+ return $this->files;
118
+ }
119
+
120
+ public function addFile(PostFileInterface $file)
121
+ {
122
+ $this->files[] = $file;
123
+ $this->mutate();
124
+ }
125
+
126
+ public function clearFiles()
127
+ {
128
+ $this->files = [];
129
+ $this->mutate();
130
+ }
131
+
132
+ /**
133
+ * Returns the numbers of fields + files
134
+ *
135
+ * @return int
136
+ */
137
+ public function count()
138
+ {
139
+ return count($this->files) + count($this->fields);
140
+ }
141
+
142
+ public function __toString()
143
+ {
144
+ return (string) $this->getBody();
145
+ }
146
+
147
+ public function getContents($maxLength = -1)
148
+ {
149
+ return $this->getBody()->getContents();
150
+ }
151
+
152
+ public function close()
153
+ {
154
+ $this->detach();
155
+ }
156
+
157
+ public function detach()
158
+ {
159
+ $this->detached = true;
160
+ $this->fields = $this->files = [];
161
+
162
+ if ($this->body) {
163
+ $this->body->close();
164
+ $this->body = null;
165
+ }
166
+ }
167
+
168
+ public function attach($stream)
169
+ {
170
+ throw new CannotAttachException();
171
+ }
172
+
173
+ public function eof()
174
+ {
175
+ return $this->getBody()->eof();
176
+ }
177
+
178
+ public function tell()
179
+ {
180
+ return $this->body ? $this->body->tell() : 0;
181
+ }
182
+
183
+ public function isSeekable()
184
+ {
185
+ return true;
186
+ }
187
+
188
+ public function isReadable()
189
+ {
190
+ return true;
191
+ }
192
+
193
+ public function isWritable()
194
+ {
195
+ return false;
196
+ }
197
+
198
+ public function getSize()
199
+ {
200
+ return $this->getBody()->getSize();
201
+ }
202
+
203
+ public function seek($offset, $whence = SEEK_SET)
204
+ {
205
+ return $this->getBody()->seek($offset, $whence);
206
+ }
207
+
208
+ public function read($length)
209
+ {
210
+ return $this->getBody()->read($length);
211
+ }
212
+
213
+ public function write($string)
214
+ {
215
+ return false;
216
+ }
217
+
218
+ public function getMetadata($key = null)
219
+ {
220
+ return $key ? null : [];
221
+ }
222
+
223
+ /**
224
+ * Return a stream object that is built from the POST fields and files.
225
+ *
226
+ * If one has already been created, the previously created stream will be
227
+ * returned.
228
+ */
229
+ private function getBody()
230
+ {
231
+ if ($this->body) {
232
+ return $this->body;
233
+ } elseif ($this->files || $this->forceMultipart) {
234
+ return $this->body = $this->createMultipart();
235
+ } elseif ($this->fields) {
236
+ return $this->body = $this->createUrlEncoded();
237
+ } else {
238
+ return $this->body = Stream::factory();
239
+ }
240
+ }
241
+
242
+ /**
243
+ * Get the aggregator used to join multi-valued field parameters
244
+ *
245
+ * @return callable
246
+ */
247
+ final protected function getAggregator()
248
+ {
249
+ if (!$this->aggregator) {
250
+ $this->aggregator = Query::phpAggregator();
251
+ }
252
+
253
+ return $this->aggregator;
254
+ }
255
+
256
+ /**
257
+ * Creates a multipart/form-data body stream
258
+ *
259
+ * @return MultipartBody
260
+ */
261
+ private function createMultipart()
262
+ {
263
+ // Flatten the nested query string values using the correct aggregator
264
+ return new MultipartBody(
265
+ call_user_func($this->getAggregator(), $this->fields),
266
+ $this->files
267
+ );
268
+ }
269
+
270
+ /**
271
+ * Creates an application/x-www-form-urlencoded stream body
272
+ *
273
+ * @return StreamInterface
274
+ */
275
+ private function createUrlEncoded()
276
+ {
277
+ return Stream::factory($this->getFields(true));
278
+ }
279
+
280
+ /**
281
+ * Get rid of any cached data
282
+ */
283
+ private function mutate()
284
+ {
285
+ $this->body = null;
286
+ }
287
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Post/PostBodyInterface.php ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Post;
3
+
4
+ use GuzzleHttp\Message\AppliesHeadersInterface;
5
+ use GuzzleHttp\Stream\StreamInterface;
6
+
7
+ /**
8
+ * Represents a POST body that is sent as either a multipart/form-data stream
9
+ * or application/x-www-urlencoded stream.
10
+ */
11
+ interface PostBodyInterface extends StreamInterface, \Countable, AppliesHeadersInterface
12
+ {
13
+ /**
14
+ * Set a specific field
15
+ *
16
+ * @param string $name Name of the field to set
17
+ * @param string|array $value Value to set
18
+ */
19
+ public function setField($name, $value);
20
+
21
+ /**
22
+ * Set the aggregation strategy that will be used to turn multi-valued
23
+ * fields into a string.
24
+ *
25
+ * The aggregation function accepts a deeply nested array of query string
26
+ * values and returns a flattened associative array of key value pairs.
27
+ *
28
+ * @param callable $aggregator
29
+ */
30
+ public function setAggregator(callable $aggregator);
31
+
32
+ /**
33
+ * Set to true to force a multipart upload even if there are no files.
34
+ *
35
+ * @param bool $force Set to true to force multipart uploads or false to
36
+ * remove this flag.
37
+ */
38
+ public function forceMultipartUpload($force);
39
+
40
+ /**
41
+ * Replace all existing form fields with an array of fields
42
+ *
43
+ * @param array $fields Associative array of fields to set
44
+ */
45
+ public function replaceFields(array $fields);
46
+
47
+ /**
48
+ * Get a specific field by name
49
+ *
50
+ * @param string $name Name of the POST field to retrieve
51
+ *
52
+ * @return string|null
53
+ */
54
+ public function getField($name);
55
+
56
+ /**
57
+ * Remove a field by name
58
+ *
59
+ * @param string $name Name of the field to remove
60
+ */
61
+ public function removeField($name);
62
+
63
+ /**
64
+ * Returns an associative array of names to values or a query string.
65
+ *
66
+ * @param bool $asString Set to true to retrieve the fields as a query
67
+ * string.
68
+ *
69
+ * @return array|string
70
+ */
71
+ public function getFields($asString = false);
72
+
73
+ /**
74
+ * Returns true if a field is set
75
+ *
76
+ * @param string $name Name of the field to set
77
+ *
78
+ * @return bool
79
+ */
80
+ public function hasField($name);
81
+
82
+ /**
83
+ * Get all of the files
84
+ *
85
+ * @return array Returns an array of PostFileInterface objects
86
+ */
87
+ public function getFiles();
88
+
89
+ /**
90
+ * Get a POST file by name.
91
+ *
92
+ * @param string $name Name of the POST file to retrieve
93
+ *
94
+ * @return PostFileInterface|null
95
+ */
96
+ public function getFile($name);
97
+
98
+ /**
99
+ * Add a file to the POST
100
+ *
101
+ * @param PostFileInterface $file File to add
102
+ */
103
+ public function addFile(PostFileInterface $file);
104
+
105
+ /**
106
+ * Remove all files from the collection
107
+ */
108
+ public function clearFiles();
109
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Post/PostFile.php ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Post;
3
+
4
+ use GuzzleHttp\Mimetypes;
5
+ use GuzzleHttp\Stream\StreamInterface;
6
+ use GuzzleHttp\Stream\Stream;
7
+
8
+ /**
9
+ * Post file upload
10
+ */
11
+ class PostFile implements PostFileInterface
12
+ {
13
+ private $name;
14
+ private $filename;
15
+ private $content;
16
+ private $headers = [];
17
+
18
+ /**
19
+ * @param string $name Name of the form field
20
+ * @param mixed $content Data to send
21
+ * @param string|null $filename Filename content-disposition attribute
22
+ * @param array $headers Array of headers to set on the file
23
+ * (can override any default headers)
24
+ * @throws \RuntimeException when filename is not passed or can't be determined
25
+ */
26
+ public function __construct(
27
+ $name,
28
+ $content,
29
+ $filename = null,
30
+ array $headers = []
31
+ ) {
32
+ $this->headers = $headers;
33
+ $this->name = $name;
34
+ $this->prepareContent($content);
35
+ $this->prepareFilename($filename);
36
+ $this->prepareDefaultHeaders();
37
+ }
38
+
39
+ public function getName()
40
+ {
41
+ return $this->name;
42
+ }
43
+
44
+ public function getFilename()
45
+ {
46
+ return $this->filename;
47
+ }
48
+
49
+ public function getContent()
50
+ {
51
+ return $this->content;
52
+ }
53
+
54
+ public function getHeaders()
55
+ {
56
+ return $this->headers;
57
+ }
58
+
59
+ /**
60
+ * Prepares the contents of a POST file.
61
+ *
62
+ * @param mixed $content Content of the POST file
63
+ */
64
+ private function prepareContent($content)
65
+ {
66
+ $this->content = $content;
67
+
68
+ if (!($this->content instanceof StreamInterface)) {
69
+ $this->content = Stream::factory($this->content);
70
+ } elseif ($this->content instanceof MultipartBody) {
71
+ if (!$this->hasHeader('Content-Disposition')) {
72
+ $disposition = 'form-data; name="' . $this->name .'"';
73
+ $this->headers['Content-Disposition'] = $disposition;
74
+ }
75
+
76
+ if (!$this->hasHeader('Content-Type')) {
77
+ $this->headers['Content-Type'] = sprintf(
78
+ "multipart/form-data; boundary=%s",
79
+ $this->content->getBoundary()
80
+ );
81
+ }
82
+ }
83
+ }
84
+
85
+ /**
86
+ * Applies a file name to the POST file based on various checks.
87
+ *
88
+ * @param string|null $filename Filename to apply (or null to guess)
89
+ */
90
+ private function prepareFilename($filename)
91
+ {
92
+ $this->filename = $filename;
93
+
94
+ if (!$this->filename) {
95
+ $this->filename = $this->content->getMetadata('uri');
96
+ }
97
+
98
+ if (!$this->filename || substr($this->filename, 0, 6) === 'php://') {
99
+ $this->filename = $this->name;
100
+ }
101
+ }
102
+
103
+ /**
104
+ * Applies default Content-Disposition and Content-Type headers if needed.
105
+ */
106
+ private function prepareDefaultHeaders()
107
+ {
108
+ // Set a default content-disposition header if one was no provided
109
+ if (!$this->hasHeader('Content-Disposition')) {
110
+ $this->headers['Content-Disposition'] = sprintf(
111
+ 'form-data; name="%s"; filename="%s"',
112
+ $this->name,
113
+ basename($this->filename)
114
+ );
115
+ }
116
+
117
+ // Set a default Content-Type if one was not supplied
118
+ if (!$this->hasHeader('Content-Type')) {
119
+ $this->headers['Content-Type'] = Mimetypes::getInstance()
120
+ ->fromFilename($this->filename) ?: 'text/plain';
121
+ }
122
+ }
123
+
124
+ /**
125
+ * Check if a specific header exists on the POST file by name.
126
+ *
127
+ * @param string $name Case-insensitive header to check
128
+ *
129
+ * @return bool
130
+ */
131
+ private function hasHeader($name)
132
+ {
133
+ return isset(array_change_key_case($this->headers)[strtolower($name)]);
134
+ }
135
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Post/PostFileInterface.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Post;
3
+
4
+ use GuzzleHttp\Stream\StreamInterface;
5
+
6
+ /**
7
+ * Post file upload interface
8
+ */
9
+ interface PostFileInterface
10
+ {
11
+ /**
12
+ * Get the name of the form field
13
+ *
14
+ * @return string
15
+ */
16
+ public function getName();
17
+
18
+ /**
19
+ * Get the full path to the file
20
+ *
21
+ * @return string
22
+ */
23
+ public function getFilename();
24
+
25
+ /**
26
+ * Get the content
27
+ *
28
+ * @return StreamInterface
29
+ */
30
+ public function getContent();
31
+
32
+ /**
33
+ * Gets all POST file headers.
34
+ *
35
+ * The keys represent the header name as it will be sent over the wire, and
36
+ * each value is a string.
37
+ *
38
+ * @return array Returns an associative array of the file's headers.
39
+ */
40
+ public function getHeaders();
41
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Query.php ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ /**
5
+ * Manages query string variables and can aggregate them into a string
6
+ */
7
+ class Query extends Collection
8
+ {
9
+ const RFC3986 = 'RFC3986';
10
+ const RFC1738 = 'RFC1738';
11
+
12
+ /** @var callable Encoding function */
13
+ private $encoding = 'rawurlencode';
14
+ /** @var callable */
15
+ private $aggregator;
16
+
17
+ /**
18
+ * Parse a query string into a Query object
19
+ *
20
+ * $urlEncoding is used to control how the query string is parsed and how
21
+ * it is ultimately serialized. The value can be set to one of the
22
+ * following:
23
+ *
24
+ * - true: (default) Parse query strings using RFC 3986 while still
25
+ * converting "+" to " ".
26
+ * - false: Disables URL decoding of the input string and URL encoding when
27
+ * the query string is serialized.
28
+ * - 'RFC3986': Use RFC 3986 URL encoding/decoding
29
+ * - 'RFC1738': Use RFC 1738 URL encoding/decoding
30
+ *
31
+ * @param string $query Query string to parse
32
+ * @param bool|string $urlEncoding Controls how the input string is decoded
33
+ * and encoded.
34
+ * @return self
35
+ */
36
+ public static function fromString($query, $urlEncoding = true)
37
+ {
38
+ static $qp;
39
+ if (!$qp) {
40
+ $qp = new QueryParser();
41
+ }
42
+
43
+ $q = new static();
44
+
45
+ if ($urlEncoding !== true) {
46
+ $q->setEncodingType($urlEncoding);
47
+ }
48
+
49
+ $qp->parseInto($q, $query, $urlEncoding);
50
+
51
+ return $q;
52
+ }
53
+
54
+ /**
55
+ * Convert the query string parameters to a query string string
56
+ *
57
+ * @return string
58
+ */
59
+ public function __toString()
60
+ {
61
+ if (!$this->data) {
62
+ return '';
63
+ }
64
+
65
+ // The default aggregator is statically cached
66
+ static $defaultAggregator;
67
+
68
+ if (!$this->aggregator) {
69
+ if (!$defaultAggregator) {
70
+ $defaultAggregator = self::phpAggregator();
71
+ }
72
+ $this->aggregator = $defaultAggregator;
73
+ }
74
+
75
+ $result = '';
76
+ $aggregator = $this->aggregator;
77
+ $encoder = $this->encoding;
78
+
79
+ foreach ($aggregator($this->data) as $key => $values) {
80
+ foreach ($values as $value) {
81
+ if ($result) {
82
+ $result .= '&';
83
+ }
84
+ $result .= $encoder($key);
85
+ if ($value !== null) {
86
+ $result .= '=' . $encoder($value);
87
+ }
88
+ }
89
+ }
90
+
91
+ return $result;
92
+ }
93
+
94
+ /**
95
+ * Controls how multi-valued query string parameters are aggregated into a
96
+ * string.
97
+ *
98
+ * $query->setAggregator($query::duplicateAggregator());
99
+ *
100
+ * @param callable $aggregator Callable used to convert a deeply nested
101
+ * array of query string variables into a flattened array of key value
102
+ * pairs. The callable accepts an array of query data and returns a
103
+ * flattened array of key value pairs where each value is an array of
104
+ * strings.
105
+ */
106
+ public function setAggregator(callable $aggregator)
107
+ {
108
+ $this->aggregator = $aggregator;
109
+ }
110
+
111
+ /**
112
+ * Specify how values are URL encoded
113
+ *
114
+ * @param string|bool $type One of 'RFC1738', 'RFC3986', or false to disable encoding
115
+ *
116
+ * @throws \InvalidArgumentException
117
+ */
118
+ public function setEncodingType($type)
119
+ {
120
+ switch ($type) {
121
+ case self::RFC3986:
122
+ $this->encoding = 'rawurlencode';
123
+ break;
124
+ case self::RFC1738:
125
+ $this->encoding = 'urlencode';
126
+ break;
127
+ case false:
128
+ $this->encoding = function ($v) { return $v; };
129
+ break;
130
+ default:
131
+ throw new \InvalidArgumentException('Invalid URL encoding type');
132
+ }
133
+ }
134
+
135
+ /**
136
+ * Query string aggregator that does not aggregate nested query string
137
+ * values and allows duplicates in the resulting array.
138
+ *
139
+ * Example: http://test.com?q=1&q=2
140
+ *
141
+ * @return callable
142
+ */
143
+ public static function duplicateAggregator()
144
+ {
145
+ return function (array $data) {
146
+ return self::walkQuery($data, '', function ($key, $prefix) {
147
+ return is_int($key) ? $prefix : "{$prefix}[{$key}]";
148
+ });
149
+ };
150
+ }
151
+
152
+ /**
153
+ * Aggregates nested query string variables using the same technique as
154
+ * ``http_build_query()``.
155
+ *
156
+ * @param bool $numericIndices Pass false to not include numeric indices
157
+ * when multi-values query string parameters are present.
158
+ *
159
+ * @return callable
160
+ */
161
+ public static function phpAggregator($numericIndices = true)
162
+ {
163
+ return function (array $data) use ($numericIndices) {
164
+ return self::walkQuery(
165
+ $data,
166
+ '',
167
+ function ($key, $prefix) use ($numericIndices) {
168
+ return !$numericIndices && is_int($key)
169
+ ? "{$prefix}[]"
170
+ : "{$prefix}[{$key}]";
171
+ }
172
+ );
173
+ };
174
+ }
175
+
176
+ /**
177
+ * Easily create query aggregation functions by providing a key prefix
178
+ * function to this query string array walker.
179
+ *
180
+ * @param array $query Query string to walk
181
+ * @param string $keyPrefix Key prefix (start with '')
182
+ * @param callable $prefixer Function used to create a key prefix
183
+ *
184
+ * @return array
185
+ */
186
+ public static function walkQuery(array $query, $keyPrefix, callable $prefixer)
187
+ {
188
+ $result = [];
189
+ foreach ($query as $key => $value) {
190
+ if ($keyPrefix) {
191
+ $key = $prefixer($key, $keyPrefix);
192
+ }
193
+ if (is_array($value)) {
194
+ $result += self::walkQuery($value, $key, $prefixer);
195
+ } elseif (isset($result[$key])) {
196
+ $result[$key][] = $value;
197
+ } else {
198
+ $result[$key] = array($value);
199
+ }
200
+ }
201
+
202
+ return $result;
203
+ }
204
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/QueryParser.php ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ /**
5
+ * Parses query strings into a Query object.
6
+ *
7
+ * While parsing, the parser will attempt to determine the most appropriate
8
+ * query string aggregator to use when serializing the parsed query string
9
+ * object back into a string. The hope is that parsing then serializing a
10
+ * query string should be a lossless operation.
11
+ *
12
+ * @internal Use Query::fromString()
13
+ */
14
+ class QueryParser
15
+ {
16
+ private $duplicates;
17
+ private $numericIndices;
18
+
19
+ /**
20
+ * Parse a query string into a Query object.
21
+ *
22
+ * @param Query $query Query object to populate
23
+ * @param string $str Query string to parse
24
+ * @param bool|string $urlEncoding How the query string is encoded
25
+ */
26
+ public function parseInto(Query $query, $str, $urlEncoding = true)
27
+ {
28
+ if ($str === '') {
29
+ return;
30
+ }
31
+
32
+ $result = [];
33
+ $this->duplicates = false;
34
+ $this->numericIndices = true;
35
+ $decoder = self::getDecoder($urlEncoding);
36
+
37
+ foreach (explode('&', $str) as $kvp) {
38
+
39
+ $parts = explode('=', $kvp, 2);
40
+ $key = $decoder($parts[0]);
41
+ $value = isset($parts[1]) ? $decoder($parts[1]) : null;
42
+
43
+ // Special handling needs to be taken for PHP nested array syntax
44
+ if (strpos($key, '[') !== false) {
45
+ $this->parsePhpValue($key, $value, $result);
46
+ continue;
47
+ }
48
+
49
+ if (!isset($result[$key])) {
50
+ $result[$key] = $value;
51
+ } else {
52
+ $this->duplicates = true;
53
+ if (!is_array($result[$key])) {
54
+ $result[$key] = [$result[$key]];
55
+ }
56
+ $result[$key][] = $value;
57
+ }
58
+ }
59
+
60
+ $query->replace($result);
61
+
62
+ if (!$this->numericIndices) {
63
+ $query->setAggregator(Query::phpAggregator(false));
64
+ } elseif ($this->duplicates) {
65
+ $query->setAggregator(Query::duplicateAggregator());
66
+ }
67
+ }
68
+
69
+ /**
70
+ * Returns a callable that is used to URL decode query keys and values.
71
+ *
72
+ * @param string|bool $type One of true, false, RFC3986, and RFC1738
73
+ *
74
+ * @return callable|string
75
+ */
76
+ private static function getDecoder($type)
77
+ {
78
+ if ($type === true) {
79
+ return function ($value) {
80
+ return rawurldecode(str_replace('+', ' ', $value));
81
+ };
82
+ } elseif ($type == Query::RFC3986) {
83
+ return 'rawurldecode';
84
+ } elseif ($type == Query::RFC1738) {
85
+ return 'urldecode';
86
+ } else {
87
+ return function ($str) { return $str; };
88
+ }
89
+ }
90
+
91
+ /**
92
+ * Parses a PHP style key value pair.
93
+ *
94
+ * @param string $key Key to parse (e.g., "foo[a][b]")
95
+ * @param string|null $value Value to set
96
+ * @param array $result Result to modify by reference
97
+ */
98
+ private function parsePhpValue($key, $value, array &$result)
99
+ {
100
+ $node =& $result;
101
+ $keyBuffer = '';
102
+
103
+ for ($i = 0, $t = strlen($key); $i < $t; $i++) {
104
+ switch ($key[$i]) {
105
+ case '[':
106
+ if ($keyBuffer) {
107
+ $this->prepareNode($node, $keyBuffer);
108
+ $node =& $node[$keyBuffer];
109
+ $keyBuffer = '';
110
+ }
111
+ break;
112
+ case ']':
113
+ $k = $this->cleanKey($node, $keyBuffer);
114
+ $this->prepareNode($node, $k);
115
+ $node =& $node[$k];
116
+ $keyBuffer = '';
117
+ break;
118
+ default:
119
+ $keyBuffer .= $key[$i];
120
+ break;
121
+ }
122
+ }
123
+
124
+ if (isset($node)) {
125
+ $this->duplicates = true;
126
+ $node[] = $value;
127
+ } else {
128
+ $node = $value;
129
+ }
130
+ }
131
+
132
+ /**
133
+ * Prepares a value in the array at the given key.
134
+ *
135
+ * If the key already exists, the key value is converted into an array.
136
+ *
137
+ * @param array $node Result node to modify
138
+ * @param string $key Key to add or modify in the node
139
+ */
140
+ private function prepareNode(&$node, $key)
141
+ {
142
+ if (!isset($node[$key])) {
143
+ $node[$key] = null;
144
+ } elseif (!is_array($node[$key])) {
145
+ $node[$key] = [$node[$key]];
146
+ }
147
+ }
148
+
149
+ /**
150
+ * Returns the appropriate key based on the node and key.
151
+ */
152
+ private function cleanKey($node, $key)
153
+ {
154
+ if ($key === '') {
155
+ $key = $node ? (string) count($node) : 0;
156
+ // Found a [] key, so track this to ensure that we disable numeric
157
+ // indexing of keys in the resolved query aggregator.
158
+ $this->numericIndices = false;
159
+ }
160
+
161
+ return $key;
162
+ }
163
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/RequestFsm.php ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ use GuzzleHttp\Event\BeforeEvent;
5
+ use GuzzleHttp\Event\ErrorEvent;
6
+ use GuzzleHttp\Event\CompleteEvent;
7
+ use GuzzleHttp\Event\EndEvent;
8
+ use GuzzleHttp\Exception\StateException;
9
+ use GuzzleHttp\Exception\RequestException;
10
+ use GuzzleHttp\Message\FutureResponse;
11
+ use GuzzleHttp\Message\MessageFactoryInterface;
12
+ use GuzzleHttp\Ring\Future\FutureInterface;
13
+
14
+ /**
15
+ * Responsible for transitioning requests through lifecycle events.
16
+ */
17
+ class RequestFsm
18
+ {
19
+ private $handler;
20
+ private $mf;
21
+ private $maxTransitions;
22
+
23
+ public function __construct(
24
+ callable $handler,
25
+ MessageFactoryInterface $messageFactory,
26
+ $maxTransitions = 200
27
+ ) {
28
+ $this->mf = $messageFactory;
29
+ $this->maxTransitions = $maxTransitions;
30
+ $this->handler = $handler;
31
+ }
32
+
33
+ /**
34
+ * Runs the state machine until a terminal state is entered or the
35
+ * optionally supplied $finalState is entered.
36
+ *
37
+ * @param Transaction $trans Transaction being transitioned.
38
+ *
39
+ * @throws \Exception if a terminal state throws an exception.
40
+ */
41
+ public function __invoke(Transaction $trans)
42
+ {
43
+ $trans->_transitionCount = 0;
44
+
45
+ if (!$trans->state) {
46
+ $trans->state = 'before';
47
+ }
48
+
49
+ transition:
50
+
51
+ if (++$trans->_transitionCount > $this->maxTransitions) {
52
+ throw new StateException("Too many state transitions were "
53
+ . "encountered ({$trans->_transitionCount}). This likely "
54
+ . "means that a combination of event listeners are in an "
55
+ . "infinite loop.");
56
+ }
57
+
58
+ switch ($trans->state) {
59
+ case 'before': goto before;
60
+ case 'complete': goto complete;
61
+ case 'error': goto error;
62
+ case 'retry': goto retry;
63
+ case 'send': goto send;
64
+ case 'end': goto end;
65
+ default: throw new StateException("Invalid state: {$trans->state}");
66
+ }
67
+
68
+ before: {
69
+ try {
70
+ $trans->request->getEmitter()->emit('before', new BeforeEvent($trans));
71
+ $trans->state = 'send';
72
+ if ((bool) $trans->response) {
73
+ $trans->state = 'complete';
74
+ }
75
+ } catch (\Exception $e) {
76
+ $trans->state = 'error';
77
+ $trans->exception = $e;
78
+ }
79
+ goto transition;
80
+ }
81
+
82
+ complete: {
83
+ try {
84
+ if ($trans->response instanceof FutureInterface) {
85
+ // Futures will have their own end events emitted when
86
+ // dereferenced.
87
+ return;
88
+ }
89
+ $trans->state = 'end';
90
+ $trans->response->setEffectiveUrl($trans->request->getUrl());
91
+ $trans->request->getEmitter()->emit('complete', new CompleteEvent($trans));
92
+ } catch (\Exception $e) {
93
+ $trans->state = 'error';
94
+ $trans->exception = $e;
95
+ }
96
+ goto transition;
97
+ }
98
+
99
+ error: {
100
+ try {
101
+ // Convert non-request exception to a wrapped exception
102
+ $trans->exception = RequestException::wrapException(
103
+ $trans->request, $trans->exception
104
+ );
105
+ $trans->state = 'end';
106
+ $trans->request->getEmitter()->emit('error', new ErrorEvent($trans));
107
+ // An intercepted request (not retried) transitions to complete
108
+ if (!$trans->exception && $trans->state !== 'retry') {
109
+ $trans->state = 'complete';
110
+ }
111
+ } catch (\Exception $e) {
112
+ $trans->state = 'end';
113
+ $trans->exception = $e;
114
+ }
115
+ goto transition;
116
+ }
117
+
118
+ retry: {
119
+ $trans->retries++;
120
+ $trans->response = null;
121
+ $trans->exception = null;
122
+ $trans->state = 'before';
123
+ goto transition;
124
+ }
125
+
126
+ send: {
127
+ $fn = $this->handler;
128
+ $trans->response = FutureResponse::proxy(
129
+ $fn(RingBridge::prepareRingRequest($trans)),
130
+ function ($value) use ($trans) {
131
+ RingBridge::completeRingResponse($trans, $value, $this->mf, $this);
132
+ $this($trans);
133
+ return $trans->response;
134
+ }
135
+ );
136
+ return;
137
+ }
138
+
139
+ end: {
140
+ $trans->request->getEmitter()->emit('end', new EndEvent($trans));
141
+ // Throw exceptions in the terminal event if the exception
142
+ // was not handled by an "end" event listener.
143
+ if ($trans->exception) {
144
+ if (!($trans->exception instanceof RequestException)) {
145
+ $trans->exception = RequestException::wrapException(
146
+ $trans->request, $trans->exception
147
+ );
148
+ }
149
+ throw $trans->exception;
150
+ }
151
+ }
152
+ }
153
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/RingBridge.php ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ use GuzzleHttp\Message\MessageFactoryInterface;
5
+ use GuzzleHttp\Message\RequestInterface;
6
+ use GuzzleHttp\Event\ProgressEvent;
7
+ use GuzzleHttp\Message\Request;
8
+ use GuzzleHttp\Ring\Core;
9
+ use GuzzleHttp\Stream\Stream;
10
+ use GuzzleHttp\Exception\RequestException;
11
+
12
+ /**
13
+ * Provides the bridge between Guzzle requests and responses and Guzzle Ring.
14
+ */
15
+ class RingBridge
16
+ {
17
+ /**
18
+ * Creates a Ring request from a request object.
19
+ *
20
+ * This function does not hook up the "then" and "progress" events that
21
+ * would be required for actually sending a Guzzle request through a
22
+ * RingPHP handler.
23
+ *
24
+ * @param RequestInterface $request Request to convert.
25
+ *
26
+ * @return array Converted Guzzle Ring request.
27
+ */
28
+ public static function createRingRequest(RequestInterface $request)
29
+ {
30
+ $options = $request->getConfig()->toArray();
31
+ $url = $request->getUrl();
32
+ // No need to calculate the query string twice (in URL and query).
33
+ $qs = ($pos = strpos($url, '?')) ? substr($url, $pos + 1) : null;
34
+
35
+ return [
36
+ 'scheme' => $request->getScheme(),
37
+ 'http_method' => $request->getMethod(),
38
+ 'url' => $url,
39
+ 'uri' => $request->getPath(),
40
+ 'headers' => $request->getHeaders(),
41
+ 'body' => $request->getBody(),
42
+ 'version' => $request->getProtocolVersion(),
43
+ 'client' => $options,
44
+ 'query_string' => $qs,
45
+ 'future' => isset($options['future']) ? $options['future'] : false
46
+ ];
47
+ }
48
+
49
+ /**
50
+ * Creates a Ring request from a request object AND prepares the callbacks.
51
+ *
52
+ * @param Transaction $trans Transaction to update.
53
+ *
54
+ * @return array Converted Guzzle Ring request.
55
+ */
56
+ public static function prepareRingRequest(Transaction $trans)
57
+ {
58
+ // Clear out the transaction state when initiating.
59
+ $trans->exception = null;
60
+ $request = self::createRingRequest($trans->request);
61
+
62
+ // Emit progress events if any progress listeners are registered.
63
+ if ($trans->request->getEmitter()->hasListeners('progress')) {
64
+ $emitter = $trans->request->getEmitter();
65
+ $request['client']['progress'] = function ($a, $b, $c, $d) use ($trans, $emitter) {
66
+ $emitter->emit('progress', new ProgressEvent($trans, $a, $b, $c, $d));
67
+ };
68
+ }
69
+
70
+ return $request;
71
+ }
72
+
73
+ /**
74
+ * Handles the process of processing a response received from a ring
75
+ * handler. The created response is added to the transaction, and the
76
+ * transaction stat is set appropriately.
77
+ *
78
+ * @param Transaction $trans Owns request and response.
79
+ * @param array $response Ring response array
80
+ * @param MessageFactoryInterface $messageFactory Creates response objects.
81
+ */
82
+ public static function completeRingResponse(
83
+ Transaction $trans,
84
+ array $response,
85
+ MessageFactoryInterface $messageFactory
86
+ ) {
87
+ $trans->state = 'complete';
88
+ $trans->transferInfo = isset($response['transfer_stats'])
89
+ ? $response['transfer_stats'] : [];
90
+
91
+ if (!empty($response['status'])) {
92
+ $options = [];
93
+ if (isset($response['version'])) {
94
+ $options['protocol_version'] = $response['version'];
95
+ }
96
+ if (isset($response['reason'])) {
97
+ $options['reason_phrase'] = $response['reason'];
98
+ }
99
+ $trans->response = $messageFactory->createResponse(
100
+ $response['status'],
101
+ isset($response['headers']) ? $response['headers'] : [],
102
+ isset($response['body']) ? $response['body'] : null,
103
+ $options
104
+ );
105
+ if (isset($response['effective_url'])) {
106
+ $trans->response->setEffectiveUrl($response['effective_url']);
107
+ }
108
+ } elseif (empty($response['error'])) {
109
+ // When nothing was returned, then we need to add an error.
110
+ $response['error'] = self::getNoRingResponseException($trans->request);
111
+ }
112
+
113
+ if (isset($response['error'])) {
114
+ $trans->state = 'error';
115
+ $trans->exception = $response['error'];
116
+ }
117
+ }
118
+
119
+ /**
120
+ * Creates a Guzzle request object using a ring request array.
121
+ *
122
+ * @param array $request Ring request
123
+ *
124
+ * @return Request
125
+ * @throws \InvalidArgumentException for incomplete requests.
126
+ */
127
+ public static function fromRingRequest(array $request)
128
+ {
129
+ $options = [];
130
+ if (isset($request['version'])) {
131
+ $options['protocol_version'] = $request['version'];
132
+ }
133
+
134
+ if (!isset($request['http_method'])) {
135
+ throw new \InvalidArgumentException('No http_method');
136
+ }
137
+
138
+ return new Request(
139
+ $request['http_method'],
140
+ Core::url($request),
141
+ isset($request['headers']) ? $request['headers'] : [],
142
+ isset($request['body']) ? Stream::factory($request['body']) : null,
143
+ $options
144
+ );
145
+ }
146
+
147
+ /**
148
+ * Get an exception that can be used when a RingPHP handler does not
149
+ * populate a response.
150
+ *
151
+ * @param RequestInterface $request
152
+ *
153
+ * @return RequestException
154
+ */
155
+ public static function getNoRingResponseException(RequestInterface $request)
156
+ {
157
+ $message = <<<EOT
158
+ Sending the request did not return a response, exception, or populate the
159
+ transaction with a response. This is most likely due to an incorrectly
160
+ implemented RingPHP handler. If you are simply trying to mock responses,
161
+ then it is recommended to use the GuzzleHttp\Ring\Client\MockHandler.
162
+ EOT;
163
+ return new RequestException($message, $request);
164
+ }
165
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Subscriber/Cookie.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Subscriber;
3
+
4
+ use GuzzleHttp\Cookie\CookieJar;
5
+ use GuzzleHttp\Cookie\CookieJarInterface;
6
+ use GuzzleHttp\Event\BeforeEvent;
7
+ use GuzzleHttp\Event\CompleteEvent;
8
+ use GuzzleHttp\Event\RequestEvents;
9
+ use GuzzleHttp\Event\SubscriberInterface;
10
+
11
+ /**
12
+ * Adds, extracts, and persists cookies between HTTP requests
13
+ */
14
+ class Cookie implements SubscriberInterface
15
+ {
16
+ /** @var CookieJarInterface */
17
+ private $cookieJar;
18
+
19
+ /**
20
+ * @param CookieJarInterface $cookieJar Cookie jar used to hold cookies
21
+ */
22
+ public function __construct(CookieJarInterface $cookieJar = null)
23
+ {
24
+ $this->cookieJar = $cookieJar ?: new CookieJar();
25
+ }
26
+
27
+ public function getEvents()
28
+ {
29
+ // Fire the cookie plugin complete event before redirecting
30
+ return [
31
+ 'before' => ['onBefore'],
32
+ 'complete' => ['onComplete', RequestEvents::REDIRECT_RESPONSE + 10]
33
+ ];
34
+ }
35
+
36
+ /**
37
+ * Get the cookie cookieJar
38
+ *
39
+ * @return CookieJarInterface
40
+ */
41
+ public function getCookieJar()
42
+ {
43
+ return $this->cookieJar;
44
+ }
45
+
46
+ public function onBefore(BeforeEvent $event)
47
+ {
48
+ $this->cookieJar->addCookieHeader($event->getRequest());
49
+ }
50
+
51
+ public function onComplete(CompleteEvent $event)
52
+ {
53
+ $this->cookieJar->extractCookies(
54
+ $event->getRequest(),
55
+ $event->getResponse()
56
+ );
57
+ }
58
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Subscriber/History.php ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Subscriber;
3
+
4
+ use GuzzleHttp\Event\CompleteEvent;
5
+ use GuzzleHttp\Event\ErrorEvent;
6
+ use GuzzleHttp\Event\RequestEvents;
7
+ use GuzzleHttp\Event\SubscriberInterface;
8
+ use GuzzleHttp\Message\RequestInterface;
9
+ use GuzzleHttp\Message\ResponseInterface;
10
+
11
+ /**
12
+ * Maintains a list of requests and responses sent using a request or client
13
+ */
14
+ class History implements SubscriberInterface, \IteratorAggregate, \Countable
15
+ {
16
+ /** @var int The maximum number of requests to maintain in the history */
17
+ private $limit;
18
+
19
+ /** @var array Requests and responses that have passed through the plugin */
20
+ private $transactions = [];
21
+
22
+ public function __construct($limit = 10)
23
+ {
24
+ $this->limit = $limit;
25
+ }
26
+
27
+ public function getEvents()
28
+ {
29
+ return [
30
+ 'complete' => ['onComplete', RequestEvents::EARLY],
31
+ 'error' => ['onError', RequestEvents::EARLY],
32
+ ];
33
+ }
34
+
35
+ /**
36
+ * Convert to a string that contains all request and response headers
37
+ *
38
+ * @return string
39
+ */
40
+ public function __toString()
41
+ {
42
+ $lines = array();
43
+ foreach ($this->transactions as $entry) {
44
+ $response = isset($entry['response']) ? $entry['response'] : '';
45
+ $lines[] = '> ' . trim($entry['sent_request'])
46
+ . "\n\n< " . trim($response) . "\n";
47
+ }
48
+
49
+ return implode("\n", $lines);
50
+ }
51
+
52
+ public function onComplete(CompleteEvent $event)
53
+ {
54
+ $this->add($event->getRequest(), $event->getResponse());
55
+ }
56
+
57
+ public function onError(ErrorEvent $event)
58
+ {
59
+ // Only track when no response is present, meaning this didn't ever
60
+ // emit a complete event
61
+ if (!$event->getResponse()) {
62
+ $this->add($event->getRequest());
63
+ }
64
+ }
65
+
66
+ /**
67
+ * Returns an Iterator that yields associative array values where each
68
+ * associative array contains the following key value pairs:
69
+ *
70
+ * - request: Representing the actual request that was received.
71
+ * - sent_request: A clone of the request that will not be mutated.
72
+ * - response: The response that was received (if available).
73
+ *
74
+ * @return \Iterator
75
+ */
76
+ public function getIterator()
77
+ {
78
+ return new \ArrayIterator($this->transactions);
79
+ }
80
+
81
+ /**
82
+ * Get all of the requests sent through the plugin.
83
+ *
84
+ * Requests can be modified after they are logged by the history
85
+ * subscriber. By default this method will return the actual request
86
+ * instances that were received. Pass true to this method if you wish to
87
+ * get copies of the requests that represent the request state when it was
88
+ * initially logged by the history subscriber.
89
+ *
90
+ * @param bool $asSent Set to true to get clones of the requests that have
91
+ * not been mutated since the request was received by
92
+ * the history subscriber.
93
+ *
94
+ * @return RequestInterface[]
95
+ */
96
+ public function getRequests($asSent = false)
97
+ {
98
+ return array_map(function ($t) use ($asSent) {
99
+ return $asSent ? $t['sent_request'] : $t['request'];
100
+ }, $this->transactions);
101
+ }
102
+
103
+ /**
104
+ * Get the number of requests in the history
105
+ *
106
+ * @return int
107
+ */
108
+ public function count()
109
+ {
110
+ return count($this->transactions);
111
+ }
112
+
113
+ /**
114
+ * Get the last request sent.
115
+ *
116
+ * Requests can be modified after they are logged by the history
117
+ * subscriber. By default this method will return the actual request
118
+ * instance that was received. Pass true to this method if you wish to get
119
+ * a copy of the request that represents the request state when it was
120
+ * initially logged by the history subscriber.
121
+ *
122
+ * @param bool $asSent Set to true to get a clone of the last request that
123
+ * has not been mutated since the request was received
124
+ * by the history subscriber.
125
+ *
126
+ * @return RequestInterface
127
+ */
128
+ public function getLastRequest($asSent = false)
129
+ {
130
+ return $asSent
131
+ ? end($this->transactions)['sent_request']
132
+ : end($this->transactions)['request'];
133
+ }
134
+
135
+ /**
136
+ * Get the last response in the history
137
+ *
138
+ * @return ResponseInterface|null
139
+ */
140
+ public function getLastResponse()
141
+ {
142
+ return end($this->transactions)['response'];
143
+ }
144
+
145
+ /**
146
+ * Clears the history
147
+ */
148
+ public function clear()
149
+ {
150
+ $this->transactions = array();
151
+ }
152
+
153
+ /**
154
+ * Add a request to the history
155
+ *
156
+ * @param RequestInterface $request Request to add
157
+ * @param ResponseInterface $response Response of the request
158
+ */
159
+ private function add(
160
+ RequestInterface $request,
161
+ ResponseInterface $response = null
162
+ ) {
163
+ $this->transactions[] = [
164
+ 'request' => $request,
165
+ 'sent_request' => clone $request,
166
+ 'response' => $response
167
+ ];
168
+ if (count($this->transactions) > $this->limit) {
169
+ array_shift($this->transactions);
170
+ }
171
+ }
172
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Subscriber/HttpError.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Subscriber;
3
+
4
+ use GuzzleHttp\Event\CompleteEvent;
5
+ use GuzzleHttp\Event\RequestEvents;
6
+ use GuzzleHttp\Event\SubscriberInterface;
7
+ use GuzzleHttp\Exception\RequestException;
8
+
9
+ /**
10
+ * Throws exceptions when a 4xx or 5xx response is received
11
+ */
12
+ class HttpError implements SubscriberInterface
13
+ {
14
+ public function getEvents()
15
+ {
16
+ return ['complete' => ['onComplete', RequestEvents::VERIFY_RESPONSE]];
17
+ }
18
+
19
+ /**
20
+ * Throw a RequestException on an HTTP protocol error
21
+ *
22
+ * @param CompleteEvent $event Emitted event
23
+ * @throws RequestException
24
+ */
25
+ public function onComplete(CompleteEvent $event)
26
+ {
27
+ $code = (string) $event->getResponse()->getStatusCode();
28
+ // Throw an exception for an unsuccessful response
29
+ if ($code[0] >= 4) {
30
+ throw RequestException::create(
31
+ $event->getRequest(),
32
+ $event->getResponse()
33
+ );
34
+ }
35
+ }
36
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Subscriber/Mock.php ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Subscriber;
3
+
4
+ use GuzzleHttp\Event\RequestEvents;
5
+ use GuzzleHttp\Event\SubscriberInterface;
6
+ use GuzzleHttp\Event\BeforeEvent;
7
+ use GuzzleHttp\Exception\RequestException;
8
+ use GuzzleHttp\Message\MessageFactory;
9
+ use GuzzleHttp\Message\ResponseInterface;
10
+ use GuzzleHttp\Stream\StreamInterface;
11
+
12
+ /**
13
+ * Queues mock responses or exceptions and delivers mock responses or
14
+ * exceptions in a fifo order.
15
+ */
16
+ class Mock implements SubscriberInterface, \Countable
17
+ {
18
+ /** @var array Array of mock responses / exceptions */
19
+ private $queue = [];
20
+
21
+ /** @var bool Whether or not to consume an entity body when mocking */
22
+ private $readBodies;
23
+
24
+ /** @var MessageFactory */
25
+ private $factory;
26
+
27
+ /**
28
+ * @param array $items Array of responses or exceptions to queue
29
+ * @param bool $readBodies Set to false to not consume the entity body of
30
+ * a request when a mock is served.
31
+ */
32
+ public function __construct(array $items = [], $readBodies = true)
33
+ {
34
+ $this->factory = new MessageFactory();
35
+ $this->readBodies = $readBodies;
36
+ $this->addMultiple($items);
37
+ }
38
+
39
+ public function getEvents()
40
+ {
41
+ // Fire the event last, after signing
42
+ return ['before' => ['onBefore', RequestEvents::SIGN_REQUEST - 10]];
43
+ }
44
+
45
+ /**
46
+ * @throws \OutOfBoundsException|\Exception
47
+ */
48
+ public function onBefore(BeforeEvent $event)
49
+ {
50
+ if (!$item = array_shift($this->queue)) {
51
+ throw new \OutOfBoundsException('Mock queue is empty');
52
+ } elseif ($item instanceof RequestException) {
53
+ throw $item;
54
+ }
55
+
56
+ // Emulate reading a response body
57
+ $request = $event->getRequest();
58
+ if ($this->readBodies && $request->getBody()) {
59
+ while (!$request->getBody()->eof()) {
60
+ $request->getBody()->read(8096);
61
+ }
62
+ }
63
+
64
+ $saveTo = $event->getRequest()->getConfig()->get('save_to');
65
+
66
+ if (null !== $saveTo) {
67
+ $body = $item->getBody();
68
+
69
+ if (is_resource($saveTo)) {
70
+ fwrite($saveTo, $body);
71
+ } elseif (is_string($saveTo)) {
72
+ file_put_contents($saveTo, $body);
73
+ } elseif ($saveTo instanceof StreamInterface) {
74
+ $saveTo->write($body);
75
+ }
76
+ }
77
+
78
+ $event->intercept($item);
79
+ }
80
+
81
+ public function count()
82
+ {
83
+ return count($this->queue);
84
+ }
85
+
86
+ /**
87
+ * Add a response to the end of the queue
88
+ *
89
+ * @param string|ResponseInterface $response Response or path to response file
90
+ *
91
+ * @return self
92
+ * @throws \InvalidArgumentException if a string or Response is not passed
93
+ */
94
+ public function addResponse($response)
95
+ {
96
+ if (is_string($response)) {
97
+ $response = file_exists($response)
98
+ ? $this->factory->fromMessage(file_get_contents($response))
99
+ : $this->factory->fromMessage($response);
100
+ } elseif (!($response instanceof ResponseInterface)) {
101
+ throw new \InvalidArgumentException('Response must a message '
102
+ . 'string, response object, or path to a file');
103
+ }
104
+
105
+ $this->queue[] = $response;
106
+
107
+ return $this;
108
+ }
109
+
110
+ /**
111
+ * Add an exception to the end of the queue
112
+ *
113
+ * @param RequestException $e Exception to throw when the request is executed
114
+ *
115
+ * @return self
116
+ */
117
+ public function addException(RequestException $e)
118
+ {
119
+ $this->queue[] = $e;
120
+
121
+ return $this;
122
+ }
123
+
124
+ /**
125
+ * Add multiple items to the queue
126
+ *
127
+ * @param array $items Items to add
128
+ */
129
+ public function addMultiple(array $items)
130
+ {
131
+ foreach ($items as $item) {
132
+ if ($item instanceof RequestException) {
133
+ $this->addException($item);
134
+ } else {
135
+ $this->addResponse($item);
136
+ }
137
+ }
138
+ }
139
+
140
+ /**
141
+ * Clear the queue
142
+ */
143
+ public function clearQueue()
144
+ {
145
+ $this->queue = [];
146
+ }
147
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Subscriber/Prepare.php ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Subscriber;
3
+
4
+ use GuzzleHttp\Event\BeforeEvent;
5
+ use GuzzleHttp\Event\RequestEvents;
6
+ use GuzzleHttp\Event\SubscriberInterface;
7
+ use GuzzleHttp\Message\AppliesHeadersInterface;
8
+ use GuzzleHttp\Message\RequestInterface;
9
+ use GuzzleHttp\Mimetypes;
10
+ use GuzzleHttp\Stream\StreamInterface;
11
+
12
+ /**
13
+ * Prepares requests with a body before sending
14
+ *
15
+ * **Request Options**
16
+ *
17
+ * - expect: Set to true to enable the "Expect: 100-Continue" header for a
18
+ * request that send a body. Set to false to disable "Expect: 100-Continue".
19
+ * Set to a number so that the size of the payload must be greater than the
20
+ * number in order to send the Expect header. Setting to a number will send
21
+ * the Expect header for all requests in which the size of the payload cannot
22
+ * be determined or where the body is not rewindable.
23
+ */
24
+ class Prepare implements SubscriberInterface
25
+ {
26
+ public function getEvents()
27
+ {
28
+ return ['before' => ['onBefore', RequestEvents::PREPARE_REQUEST]];
29
+ }
30
+
31
+ public function onBefore(BeforeEvent $event)
32
+ {
33
+ $request = $event->getRequest();
34
+
35
+ // Set the appropriate Content-Type for a request if one is not set and
36
+ // there are form fields
37
+ if (!($body = $request->getBody())) {
38
+ return;
39
+ }
40
+
41
+ $this->addContentLength($request, $body);
42
+
43
+ if ($body instanceof AppliesHeadersInterface) {
44
+ // Synchronize the body with the request headers
45
+ $body->applyRequestHeaders($request);
46
+ } elseif (!$request->hasHeader('Content-Type')) {
47
+ $this->addContentType($request, $body);
48
+ }
49
+
50
+ $this->addExpectHeader($request, $body);
51
+ }
52
+
53
+ private function addContentType(
54
+ RequestInterface $request,
55
+ StreamInterface $body
56
+ ) {
57
+ if (!($uri = $body->getMetadata('uri'))) {
58
+ return;
59
+ }
60
+
61
+ // Guess the content-type based on the stream's "uri" metadata value.
62
+ // The file extension is used to determine the appropriate mime-type.
63
+ if ($contentType = Mimetypes::getInstance()->fromFilename($uri)) {
64
+ $request->setHeader('Content-Type', $contentType);
65
+ }
66
+ }
67
+
68
+ private function addContentLength(
69
+ RequestInterface $request,
70
+ StreamInterface $body
71
+ ) {
72
+ // Set the Content-Length header if it can be determined, and never
73
+ // send a Transfer-Encoding: chunked and Content-Length header in
74
+ // the same request.
75
+ if ($request->hasHeader('Content-Length')) {
76
+ // Remove transfer-encoding if content-length is set.
77
+ $request->removeHeader('Transfer-Encoding');
78
+ return;
79
+ }
80
+
81
+ if ($request->hasHeader('Transfer-Encoding')) {
82
+ return;
83
+ }
84
+
85
+ if (null !== ($size = $body->getSize())) {
86
+ $request->setHeader('Content-Length', $size);
87
+ $request->removeHeader('Transfer-Encoding');
88
+ } elseif ('1.1' == $request->getProtocolVersion()) {
89
+ // Use chunked Transfer-Encoding if there is no determinable
90
+ // content-length header and we're using HTTP/1.1.
91
+ $request->setHeader('Transfer-Encoding', 'chunked');
92
+ $request->removeHeader('Content-Length');
93
+ }
94
+ }
95
+
96
+ private function addExpectHeader(
97
+ RequestInterface $request,
98
+ StreamInterface $body
99
+ ) {
100
+ // Determine if the Expect header should be used
101
+ if ($request->hasHeader('Expect')) {
102
+ return;
103
+ }
104
+
105
+ $expect = $request->getConfig()['expect'];
106
+
107
+ // Return if disabled or if you're not using HTTP/1.1
108
+ if ($expect === false || $request->getProtocolVersion() !== '1.1') {
109
+ return;
110
+ }
111
+
112
+ // The expect header is unconditionally enabled
113
+ if ($expect === true) {
114
+ $request->setHeader('Expect', '100-Continue');
115
+ return;
116
+ }
117
+
118
+ // By default, send the expect header when the payload is > 1mb
119
+ if ($expect === null) {
120
+ $expect = 1048576;
121
+ }
122
+
123
+ // Always add if the body cannot be rewound, the size cannot be
124
+ // determined, or the size is greater than the cutoff threshold
125
+ $size = $body->getSize();
126
+ if ($size === null || $size >= (int) $expect || !$body->isSeekable()) {
127
+ $request->setHeader('Expect', '100-Continue');
128
+ }
129
+ }
130
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Subscriber/Redirect.php ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Subscriber;
3
+
4
+ use GuzzleHttp\Event\CompleteEvent;
5
+ use GuzzleHttp\Event\RequestEvents;
6
+ use GuzzleHttp\Event\SubscriberInterface;
7
+ use GuzzleHttp\Exception\BadResponseException;
8
+ use GuzzleHttp\Exception\CouldNotRewindStreamException;
9
+ use GuzzleHttp\Exception\TooManyRedirectsException;
10
+ use GuzzleHttp\Message\RequestInterface;
11
+ use GuzzleHttp\Message\ResponseInterface;
12
+ use GuzzleHttp\Url;
13
+
14
+ /**
15
+ * Subscriber used to implement HTTP redirects.
16
+ *
17
+ * **Request options**
18
+ *
19
+ * - redirect: Associative array containing the 'max', 'strict', and 'referer'
20
+ * keys.
21
+ *
22
+ * - max: Maximum number of redirects allowed per-request
23
+ * - strict: You can use strict redirects by setting this value to ``true``.
24
+ * Strict redirects adhere to strict RFC compliant redirection (e.g.,
25
+ * redirect POST with POST) vs doing what most clients do (e.g., redirect
26
+ * POST request with a GET request).
27
+ * - referer: Set to true to automatically add the "Referer" header when a
28
+ * redirect request is sent.
29
+ * - protocols: Array of allowed protocols. Defaults to 'http' and 'https'.
30
+ * When a redirect attempts to utilize a protocol that is not white listed,
31
+ * an exception is thrown.
32
+ */
33
+ class Redirect implements SubscriberInterface
34
+ {
35
+ public function getEvents()
36
+ {
37
+ return ['complete' => ['onComplete', RequestEvents::REDIRECT_RESPONSE]];
38
+ }
39
+
40
+ /**
41
+ * Rewind the entity body of the request if needed
42
+ *
43
+ * @param RequestInterface $redirectRequest
44
+ * @throws CouldNotRewindStreamException
45
+ */
46
+ public static function rewindEntityBody(RequestInterface $redirectRequest)
47
+ {
48
+ // Rewind the entity body of the request if needed
49
+ if ($body = $redirectRequest->getBody()) {
50
+ // Only rewind the body if some of it has been read already, and
51
+ // throw an exception if the rewind fails
52
+ if ($body->tell() && !$body->seek(0)) {
53
+ throw new CouldNotRewindStreamException(
54
+ 'Unable to rewind the non-seekable request body after redirecting',
55
+ $redirectRequest
56
+ );
57
+ }
58
+ }
59
+ }
60
+
61
+ /**
62
+ * Called when a request receives a redirect response
63
+ *
64
+ * @param CompleteEvent $event Event emitted
65
+ * @throws TooManyRedirectsException
66
+ */
67
+ public function onComplete(CompleteEvent $event)
68
+ {
69
+ $response = $event->getResponse();
70
+
71
+ if (substr($response->getStatusCode(), 0, 1) != '3'
72
+ || !$response->hasHeader('Location')
73
+ ) {
74
+ return;
75
+ }
76
+
77
+ $request = $event->getRequest();
78
+ $config = $request->getConfig();
79
+
80
+ // Increment the redirect and initialize the redirect state.
81
+ if ($redirectCount = $config['redirect_count']) {
82
+ $config['redirect_count'] = ++$redirectCount;
83
+ } else {
84
+ $config['redirect_scheme'] = $request->getScheme();
85
+ $config['redirect_count'] = $redirectCount = 1;
86
+ }
87
+
88
+ $max = $config->getPath('redirect/max') ?: 5;
89
+
90
+ if ($redirectCount > $max) {
91
+ throw new TooManyRedirectsException(
92
+ "Will not follow more than {$redirectCount} redirects",
93
+ $request
94
+ );
95
+ }
96
+
97
+ $this->modifyRedirectRequest($request, $response);
98
+ $event->retry();
99
+ }
100
+
101
+ private function modifyRedirectRequest(
102
+ RequestInterface $request,
103
+ ResponseInterface $response
104
+ ) {
105
+ $config = $request->getConfig();
106
+ $protocols = $config->getPath('redirect/protocols') ?: ['http', 'https'];
107
+
108
+ // Use a GET request if this is an entity enclosing request and we are
109
+ // not forcing RFC compliance, but rather emulating what all browsers
110
+ // would do.
111
+ $statusCode = $response->getStatusCode();
112
+ if ($statusCode == 303 ||
113
+ ($statusCode <= 302 && $request->getBody() && !$config->getPath('redirect/strict'))
114
+ ) {
115
+ $request->setMethod('GET');
116
+ $request->setBody(null);
117
+ }
118
+
119
+ $previousUrl = $request->getUrl();
120
+ $this->setRedirectUrl($request, $response, $protocols);
121
+ $this->rewindEntityBody($request);
122
+
123
+ // Add the Referer header if it is told to do so and only
124
+ // add the header if we are not redirecting from https to http.
125
+ if ($config->getPath('redirect/referer')
126
+ && ($request->getScheme() == 'https' || $request->getScheme() == $config['redirect_scheme'])
127
+ ) {
128
+ $url = Url::fromString($previousUrl);
129
+ $url->setUsername(null);
130
+ $url->setPassword(null);
131
+ $request->setHeader('Referer', (string) $url);
132
+ } else {
133
+ $request->removeHeader('Referer');
134
+ }
135
+ }
136
+
137
+ /**
138
+ * Set the appropriate URL on the request based on the location header
139
+ *
140
+ * @param RequestInterface $request
141
+ * @param ResponseInterface $response
142
+ * @param array $protocols
143
+ */
144
+ private function setRedirectUrl(
145
+ RequestInterface $request,
146
+ ResponseInterface $response,
147
+ array $protocols
148
+ ) {
149
+ $location = $response->getHeader('Location');
150
+ $location = Url::fromString($location);
151
+
152
+ // Combine location with the original URL if it is not absolute.
153
+ if (!$location->isAbsolute()) {
154
+ $originalUrl = Url::fromString($request->getUrl());
155
+ // Remove query string parameters and just take what is present on
156
+ // the redirect Location header
157
+ $originalUrl->getQuery()->clear();
158
+ $location = $originalUrl->combine($location);
159
+ }
160
+
161
+ // Ensure that the redirect URL is allowed based on the protocols.
162
+ if (!in_array($location->getScheme(), $protocols)) {
163
+ throw new BadResponseException(
164
+ sprintf(
165
+ 'Redirect URL, %s, does not use one of the allowed redirect protocols: %s',
166
+ $location,
167
+ implode(', ', $protocols)
168
+ ),
169
+ $request,
170
+ $response
171
+ );
172
+ }
173
+
174
+ $request->setUrl($location);
175
+ }
176
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/ToArrayInterface.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ /**
5
+ * An object that can be represented as an array
6
+ */
7
+ interface ToArrayInterface
8
+ {
9
+ /**
10
+ * Get the array representation of an object
11
+ *
12
+ * @return array
13
+ */
14
+ public function toArray();
15
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Transaction.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ use GuzzleHttp\Message\RequestInterface;
5
+ use GuzzleHttp\Message\ResponseInterface;
6
+
7
+ /**
8
+ * Represents the relationship between a client, request, and response.
9
+ *
10
+ * You can access the request, response, and client using their corresponding
11
+ * public properties.
12
+ */
13
+ class Transaction
14
+ {
15
+ /**
16
+ * HTTP client used to transfer the request.
17
+ *
18
+ * @var ClientInterface
19
+ */
20
+ public $client;
21
+
22
+ /**
23
+ * The request that is being sent.
24
+ *
25
+ * @var RequestInterface
26
+ */
27
+ public $request;
28
+
29
+ /**
30
+ * The response associated with the transaction. A response will not be
31
+ * present when a networking error occurs or an error occurs before sending
32
+ * the request.
33
+ *
34
+ * @var ResponseInterface|null
35
+ */
36
+ public $response;
37
+
38
+ /**
39
+ * Exception associated with the transaction. If this exception is present
40
+ * when processing synchronous or future commands, then it is thrown. When
41
+ * intercepting a failed transaction, you MUST set this value to null in
42
+ * order to prevent the exception from being thrown.
43
+ *
44
+ * @var \Exception
45
+ */
46
+ public $exception;
47
+
48
+ /**
49
+ * Associative array of handler specific transfer statistics and custom
50
+ * key value pair information. When providing similar information, handlers
51
+ * should follow the same key value pair naming conventions as PHP's
52
+ * curl_getinfo() (http://php.net/manual/en/function.curl-getinfo.php).
53
+ *
54
+ * @var array
55
+ */
56
+ public $transferInfo = [];
57
+
58
+ /**
59
+ * The number of transaction retries.
60
+ *
61
+ * @var int
62
+ */
63
+ public $retries = 0;
64
+
65
+ /**
66
+ * The transaction's current state.
67
+ *
68
+ * @var string
69
+ */
70
+ public $state;
71
+
72
+ /**
73
+ * Whether or not this is a future transaction. This value should not be
74
+ * changed after the future is constructed.
75
+ *
76
+ * @var bool
77
+ */
78
+ public $future;
79
+
80
+ /**
81
+ * The number of state transitions that this transaction has been through.
82
+ *
83
+ * @var int
84
+ * @internal This is for internal use only. If you modify this, then you
85
+ * are asking for trouble.
86
+ */
87
+ public $_transitionCount = 0;
88
+
89
+ /**
90
+ * @param ClientInterface $client Client that is used to send the requests
91
+ * @param RequestInterface $request Request to send
92
+ * @param bool $future Whether or not this is a future request.
93
+ */
94
+ public function __construct(
95
+ ClientInterface $client,
96
+ RequestInterface $request,
97
+ $future = false
98
+ ) {
99
+ $this->client = $client;
100
+ $this->request = $request;
101
+ $this->_future = $future;
102
+ }
103
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/UriTemplate.php ADDED
@@ -0,0 +1,241 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ /**
5
+ * Expands URI templates. Userland implementation of PECL uri_template.
6
+ *
7
+ * @link http://tools.ietf.org/html/rfc6570
8
+ */
9
+ class UriTemplate
10
+ {
11
+ /** @var string URI template */
12
+ private $template;
13
+
14
+ /** @var array Variables to use in the template expansion */
15
+ private $variables;
16
+
17
+ /** @var array Hash for quick operator lookups */
18
+ private static $operatorHash = array(
19
+ '' => array('prefix' => '', 'joiner' => ',', 'query' => false),
20
+ '+' => array('prefix' => '', 'joiner' => ',', 'query' => false),
21
+ '#' => array('prefix' => '#', 'joiner' => ',', 'query' => false),
22
+ '.' => array('prefix' => '.', 'joiner' => '.', 'query' => false),
23
+ '/' => array('prefix' => '/', 'joiner' => '/', 'query' => false),
24
+ ';' => array('prefix' => ';', 'joiner' => ';', 'query' => true),
25
+ '?' => array('prefix' => '?', 'joiner' => '&', 'query' => true),
26
+ '&' => array('prefix' => '&', 'joiner' => '&', 'query' => true)
27
+ );
28
+
29
+ /** @var array Delimiters */
30
+ private static $delims = array(':', '/', '?', '#', '[', ']', '@', '!', '$',
31
+ '&', '\'', '(', ')', '*', '+', ',', ';', '=');
32
+
33
+ /** @var array Percent encoded delimiters */
34
+ private static $delimsPct = array('%3A', '%2F', '%3F', '%23', '%5B', '%5D',
35
+ '%40', '%21', '%24', '%26', '%27', '%28', '%29', '%2A', '%2B', '%2C',
36
+ '%3B', '%3D');
37
+
38
+ public function expand($template, array $variables)
39
+ {
40
+ if (false === strpos($template, '{')) {
41
+ return $template;
42
+ }
43
+
44
+ $this->template = $template;
45
+ $this->variables = $variables;
46
+
47
+ return preg_replace_callback(
48
+ '/\{([^\}]+)\}/',
49
+ [$this, 'expandMatch'],
50
+ $this->template
51
+ );
52
+ }
53
+
54
+ /**
55
+ * Parse an expression into parts
56
+ *
57
+ * @param string $expression Expression to parse
58
+ *
59
+ * @return array Returns an associative array of parts
60
+ */
61
+ private function parseExpression($expression)
62
+ {
63
+ $result = array();
64
+
65
+ if (isset(self::$operatorHash[$expression[0]])) {
66
+ $result['operator'] = $expression[0];
67
+ $expression = substr($expression, 1);
68
+ } else {
69
+ $result['operator'] = '';
70
+ }
71
+
72
+ foreach (explode(',', $expression) as $value) {
73
+ $value = trim($value);
74
+ $varspec = array();
75
+ if ($colonPos = strpos($value, ':')) {
76
+ $varspec['value'] = substr($value, 0, $colonPos);
77
+ $varspec['modifier'] = ':';
78
+ $varspec['position'] = (int) substr($value, $colonPos + 1);
79
+ } elseif (substr($value, -1) == '*') {
80
+ $varspec['modifier'] = '*';
81
+ $varspec['value'] = substr($value, 0, -1);
82
+ } else {
83
+ $varspec['value'] = (string) $value;
84
+ $varspec['modifier'] = '';
85
+ }
86
+ $result['values'][] = $varspec;
87
+ }
88
+
89
+ return $result;
90
+ }
91
+
92
+ /**
93
+ * Process an expansion
94
+ *
95
+ * @param array $matches Matches met in the preg_replace_callback
96
+ *
97
+ * @return string Returns the replacement string
98
+ */
99
+ private function expandMatch(array $matches)
100
+ {
101
+ static $rfc1738to3986 = array('+' => '%20', '%7e' => '~');
102
+
103
+ $replacements = array();
104
+ $parsed = self::parseExpression($matches[1]);
105
+ $prefix = self::$operatorHash[$parsed['operator']]['prefix'];
106
+ $joiner = self::$operatorHash[$parsed['operator']]['joiner'];
107
+ $useQuery = self::$operatorHash[$parsed['operator']]['query'];
108
+
109
+ foreach ($parsed['values'] as $value) {
110
+
111
+ if (!isset($this->variables[$value['value']])) {
112
+ continue;
113
+ }
114
+
115
+ $variable = $this->variables[$value['value']];
116
+ $actuallyUseQuery = $useQuery;
117
+ $expanded = '';
118
+
119
+ if (is_array($variable)) {
120
+
121
+ $isAssoc = $this->isAssoc($variable);
122
+ $kvp = array();
123
+ foreach ($variable as $key => $var) {
124
+
125
+ if ($isAssoc) {
126
+ $key = rawurlencode($key);
127
+ $isNestedArray = is_array($var);
128
+ } else {
129
+ $isNestedArray = false;
130
+ }
131
+
132
+ if (!$isNestedArray) {
133
+ $var = rawurlencode($var);
134
+ if ($parsed['operator'] == '+' ||
135
+ $parsed['operator'] == '#'
136
+ ) {
137
+ $var = $this->decodeReserved($var);
138
+ }
139
+ }
140
+
141
+ if ($value['modifier'] == '*') {
142
+ if ($isAssoc) {
143
+ if ($isNestedArray) {
144
+ // Nested arrays must allow for deeply nested
145
+ // structures.
146
+ $var = strtr(
147
+ http_build_query([$key => $var]),
148
+ $rfc1738to3986
149
+ );
150
+ } else {
151
+ $var = $key . '=' . $var;
152
+ }
153
+ } elseif ($key > 0 && $actuallyUseQuery) {
154
+ $var = $value['value'] . '=' . $var;
155
+ }
156
+ }
157
+
158
+ $kvp[$key] = $var;
159
+ }
160
+
161
+ if (empty($variable)) {
162
+ $actuallyUseQuery = false;
163
+ } elseif ($value['modifier'] == '*') {
164
+ $expanded = implode($joiner, $kvp);
165
+ if ($isAssoc) {
166
+ // Don't prepend the value name when using the explode
167
+ // modifier with an associative array.
168
+ $actuallyUseQuery = false;
169
+ }
170
+ } else {
171
+ if ($isAssoc) {
172
+ // When an associative array is encountered and the
173
+ // explode modifier is not set, then the result must be
174
+ // a comma separated list of keys followed by their
175
+ // respective values.
176
+ foreach ($kvp as $k => &$v) {
177
+ $v = $k . ',' . $v;
178
+ }
179
+ }
180
+ $expanded = implode(',', $kvp);
181
+ }
182
+
183
+ } else {
184
+ if ($value['modifier'] == ':') {
185
+ $variable = substr($variable, 0, $value['position']);
186
+ }
187
+ $expanded = rawurlencode($variable);
188
+ if ($parsed['operator'] == '+' || $parsed['operator'] == '#') {
189
+ $expanded = $this->decodeReserved($expanded);
190
+ }
191
+ }
192
+
193
+ if ($actuallyUseQuery) {
194
+ if (!$expanded && $joiner != '&') {
195
+ $expanded = $value['value'];
196
+ } else {
197
+ $expanded = $value['value'] . '=' . $expanded;
198
+ }
199
+ }
200
+
201
+ $replacements[] = $expanded;
202
+ }
203
+
204
+ $ret = implode($joiner, $replacements);
205
+ if ($ret && $prefix) {
206
+ return $prefix . $ret;
207
+ }
208
+
209
+ return $ret;
210
+ }
211
+
212
+ /**
213
+ * Determines if an array is associative.
214
+ *
215
+ * This makes the assumption that input arrays are sequences or hashes.
216
+ * This assumption is a tradeoff for accuracy in favor of speed, but it
217
+ * should work in almost every case where input is supplied for a URI
218
+ * template.
219
+ *
220
+ * @param array $array Array to check
221
+ *
222
+ * @return bool
223
+ */
224
+ private function isAssoc(array $array)
225
+ {
226
+ return $array && array_keys($array)[0] !== 0;
227
+ }
228
+
229
+ /**
230
+ * Removes percent encoding on reserved characters (used with + and #
231
+ * modifiers).
232
+ *
233
+ * @param string $string String to fix
234
+ *
235
+ * @return string
236
+ */
237
+ private function decodeReserved($string)
238
+ {
239
+ return str_replace(self::$delimsPct, self::$delims, $string);
240
+ }
241
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Url.php ADDED
@@ -0,0 +1,595 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ use GuzzleHttp\Ring\Core;
5
+
6
+ /**
7
+ * Parses and generates URLs based on URL parts
8
+ */
9
+ class Url
10
+ {
11
+ private $scheme;
12
+ private $host;
13
+ private $port;
14
+ private $username;
15
+ private $password;
16
+ private $path = '';
17
+ private $fragment;
18
+ private static $defaultPorts = ['http' => 80, 'https' => 443, 'ftp' => 21];
19
+ private static $pathPattern = '/[^a-zA-Z0-9\-\._~!\$&\'\(\)\*\+,;=%:@\/]+|%(?![A-Fa-f0-9]{2})/';
20
+ private static $queryPattern = '/[^a-zA-Z0-9\-\._~!\$\'\(\)\*\+,;%:@\/\?=&]+|%(?![A-Fa-f0-9]{2})/';
21
+ /** @var Query|string Query part of the URL */
22
+ private $query;
23
+
24
+ /**
25
+ * Factory method to create a new URL from a URL string
26
+ *
27
+ * @param string $url Full URL used to create a Url object
28
+ *
29
+ * @return Url
30
+ * @throws \InvalidArgumentException
31
+ */
32
+ public static function fromString($url)
33
+ {
34
+ static $defaults = ['scheme' => null, 'host' => null,
35
+ 'path' => null, 'port' => null, 'query' => null,
36
+ 'user' => null, 'pass' => null, 'fragment' => null];
37
+
38
+ if (false === ($parts = parse_url($url))) {
39
+ throw new \InvalidArgumentException('Unable to parse malformed '
40
+ . 'url: ' . $url);
41
+ }
42
+
43
+ $parts += $defaults;
44
+
45
+ // Convert the query string into a Query object
46
+ if ($parts['query'] || 0 !== strlen($parts['query'])) {
47
+ $parts['query'] = Query::fromString($parts['query']);
48
+ }
49
+
50
+ return new static($parts['scheme'], $parts['host'], $parts['user'],
51
+ $parts['pass'], $parts['port'], $parts['path'], $parts['query'],
52
+ $parts['fragment']);
53
+ }
54
+
55
+ /**
56
+ * Build a URL from parse_url parts. The generated URL will be a relative
57
+ * URL if a scheme or host are not provided.
58
+ *
59
+ * @param array $parts Array of parse_url parts
60
+ *
61
+ * @return string
62
+ */
63
+ public static function buildUrl(array $parts)
64
+ {
65
+ $url = $scheme = '';
66
+
67
+ if (!empty($parts['scheme'])) {
68
+ $scheme = $parts['scheme'];
69
+ $url .= $scheme . ':';
70
+ }
71
+
72
+ if (!empty($parts['host'])) {
73
+ $url .= '//';
74
+ if (isset($parts['user'])) {
75
+ $url .= $parts['user'];
76
+ if (isset($parts['pass'])) {
77
+ $url .= ':' . $parts['pass'];
78
+ }
79
+ $url .= '@';
80
+ }
81
+
82
+ $url .= $parts['host'];
83
+
84
+ // Only include the port if it is not the default port of the scheme
85
+ if (isset($parts['port']) &&
86
+ (!isset(self::$defaultPorts[$scheme]) ||
87
+ $parts['port'] != self::$defaultPorts[$scheme])
88
+ ) {
89
+ $url .= ':' . $parts['port'];
90
+ }
91
+ }
92
+
93
+ // Add the path component if present
94
+ if (isset($parts['path']) && strlen($parts['path'])) {
95
+ // Always ensure that the path begins with '/' if set and something
96
+ // is before the path
97
+ if (!empty($parts['host']) && $parts['path'][0] != '/') {
98
+ $url .= '/';
99
+ }
100
+ $url .= $parts['path'];
101
+ }
102
+
103
+ // Add the query string if present
104
+ if (isset($parts['query'])) {
105
+ $queryStr = (string) $parts['query'];
106
+ if ($queryStr || $queryStr === '0') {
107
+ $url .= '?' . $queryStr;
108
+ }
109
+ }
110
+
111
+ // Ensure that # is only added to the url if fragment contains anything.
112
+ if (isset($parts['fragment'])) {
113
+ $url .= '#' . $parts['fragment'];
114
+ }
115
+
116
+ return $url;
117
+ }
118
+
119
+ /**
120
+ * Create a new URL from URL parts
121
+ *
122
+ * @param string $scheme Scheme of the URL
123
+ * @param string $host Host of the URL
124
+ * @param string $username Username of the URL
125
+ * @param string $password Password of the URL
126
+ * @param int $port Port of the URL
127
+ * @param string $path Path of the URL
128
+ * @param Query|array|string $query Query string of the URL
129
+ * @param string $fragment Fragment of the URL
130
+ */
131
+ public function __construct(
132
+ $scheme,
133
+ $host,
134
+ $username = null,
135
+ $password = null,
136
+ $port = null,
137
+ $path = null,
138
+ $query = null,
139
+ $fragment = null
140
+ ) {
141
+ $this->scheme = strtolower($scheme);
142
+ $this->host = $host;
143
+ $this->port = $port;
144
+ $this->username = $username;
145
+ $this->password = $password;
146
+ $this->fragment = $fragment;
147
+
148
+ if ($query) {
149
+ $this->setQuery($query);
150
+ }
151
+
152
+ $this->setPath($path);
153
+ }
154
+
155
+ /**
156
+ * Clone the URL
157
+ */
158
+ public function __clone()
159
+ {
160
+ if ($this->query instanceof Query) {
161
+ $this->query = clone $this->query;
162
+ }
163
+ }
164
+
165
+ /**
166
+ * Returns the URL as a URL string
167
+ *
168
+ * @return string
169
+ */
170
+ public function __toString()
171
+ {
172
+ return static::buildUrl($this->getParts());
173
+ }
174
+
175
+ /**
176
+ * Get the parts of the URL as an array
177
+ *
178
+ * @return array
179
+ */
180
+ public function getParts()
181
+ {
182
+ return array(
183
+ 'scheme' => $this->scheme,
184
+ 'user' => $this->username,
185
+ 'pass' => $this->password,
186
+ 'host' => $this->host,
187
+ 'port' => $this->port,
188
+ 'path' => $this->path,
189
+ 'query' => $this->query,
190
+ 'fragment' => $this->fragment,
191
+ );
192
+ }
193
+
194
+ /**
195
+ * Set the host of the request.
196
+ *
197
+ * @param string $host Host to set (e.g. www.yahoo.com, yahoo.com)
198
+ *
199
+ * @return Url
200
+ */
201
+ public function setHost($host)
202
+ {
203
+ if (strpos($host, ':') === false) {
204
+ $this->host = $host;
205
+ } else {
206
+ list($host, $port) = explode(':', $host);
207
+ $this->host = $host;
208
+ $this->setPort($port);
209
+ }
210
+ }
211
+
212
+ /**
213
+ * Get the host part of the URL
214
+ *
215
+ * @return string
216
+ */
217
+ public function getHost()
218
+ {
219
+ return $this->host;
220
+ }
221
+
222
+ /**
223
+ * Set the scheme part of the URL (http, https, ftp, etc.)
224
+ *
225
+ * @param string $scheme Scheme to set
226
+ */
227
+ public function setScheme($scheme)
228
+ {
229
+ // Remove the default port if one is specified
230
+ if ($this->port
231
+ && isset(self::$defaultPorts[$this->scheme])
232
+ && self::$defaultPorts[$this->scheme] == $this->port
233
+ ) {
234
+ $this->port = null;
235
+ }
236
+
237
+ $this->scheme = strtolower($scheme);
238
+ }
239
+
240
+ /**
241
+ * Get the scheme part of the URL
242
+ *
243
+ * @return string
244
+ */
245
+ public function getScheme()
246
+ {
247
+ return $this->scheme;
248
+ }
249
+
250
+ /**
251
+ * Set the port part of the URL
252
+ *
253
+ * @param int $port Port to set
254
+ */
255
+ public function setPort($port)
256
+ {
257
+ $this->port = $port;
258
+ }
259
+
260
+ /**
261
+ * Get the port part of the URl.
262
+ *
263
+ * If no port was set, this method will return the default port for the
264
+ * scheme of the URI.
265
+ *
266
+ * @return int|null
267
+ */
268
+ public function getPort()
269
+ {
270
+ if ($this->port) {
271
+ return $this->port;
272
+ } elseif (isset(self::$defaultPorts[$this->scheme])) {
273
+ return self::$defaultPorts[$this->scheme];
274
+ }
275
+
276
+ return null;
277
+ }
278
+
279
+ /**
280
+ * Set the path part of the URL.
281
+ *
282
+ * The provided URL is URL encoded as necessary.
283
+ *
284
+ * @param string $path Path string to set
285
+ */
286
+ public function setPath($path)
287
+ {
288
+ $this->path = self::encodePath($path);
289
+ }
290
+
291
+ /**
292
+ * Removes dot segments from a URL
293
+ * @link http://tools.ietf.org/html/rfc3986#section-5.2.4
294
+ */
295
+ public function removeDotSegments()
296
+ {
297
+ static $noopPaths = ['' => true, '/' => true, '*' => true];
298
+ static $ignoreSegments = ['.' => true, '..' => true];
299
+
300
+ if (isset($noopPaths[$this->path])) {
301
+ return;
302
+ }
303
+
304
+ $results = [];
305
+ $segments = $this->getPathSegments();
306
+ foreach ($segments as $segment) {
307
+ if ($segment == '..') {
308
+ array_pop($results);
309
+ } elseif (!isset($ignoreSegments[$segment])) {
310
+ $results[] = $segment;
311
+ }
312
+ }
313
+
314
+ $newPath = implode('/', $results);
315
+
316
+ // Add the leading slash if necessary
317
+ if (substr($this->path, 0, 1) === '/' &&
318
+ substr($newPath, 0, 1) !== '/'
319
+ ) {
320
+ $newPath = '/' . $newPath;
321
+ }
322
+
323
+ // Add the trailing slash if necessary
324
+ if ($newPath != '/' && isset($ignoreSegments[end($segments)])) {
325
+ $newPath .= '/';
326
+ }
327
+
328
+ $this->path = $newPath;
329
+ }
330
+
331
+ /**
332
+ * Add a relative path to the currently set path.
333
+ *
334
+ * @param string $relativePath Relative path to add
335
+ */
336
+ public function addPath($relativePath)
337
+ {
338
+ if ($relativePath != '/' &&
339
+ is_string($relativePath) &&
340
+ strlen($relativePath) > 0
341
+ ) {
342
+ // Add a leading slash if needed
343
+ if ($relativePath[0] !== '/' &&
344
+ substr($this->path, -1, 1) !== '/'
345
+ ) {
346
+ $relativePath = '/' . $relativePath;
347
+ }
348
+
349
+ $this->setPath($this->path . $relativePath);
350
+ }
351
+ }
352
+
353
+ /**
354
+ * Get the path part of the URL
355
+ *
356
+ * @return string
357
+ */
358
+ public function getPath()
359
+ {
360
+ return $this->path;
361
+ }
362
+
363
+ /**
364
+ * Get the path segments of the URL as an array
365
+ *
366
+ * @return array
367
+ */
368
+ public function getPathSegments()
369
+ {
370
+ return explode('/', $this->path);
371
+ }
372
+
373
+ /**
374
+ * Set the password part of the URL
375
+ *
376
+ * @param string $password Password to set
377
+ */
378
+ public function setPassword($password)
379
+ {
380
+ $this->password = $password;
381
+ }
382
+
383
+ /**
384
+ * Get the password part of the URL
385
+ *
386
+ * @return null|string
387
+ */
388
+ public function getPassword()
389
+ {
390
+ return $this->password;
391
+ }
392
+
393
+ /**
394
+ * Set the username part of the URL
395
+ *
396
+ * @param string $username Username to set
397
+ */
398
+ public function setUsername($username)
399
+ {
400
+ $this->username = $username;
401
+ }
402
+
403
+ /**
404
+ * Get the username part of the URl
405
+ *
406
+ * @return null|string
407
+ */
408
+ public function getUsername()
409
+ {
410
+ return $this->username;
411
+ }
412
+
413
+ /**
414
+ * Get the query part of the URL as a Query object
415
+ *
416
+ * @return Query
417
+ */
418
+ public function getQuery()
419
+ {
420
+ // Convert the query string to a query object if not already done.
421
+ if (!$this->query instanceof Query) {
422
+ $this->query = $this->query === null
423
+ ? new Query()
424
+ : Query::fromString($this->query);
425
+ }
426
+
427
+ return $this->query;
428
+ }
429
+
430
+ /**
431
+ * Set the query part of the URL.
432
+ *
433
+ * You may provide a query string as a string and pass $rawString as true
434
+ * to provide a query string that is not parsed until a call to getQuery()
435
+ * is made. Setting a raw query string will still encode invalid characters
436
+ * in a query string.
437
+ *
438
+ * @param Query|string|array $query Query string value to set. Can
439
+ * be a string that will be parsed into a Query object, an array
440
+ * of key value pairs, or a Query object.
441
+ * @param bool $rawString Set to true when providing a raw query string.
442
+ *
443
+ * @throws \InvalidArgumentException
444
+ */
445
+ public function setQuery($query, $rawString = false)
446
+ {
447
+ if ($query instanceof Query) {
448
+ $this->query = $query;
449
+ } elseif (is_string($query)) {
450
+ if (!$rawString) {
451
+ $this->query = Query::fromString($query);
452
+ } else {
453
+ // Ensure the query does not have illegal characters.
454
+ $this->query = preg_replace_callback(
455
+ self::$queryPattern,
456
+ [__CLASS__, 'encodeMatch'],
457
+ $query
458
+ );
459
+ }
460
+
461
+ } elseif (is_array($query)) {
462
+ $this->query = new Query($query);
463
+ } else {
464
+ throw new \InvalidArgumentException('Query must be a Query, '
465
+ . 'array, or string. Got ' . Core::describeType($query));
466
+ }
467
+ }
468
+
469
+ /**
470
+ * Get the fragment part of the URL
471
+ *
472
+ * @return null|string
473
+ */
474
+ public function getFragment()
475
+ {
476
+ return $this->fragment;
477
+ }
478
+
479
+ /**
480
+ * Set the fragment part of the URL
481
+ *
482
+ * @param string $fragment Fragment to set
483
+ */
484
+ public function setFragment($fragment)
485
+ {
486
+ $this->fragment = $fragment;
487
+ }
488
+
489
+ /**
490
+ * Check if this is an absolute URL
491
+ *
492
+ * @return bool
493
+ */
494
+ public function isAbsolute()
495
+ {
496
+ return $this->scheme && $this->host;
497
+ }
498
+
499
+ /**
500
+ * Combine the URL with another URL and return a new URL instance.
501
+ *
502
+ * Follows the rules specific in RFC 3986 section 5.4.
503
+ *
504
+ * @param string $url Relative URL to combine with
505
+ *
506
+ * @return Url
507
+ * @throws \InvalidArgumentException
508
+ * @link http://tools.ietf.org/html/rfc3986#section-5.4
509
+ */
510
+ public function combine($url)
511
+ {
512
+ $url = static::fromString($url);
513
+
514
+ // Use the more absolute URL as the base URL
515
+ if (!$this->isAbsolute() && $url->isAbsolute()) {
516
+ $url = $url->combine($this);
517
+ }
518
+
519
+ $parts = $url->getParts();
520
+
521
+ // Passing a URL with a scheme overrides everything
522
+ if ($parts['scheme']) {
523
+ return clone $url;
524
+ }
525
+
526
+ // Setting a host overrides the entire rest of the URL
527
+ if ($parts['host']) {
528
+ return new static(
529
+ $this->scheme,
530
+ $parts['host'],
531
+ $parts['user'],
532
+ $parts['pass'],
533
+ $parts['port'],
534
+ $parts['path'],
535
+ $parts['query'] instanceof Query
536
+ ? clone $parts['query']
537
+ : $parts['query'],
538
+ $parts['fragment']
539
+ );
540
+ }
541
+
542
+ if (!$parts['path'] && $parts['path'] !== '0') {
543
+ // The relative URL has no path, so check if it is just a query
544
+ $path = $this->path ?: '';
545
+ $query = $parts['query'] ?: $this->query;
546
+ } else {
547
+ $query = $parts['query'];
548
+ if ($parts['path'][0] == '/' || !$this->path) {
549
+ // Overwrite the existing path if the rel path starts with "/"
550
+ $path = $parts['path'];
551
+ } else {
552
+ // If the relative URL does not have a path or the base URL
553
+ // path does not end in a "/" then overwrite the existing path
554
+ // up to the last "/"
555
+ $path = substr($this->path, 0, strrpos($this->path, '/') + 1) . $parts['path'];
556
+ }
557
+ }
558
+
559
+ $result = new self(
560
+ $this->scheme,
561
+ $this->host,
562
+ $this->username,
563
+ $this->password,
564
+ $this->port,
565
+ $path,
566
+ $query instanceof Query ? clone $query : $query,
567
+ $parts['fragment']
568
+ );
569
+
570
+ if ($path) {
571
+ $result->removeDotSegments();
572
+ }
573
+
574
+ return $result;
575
+ }
576
+
577
+ /**
578
+ * Encodes the path part of a URL without double-encoding percent-encoded
579
+ * key value pairs.
580
+ *
581
+ * @param string $path Path to encode
582
+ *
583
+ * @return string
584
+ */
585
+ public static function encodePath($path)
586
+ {
587
+ static $cb = [__CLASS__, 'encodeMatch'];
588
+ return preg_replace_callback(self::$pathPattern, $cb, $path);
589
+ }
590
+
591
+ private static function encodeMatch(array $match)
592
+ {
593
+ return rawurlencode($match[0]);
594
+ }
595
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/src/Utils.php ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ use GuzzleHttp\Ring\Client\CurlHandler;
5
+ use GuzzleHttp\Ring\Client\CurlMultiHandler;
6
+ use GuzzleHttp\Ring\Client\StreamHandler;
7
+ use GuzzleHttp\Ring\Client\Middleware;
8
+
9
+ /**
10
+ * Utility methods used throughout Guzzle.
11
+ */
12
+ final class Utils
13
+ {
14
+ /**
15
+ * Gets a value from an array using a path syntax to retrieve nested data.
16
+ *
17
+ * This method does not allow for keys that contain "/". You must traverse
18
+ * the array manually or using something more advanced like JMESPath to
19
+ * work with keys that contain "/".
20
+ *
21
+ * // Get the bar key of a set of nested arrays.
22
+ * // This is equivalent to $collection['foo']['baz']['bar'] but won't
23
+ * // throw warnings for missing keys.
24
+ * GuzzleHttp\get_path($data, 'foo/baz/bar');
25
+ *
26
+ * @param array $data Data to retrieve values from
27
+ * @param string $path Path to traverse and retrieve a value from
28
+ *
29
+ * @return mixed|null
30
+ */
31
+ public static function getPath($data, $path)
32
+ {
33
+ $path = explode('/', $path);
34
+
35
+ while (null !== ($part = array_shift($path))) {
36
+ if (!is_array($data) || !isset($data[$part])) {
37
+ return null;
38
+ }
39
+ $data = $data[$part];
40
+ }
41
+
42
+ return $data;
43
+ }
44
+
45
+ /**
46
+ * Set a value in a nested array key. Keys will be created as needed to set
47
+ * the value.
48
+ *
49
+ * This function does not support keys that contain "/" or "[]" characters
50
+ * because these are special tokens used when traversing the data structure.
51
+ * A value may be prepended to an existing array by using "[]" as the final
52
+ * key of a path.
53
+ *
54
+ * GuzzleHttp\get_path($data, 'foo/baz'); // null
55
+ * GuzzleHttp\set_path($data, 'foo/baz/[]', 'a');
56
+ * GuzzleHttp\set_path($data, 'foo/baz/[]', 'b');
57
+ * GuzzleHttp\get_path($data, 'foo/baz');
58
+ * // Returns ['a', 'b']
59
+ *
60
+ * @param array $data Data to modify by reference
61
+ * @param string $path Path to set
62
+ * @param mixed $value Value to set at the key
63
+ *
64
+ * @throws \RuntimeException when trying to setPath using a nested path
65
+ * that travels through a scalar value.
66
+ */
67
+ public static function setPath(&$data, $path, $value)
68
+ {
69
+ $queue = explode('/', $path);
70
+ // Optimization for simple sets.
71
+ if (count($queue) === 1) {
72
+ $data[$path] = $value;
73
+ return;
74
+ }
75
+
76
+ $current =& $data;
77
+ while (null !== ($key = array_shift($queue))) {
78
+ if (!is_array($current)) {
79
+ throw new \RuntimeException("Trying to setPath {$path}, but "
80
+ . "{$key} is set and is not an array");
81
+ } elseif (!$queue) {
82
+ if ($key == '[]') {
83
+ $current[] = $value;
84
+ } else {
85
+ $current[$key] = $value;
86
+ }
87
+ } elseif (isset($current[$key])) {
88
+ $current =& $current[$key];
89
+ } else {
90
+ $current[$key] = [];
91
+ $current =& $current[$key];
92
+ }
93
+ }
94
+ }
95
+
96
+ /**
97
+ * Expands a URI template
98
+ *
99
+ * @param string $template URI template
100
+ * @param array $variables Template variables
101
+ *
102
+ * @return string
103
+ */
104
+ public static function uriTemplate($template, array $variables)
105
+ {
106
+ if (function_exists('\\uri_template')) {
107
+ return \uri_template($template, $variables);
108
+ }
109
+
110
+ static $uriTemplate;
111
+ if (!$uriTemplate) {
112
+ $uriTemplate = new UriTemplate();
113
+ }
114
+
115
+ return $uriTemplate->expand($template, $variables);
116
+ }
117
+
118
+ /**
119
+ * Wrapper for JSON decode that implements error detection with helpful
120
+ * error messages.
121
+ *
122
+ * @param string $json JSON data to parse
123
+ * @param bool $assoc When true, returned objects will be converted
124
+ * into associative arrays.
125
+ * @param int $depth User specified recursion depth.
126
+ * @param int $options Bitmask of JSON decode options.
127
+ *
128
+ * @return mixed
129
+ * @throws \InvalidArgumentException if the JSON cannot be parsed.
130
+ * @link http://www.php.net/manual/en/function.json-decode.php
131
+ */
132
+ public static function jsonDecode($json, $assoc = false, $depth = 512, $options = 0)
133
+ {
134
+ static $jsonErrors = [
135
+ JSON_ERROR_DEPTH => 'JSON_ERROR_DEPTH - Maximum stack depth exceeded',
136
+ JSON_ERROR_STATE_MISMATCH => 'JSON_ERROR_STATE_MISMATCH - Underflow or the modes mismatch',
137
+ JSON_ERROR_CTRL_CHAR => 'JSON_ERROR_CTRL_CHAR - Unexpected control character found',
138
+ JSON_ERROR_SYNTAX => 'JSON_ERROR_SYNTAX - Syntax error, malformed JSON',
139
+ JSON_ERROR_UTF8 => 'JSON_ERROR_UTF8 - Malformed UTF-8 characters, possibly incorrectly encoded'
140
+ ];
141
+
142
+ $data = \json_decode($json, $assoc, $depth, $options);
143
+
144
+ if (JSON_ERROR_NONE !== json_last_error()) {
145
+ $last = json_last_error();
146
+ throw new \InvalidArgumentException(
147
+ 'Unable to parse JSON data: '
148
+ . (isset($jsonErrors[$last])
149
+ ? $jsonErrors[$last]
150
+ : 'Unknown error')
151
+ );
152
+ }
153
+
154
+ return $data;
155
+ }
156
+
157
+ /**
158
+ * Get the default User-Agent string to use with Guzzle
159
+ *
160
+ * @return string
161
+ */
162
+ public static function getDefaultUserAgent()
163
+ {
164
+ static $defaultAgent = '';
165
+ if (!$defaultAgent) {
166
+ $defaultAgent = 'Guzzle/' . ClientInterface::VERSION;
167
+ if (extension_loaded('curl')) {
168
+ $defaultAgent .= ' curl/' . curl_version()['version'];
169
+ }
170
+ $defaultAgent .= ' PHP/' . PHP_VERSION;
171
+ }
172
+
173
+ return $defaultAgent;
174
+ }
175
+
176
+ /**
177
+ * Create a default handler to use based on the environment
178
+ *
179
+ * @throws \RuntimeException if no viable Handler is available.
180
+ */
181
+ public static function getDefaultHandler()
182
+ {
183
+ $default = $future = null;
184
+
185
+ if (extension_loaded('curl')) {
186
+ $config = [
187
+ 'select_timeout' => getenv('GUZZLE_CURL_SELECT_TIMEOUT') ?: 1
188
+ ];
189
+ if ($maxHandles = getenv('GUZZLE_CURL_MAX_HANDLES')) {
190
+ $config['max_handles'] = $maxHandles;
191
+ }
192
+ if (function_exists('curl_reset')) {
193
+ $default = new CurlHandler();
194
+ $future = new CurlMultiHandler($config);
195
+ } else {
196
+ $default = new CurlMultiHandler($config);
197
+ }
198
+ }
199
+
200
+ if (ini_get('allow_url_fopen')) {
201
+ $default = !$default
202
+ ? new StreamHandler()
203
+ : Middleware::wrapStreaming($default, new StreamHandler());
204
+ } elseif (!$default) {
205
+ throw new \RuntimeException('Guzzle requires cURL, the '
206
+ . 'allow_url_fopen ini setting, or a custom HTTP handler.');
207
+ }
208
+
209
+ return $future ? Middleware::wrapFuture($default, $future) : $default;
210
+ }
211
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/tests/BatchResultsTest.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests;
3
+
4
+ use GuzzleHttp\BatchResults;
5
+
6
+ /**
7
+ * @covers \GuzzleHttp\BatchResults
8
+ */
9
+ class BatchResultsTest extends \PHPUnit_Framework_TestCase
10
+ {
11
+ public function testExposesResults()
12
+ {
13
+ $a = new \stdClass();
14
+ $b = new \stdClass();
15
+ $c = new \stdClass();
16
+ $hash = new \SplObjectStorage();
17
+ $hash[$a] = '1';
18
+ $hash[$b] = '2';
19
+ $hash[$c] = new \Exception('foo');
20
+
21
+ $batch = new BatchResults($hash);
22
+ $this->assertCount(3, $batch);
23
+ $this->assertEquals([$a, $b, $c], $batch->getKeys());
24
+ $this->assertEquals([$hash[$c]], $batch->getFailures());
25
+ $this->assertEquals(['1', '2'], $batch->getSuccessful());
26
+ $this->assertEquals('1', $batch->getResult($a));
27
+ $this->assertNull($batch->getResult(new \stdClass()));
28
+ $this->assertTrue(isset($batch[0]));
29
+ $this->assertFalse(isset($batch[10]));
30
+ $this->assertEquals('1', $batch[0]);
31
+ $this->assertEquals('2', $batch[1]);
32
+ $this->assertNull($batch[100]);
33
+ $this->assertInstanceOf('Exception', $batch[2]);
34
+
35
+ $results = iterator_to_array($batch);
36
+ $this->assertEquals(['1', '2', $hash[$c]], $results);
37
+ }
38
+
39
+ /**
40
+ * @expectedException \RuntimeException
41
+ */
42
+ public function testCannotSetByIndex()
43
+ {
44
+ $hash = new \SplObjectStorage();
45
+ $batch = new BatchResults($hash);
46
+ $batch[10] = 'foo';
47
+ }
48
+
49
+ /**
50
+ * @expectedException \RuntimeException
51
+ */
52
+ public function testCannotUnsetByIndex()
53
+ {
54
+ $hash = new \SplObjectStorage();
55
+ $batch = new BatchResults($hash);
56
+ unset($batch[10]);
57
+ }
58
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/tests/ClientTest.php ADDED
@@ -0,0 +1,647 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests;
3
+
4
+ use GuzzleHttp\Client;
5
+ use GuzzleHttp\Event\BeforeEvent;
6
+ use GuzzleHttp\Event\ErrorEvent;
7
+ use GuzzleHttp\Message\MessageFactory;
8
+ use GuzzleHttp\Message\Response;
9
+ use GuzzleHttp\Exception\RequestException;
10
+ use GuzzleHttp\Query;
11
+ use GuzzleHttp\Ring\Client\MockHandler;
12
+ use GuzzleHttp\Ring\Future\FutureArray;
13
+ use GuzzleHttp\Subscriber\History;
14
+ use GuzzleHttp\Subscriber\Mock;
15
+ use GuzzleHttp\Url;
16
+ use GuzzleHttp\Utils;
17
+ use React\Promise\Deferred;
18
+
19
+ /**
20
+ * @covers GuzzleHttp\Client
21
+ */
22
+ class ClientTest extends \PHPUnit_Framework_TestCase
23
+ {
24
+ /** @callable */
25
+ private $ma;
26
+
27
+ public function setup()
28
+ {
29
+ $this->ma = function () {
30
+ throw new \RuntimeException('Should not have been called.');
31
+ };
32
+ }
33
+
34
+ public function testUsesDefaultDefaultOptions()
35
+ {
36
+ $client = new Client();
37
+ $this->assertTrue($client->getDefaultOption('allow_redirects'));
38
+ $this->assertTrue($client->getDefaultOption('exceptions'));
39
+ $this->assertTrue($client->getDefaultOption('verify'));
40
+ }
41
+
42
+ public function testUsesProvidedDefaultOptions()
43
+ {
44
+ $client = new Client([
45
+ 'defaults' => [
46
+ 'allow_redirects' => false,
47
+ 'query' => ['foo' => 'bar']
48
+ ]
49
+ ]);
50
+ $this->assertFalse($client->getDefaultOption('allow_redirects'));
51
+ $this->assertTrue($client->getDefaultOption('exceptions'));
52
+ $this->assertTrue($client->getDefaultOption('verify'));
53
+ $this->assertEquals(['foo' => 'bar'], $client->getDefaultOption('query'));
54
+ }
55
+
56
+ public function testCanSpecifyBaseUrl()
57
+ {
58
+ $this->assertSame('', (new Client())->getBaseUrl());
59
+ $this->assertEquals('http://foo', (new Client([
60
+ 'base_url' => 'http://foo'
61
+ ]))->getBaseUrl());
62
+ }
63
+
64
+ public function testCanSpecifyBaseUrlUriTemplate()
65
+ {
66
+ $client = new Client(['base_url' => ['http://foo.com/{var}/', ['var' => 'baz']]]);
67
+ $this->assertEquals('http://foo.com/baz/', $client->getBaseUrl());
68
+ }
69
+
70
+ /**
71
+ * @expectedException \InvalidArgumentException
72
+ */
73
+ public function testValidatesUriTemplateValue()
74
+ {
75
+ new Client(['base_url' => ['http://foo.com/']]);
76
+ }
77
+
78
+ /**
79
+ * @expectedException \Exception
80
+ * @expectedExceptionMessage Foo
81
+ */
82
+ public function testCanSpecifyHandler()
83
+ {
84
+ $client = new Client(['handler' => function () {
85
+ throw new \Exception('Foo');
86
+ }]);
87
+ $client->get('http://httpbin.org');
88
+ }
89
+
90
+ /**
91
+ * @expectedException \Exception
92
+ * @expectedExceptionMessage Foo
93
+ */
94
+ public function testCanSpecifyHandlerAsAdapter()
95
+ {
96
+ $client = new Client(['adapter' => function () {
97
+ throw new \Exception('Foo');
98
+ }]);
99
+ $client->get('http://httpbin.org');
100
+ }
101
+
102
+ /**
103
+ * @expectedException \Exception
104
+ * @expectedExceptionMessage Foo
105
+ */
106
+ public function testCanSpecifyMessageFactory()
107
+ {
108
+ $factory = $this->getMockBuilder('GuzzleHttp\Message\MessageFactoryInterface')
109
+ ->setMethods(['createRequest'])
110
+ ->getMockForAbstractClass();
111
+ $factory->expects($this->once())
112
+ ->method('createRequest')
113
+ ->will($this->throwException(new \Exception('Foo')));
114
+ $client = new Client(['message_factory' => $factory]);
115
+ $client->get();
116
+ }
117
+
118
+ public function testCanSpecifyEmitter()
119
+ {
120
+ $emitter = $this->getMockBuilder('GuzzleHttp\Event\EmitterInterface')
121
+ ->setMethods(['listeners'])
122
+ ->getMockForAbstractClass();
123
+ $emitter->expects($this->once())
124
+ ->method('listeners')
125
+ ->will($this->returnValue('foo'));
126
+
127
+ $client = new Client(['emitter' => $emitter]);
128
+ $this->assertEquals('foo', $client->getEmitter()->listeners());
129
+ }
130
+
131
+ public function testAddsDefaultUserAgentHeaderWithDefaultOptions()
132
+ {
133
+ $client = new Client(['defaults' => ['allow_redirects' => false]]);
134
+ $this->assertFalse($client->getDefaultOption('allow_redirects'));
135
+ $this->assertEquals(
136
+ ['User-Agent' => Utils::getDefaultUserAgent()],
137
+ $client->getDefaultOption('headers')
138
+ );
139
+ }
140
+
141
+ public function testAddsDefaultUserAgentHeaderWithoutDefaultOptions()
142
+ {
143
+ $client = new Client();
144
+ $this->assertEquals(
145
+ ['User-Agent' => Utils::getDefaultUserAgent()],
146
+ $client->getDefaultOption('headers')
147
+ );
148
+ }
149
+
150
+ private function getRequestClient()
151
+ {
152
+ $client = $this->getMockBuilder('GuzzleHttp\Client')
153
+ ->setMethods(['send'])
154
+ ->getMock();
155
+ $client->expects($this->once())
156
+ ->method('send')
157
+ ->will($this->returnArgument(0));
158
+
159
+ return $client;
160
+ }
161
+
162
+ public function requestMethodProvider()
163
+ {
164
+ return [
165
+ ['GET', false],
166
+ ['HEAD', false],
167
+ ['DELETE', false],
168
+ ['OPTIONS', false],
169
+ ['POST', 'foo'],
170
+ ['PUT', 'foo'],
171
+ ['PATCH', 'foo']
172
+ ];
173
+ }
174
+
175
+ /**
176
+ * @dataProvider requestMethodProvider
177
+ */
178
+ public function testClientProvidesMethodShortcut($method, $body)
179
+ {
180
+ $client = $this->getRequestClient();
181
+ if ($body) {
182
+ $request = $client->{$method}('http://foo.com', [
183
+ 'headers' => ['X-Baz' => 'Bar'],
184
+ 'body' => $body,
185
+ 'query' => ['a' => 'b']
186
+ ]);
187
+ } else {
188
+ $request = $client->{$method}('http://foo.com', [
189
+ 'headers' => ['X-Baz' => 'Bar'],
190
+ 'query' => ['a' => 'b']
191
+ ]);
192
+ }
193
+ $this->assertEquals($method, $request->getMethod());
194
+ $this->assertEquals('Bar', $request->getHeader('X-Baz'));
195
+ $this->assertEquals('a=b', $request->getQuery());
196
+ if ($body) {
197
+ $this->assertEquals($body, $request->getBody());
198
+ }
199
+ }
200
+
201
+ public function testClientMergesDefaultOptionsWithRequestOptions()
202
+ {
203
+ $f = $this->getMockBuilder('GuzzleHttp\Message\MessageFactoryInterface')
204
+ ->setMethods(array('createRequest'))
205
+ ->getMockForAbstractClass();
206
+
207
+ $o = null;
208
+ // Intercept the creation
209
+ $f->expects($this->once())
210
+ ->method('createRequest')
211
+ ->will($this->returnCallback(
212
+ function ($method, $url, array $options = []) use (&$o) {
213
+ $o = $options;
214
+ return (new MessageFactory())->createRequest($method, $url, $options);
215
+ }
216
+ ));
217
+
218
+ $client = new Client([
219
+ 'message_factory' => $f,
220
+ 'defaults' => [
221
+ 'headers' => ['Foo' => 'Bar'],
222
+ 'query' => ['baz' => 'bam'],
223
+ 'exceptions' => false
224
+ ]
225
+ ]);
226
+
227
+ $request = $client->createRequest('GET', 'http://foo.com?a=b', [
228
+ 'headers' => ['Hi' => 'there', '1' => 'one'],
229
+ 'allow_redirects' => false,
230
+ 'query' => ['t' => 1]
231
+ ]);
232
+
233
+ $this->assertFalse($o['allow_redirects']);
234
+ $this->assertFalse($o['exceptions']);
235
+ $this->assertEquals('Bar', $request->getHeader('Foo'));
236
+ $this->assertEquals('there', $request->getHeader('Hi'));
237
+ $this->assertEquals('one', $request->getHeader('1'));
238
+ $this->assertEquals('a=b&baz=bam&t=1', $request->getQuery());
239
+ }
240
+
241
+ public function testClientMergesDefaultHeadersCaseInsensitively()
242
+ {
243
+ $client = new Client(['defaults' => ['headers' => ['Foo' => 'Bar']]]);
244
+ $request = $client->createRequest('GET', 'http://foo.com?a=b', [
245
+ 'headers' => ['foo' => 'custom', 'user-agent' => 'test']
246
+ ]);
247
+ $this->assertEquals('test', $request->getHeader('User-Agent'));
248
+ $this->assertEquals('custom', $request->getHeader('Foo'));
249
+ }
250
+
251
+ public function testCanOverrideDefaultOptionWithNull()
252
+ {
253
+ $client = new Client(['defaults' => ['proxy' => 'invalid!']]);
254
+ $request = $client->createRequest('GET', 'http://foo.com?a=b', [
255
+ 'proxy' => null
256
+ ]);
257
+ $this->assertFalse($request->getConfig()->hasKey('proxy'));
258
+ }
259
+
260
+ public function testDoesNotOverwriteExistingUA()
261
+ {
262
+ $client = new Client(['defaults' => [
263
+ 'headers' => ['User-Agent' => 'test']
264
+ ]]);
265
+ $this->assertEquals(
266
+ ['User-Agent' => 'test'],
267
+ $client->getDefaultOption('headers')
268
+ );
269
+ }
270
+
271
+ public function testUsesBaseUrlWhenNoUrlIsSet()
272
+ {
273
+ $client = new Client(['base_url' => 'http://www.foo.com/baz?bam=bar']);
274
+ $this->assertEquals(
275
+ 'http://www.foo.com/baz?bam=bar',
276
+ $client->createRequest('GET')->getUrl()
277
+ );
278
+ }
279
+
280
+ public function testUsesBaseUrlCombinedWithProvidedUrl()
281
+ {
282
+ $client = new Client(['base_url' => 'http://www.foo.com/baz?bam=bar']);
283
+ $this->assertEquals(
284
+ 'http://www.foo.com/bar/bam',
285
+ $client->createRequest('GET', 'bar/bam')->getUrl()
286
+ );
287
+ }
288
+
289
+ public function testFalsyPathsAreCombinedWithBaseUrl()
290
+ {
291
+ $client = new Client(['base_url' => 'http://www.foo.com/baz?bam=bar']);
292
+ $this->assertEquals(
293
+ 'http://www.foo.com/0',
294
+ $client->createRequest('GET', '0')->getUrl()
295
+ );
296
+ }
297
+
298
+ public function testUsesBaseUrlCombinedWithProvidedUrlViaUriTemplate()
299
+ {
300
+ $client = new Client(['base_url' => 'http://www.foo.com/baz?bam=bar']);
301
+ $this->assertEquals(
302
+ 'http://www.foo.com/bar/123',
303
+ $client->createRequest('GET', ['bar/{bam}', ['bam' => '123']])->getUrl()
304
+ );
305
+ }
306
+
307
+ public function testSettingAbsoluteUrlOverridesBaseUrl()
308
+ {
309
+ $client = new Client(['base_url' => 'http://www.foo.com/baz?bam=bar']);
310
+ $this->assertEquals(
311
+ 'http://www.foo.com/foo',
312
+ $client->createRequest('GET', '/foo')->getUrl()
313
+ );
314
+ }
315
+
316
+ public function testSettingAbsoluteUriTemplateOverridesBaseUrl()
317
+ {
318
+ $client = new Client(['base_url' => 'http://www.foo.com/baz?bam=bar']);
319
+ $this->assertEquals(
320
+ 'http://goo.com/1',
321
+ $client->createRequest(
322
+ 'GET',
323
+ ['http://goo.com/{bar}', ['bar' => '1']]
324
+ )->getUrl()
325
+ );
326
+ }
327
+
328
+ public function testCanSetRelativeUrlStartingWithHttp()
329
+ {
330
+ $client = new Client(['base_url' => 'http://www.foo.com']);
331
+ $this->assertEquals(
332
+ 'http://www.foo.com/httpfoo',
333
+ $client->createRequest('GET', 'httpfoo')->getUrl()
334
+ );
335
+ }
336
+
337
+ /**
338
+ * Test that base URLs ending with a slash are resolved as per RFC3986.
339
+ *
340
+ * @link http://tools.ietf.org/html/rfc3986#section-5.2.3
341
+ */
342
+ public function testMultipleSubdirectoryWithSlash()
343
+ {
344
+ $client = new Client(['base_url' => 'http://www.foo.com/bar/bam/']);
345
+ $this->assertEquals(
346
+ 'http://www.foo.com/bar/bam/httpfoo',
347
+ $client->createRequest('GET', 'httpfoo')->getUrl()
348
+ );
349
+ }
350
+
351
+ /**
352
+ * Test that base URLs ending without a slash are resolved as per RFC3986.
353
+ *
354
+ * @link http://tools.ietf.org/html/rfc3986#section-5.2.3
355
+ */
356
+ public function testMultipleSubdirectoryNoSlash()
357
+ {
358
+ $client = new Client(['base_url' => 'http://www.foo.com/bar/bam']);
359
+ $this->assertEquals(
360
+ 'http://www.foo.com/bar/httpfoo',
361
+ $client->createRequest('GET', 'httpfoo')->getUrl()
362
+ );
363
+ }
364
+
365
+ public function testClientSendsRequests()
366
+ {
367
+ $mock = new MockHandler(['status' => 200, 'headers' => []]);
368
+ $client = new Client(['handler' => $mock]);
369
+ $response = $client->get('http://test.com');
370
+ $this->assertEquals(200, $response->getStatusCode());
371
+ $this->assertEquals('http://test.com', $response->getEffectiveUrl());
372
+ }
373
+
374
+ public function testSendingRequestCanBeIntercepted()
375
+ {
376
+ $response = new Response(200);
377
+ $client = new Client(['handler' => $this->ma]);
378
+ $client->getEmitter()->on(
379
+ 'before',
380
+ function (BeforeEvent $e) use ($response) {
381
+ $e->intercept($response);
382
+ }
383
+ );
384
+ $this->assertSame($response, $client->get('http://test.com'));
385
+ $this->assertEquals('http://test.com', $response->getEffectiveUrl());
386
+ }
387
+
388
+ /**
389
+ * @expectedException \GuzzleHttp\Exception\RequestException
390
+ * @expectedExceptionMessage Argument 1 passed to GuzzleHttp\Message\FutureResponse::proxy() must implement interface GuzzleHttp\Ring\Future\FutureInterface
391
+ */
392
+ public function testEnsuresResponseIsPresentAfterSending()
393
+ {
394
+ $handler = function () {};
395
+ $client = new Client(['handler' => $handler]);
396
+ $client->get('http://httpbin.org');
397
+ }
398
+
399
+ /**
400
+ * @expectedException \GuzzleHttp\Exception\RequestException
401
+ * @expectedExceptionMessage Waiting did not resolve future
402
+ */
403
+ public function testEnsuresResponseIsPresentAfterDereferencing()
404
+ {
405
+ $deferred = new Deferred();
406
+ $handler = new MockHandler(function () use ($deferred) {
407
+ return new FutureArray(
408
+ $deferred->promise(),
409
+ function () {}
410
+ );
411
+ });
412
+ $client = new Client(['handler' => $handler]);
413
+ $response = $client->get('http://httpbin.org');
414
+ $response->wait();
415
+ }
416
+
417
+ public function testClientHandlesErrorsDuringBeforeSend()
418
+ {
419
+ $client = new Client();
420
+ $client->getEmitter()->on('before', function ($e) {
421
+ throw new \Exception('foo');
422
+ });
423
+ $client->getEmitter()->on('error', function (ErrorEvent $e) {
424
+ $e->intercept(new Response(200));
425
+ });
426
+ $this->assertEquals(
427
+ 200,
428
+ $client->get('http://test.com')->getStatusCode()
429
+ );
430
+ }
431
+
432
+ /**
433
+ * @expectedException \GuzzleHttp\Exception\RequestException
434
+ * @expectedExceptionMessage foo
435
+ */
436
+ public function testClientHandlesErrorsDuringBeforeSendAndThrowsIfUnhandled()
437
+ {
438
+ $client = new Client();
439
+ $client->getEmitter()->on('before', function (BeforeEvent $e) {
440
+ throw new RequestException('foo', $e->getRequest());
441
+ });
442
+ $client->get('http://httpbin.org');
443
+ }
444
+
445
+ /**
446
+ * @expectedException \GuzzleHttp\Exception\RequestException
447
+ * @expectedExceptionMessage foo
448
+ */
449
+ public function testClientWrapsExceptions()
450
+ {
451
+ $client = new Client();
452
+ $client->getEmitter()->on('before', function (BeforeEvent $e) {
453
+ throw new \Exception('foo');
454
+ });
455
+ $client->get('http://httpbin.org');
456
+ }
457
+
458
+ public function testCanInjectResponseForFutureError()
459
+ {
460
+ $calledFuture = false;
461
+ $deferred = new Deferred();
462
+ $future = new FutureArray(
463
+ $deferred->promise(),
464
+ function () use ($deferred, &$calledFuture) {
465
+ $calledFuture = true;
466
+ $deferred->resolve(['error' => new \Exception('Noo!')]);
467
+ }
468
+ );
469
+ $mock = new MockHandler($future);
470
+ $client = new Client(['handler' => $mock]);
471
+ $called = 0;
472
+ $response = $client->get('http://localhost:123/foo', [
473
+ 'future' => true,
474
+ 'events' => [
475
+ 'error' => function (ErrorEvent $e) use (&$called) {
476
+ $called++;
477
+ $e->intercept(new Response(200));
478
+ }
479
+ ]
480
+ ]);
481
+ $this->assertEquals(0, $called);
482
+ $this->assertInstanceOf('GuzzleHttp\Message\FutureResponse', $response);
483
+ $this->assertEquals(200, $response->getStatusCode());
484
+ $this->assertTrue($calledFuture);
485
+ $this->assertEquals(1, $called);
486
+ }
487
+
488
+ public function testCanReturnFutureResults()
489
+ {
490
+ $called = false;
491
+ $deferred = new Deferred();
492
+ $future = new FutureArray(
493
+ $deferred->promise(),
494
+ function () use ($deferred, &$called) {
495
+ $called = true;
496
+ $deferred->resolve(['status' => 201, 'headers' => []]);
497
+ }
498
+ );
499
+ $mock = new MockHandler($future);
500
+ $client = new Client(['handler' => $mock]);
501
+ $response = $client->get('http://localhost:123/foo', ['future' => true]);
502
+ $this->assertFalse($called);
503
+ $this->assertInstanceOf('GuzzleHttp\Message\FutureResponse', $response);
504
+ $this->assertEquals(201, $response->getStatusCode());
505
+ $this->assertTrue($called);
506
+ }
507
+
508
+ public function testThrowsExceptionsWhenDereferenced()
509
+ {
510
+ $calledFuture = false;
511
+ $deferred = new Deferred();
512
+ $future = new FutureArray(
513
+ $deferred->promise(),
514
+ function () use ($deferred, &$calledFuture) {
515
+ $calledFuture = true;
516
+ $deferred->resolve(['error' => new \Exception('Noop!')]);
517
+ }
518
+ );
519
+ $client = new Client(['handler' => new MockHandler($future)]);
520
+ try {
521
+ $res = $client->get('http://localhost:123/foo', ['future' => true]);
522
+ $res->wait();
523
+ $this->fail('Did not throw');
524
+ } catch (RequestException $e) {
525
+ $this->assertEquals(1, $calledFuture);
526
+ }
527
+ }
528
+
529
+ /**
530
+ * @expectedExceptionMessage Noo!
531
+ * @expectedException \GuzzleHttp\Exception\RequestException
532
+ */
533
+ public function testThrowsExceptionsSynchronously()
534
+ {
535
+ $client = new Client([
536
+ 'handler' => new MockHandler(['error' => new \Exception('Noo!')])
537
+ ]);
538
+ $client->get('http://localhost:123/foo');
539
+ }
540
+
541
+ public function testCanSetDefaultValues()
542
+ {
543
+ $client = new Client(['foo' => 'bar']);
544
+ $client->setDefaultOption('headers/foo', 'bar');
545
+ $this->assertNull($client->getDefaultOption('foo'));
546
+ $this->assertEquals('bar', $client->getDefaultOption('headers/foo'));
547
+ }
548
+
549
+ public function testSendsAllInParallel()
550
+ {
551
+ $client = new Client();
552
+ $client->getEmitter()->attach(new Mock([
553
+ new Response(200),
554
+ new Response(201),
555
+ new Response(202),
556
+ ]));
557
+ $history = new History();
558
+ $client->getEmitter()->attach($history);
559
+
560
+ $requests = [
561
+ $client->createRequest('GET', 'http://test.com'),
562
+ $client->createRequest('POST', 'http://test.com'),
563
+ $client->createRequest('PUT', 'http://test.com')
564
+ ];
565
+
566
+ $client->sendAll($requests);
567
+ $requests = array_map(function($r) {
568
+ return $r->getMethod();
569
+ }, $history->getRequests());
570
+ $this->assertContains('GET', $requests);
571
+ $this->assertContains('POST', $requests);
572
+ $this->assertContains('PUT', $requests);
573
+ }
574
+
575
+ public function testCanDisableAuthPerRequest()
576
+ {
577
+ $client = new Client(['defaults' => ['auth' => 'foo']]);
578
+ $request = $client->createRequest('GET', 'http://test.com');
579
+ $this->assertEquals('foo', $request->getConfig()['auth']);
580
+ $request = $client->createRequest('GET', 'http://test.com', ['auth' => null]);
581
+ $this->assertFalse($request->getConfig()->hasKey('auth'));
582
+ }
583
+
584
+ public function testUsesProxyEnvironmentVariables()
585
+ {
586
+ $http = getenv('HTTP_PROXY');
587
+ $https = getenv('HTTPS_PROXY');
588
+
589
+ $client = new Client();
590
+ $this->assertNull($client->getDefaultOption('proxy'));
591
+
592
+ putenv('HTTP_PROXY=127.0.0.1');
593
+ $client = new Client();
594
+ $this->assertEquals(
595
+ ['http' => '127.0.0.1'],
596
+ $client->getDefaultOption('proxy')
597
+ );
598
+
599
+ putenv('HTTPS_PROXY=127.0.0.2');
600
+ $client = new Client();
601
+ $this->assertEquals(
602
+ ['http' => '127.0.0.1', 'https' => '127.0.0.2'],
603
+ $client->getDefaultOption('proxy')
604
+ );
605
+
606
+ putenv("HTTP_PROXY=$http");
607
+ putenv("HTTPS_PROXY=$https");
608
+ }
609
+
610
+ public function testReturnsFutureForErrorWhenRequested()
611
+ {
612
+ $client = new Client(['handler' => new MockHandler(['status' => 404])]);
613
+ $request = $client->createRequest('GET', 'http://localhost:123/foo', [
614
+ 'future' => true
615
+ ]);
616
+ $res = $client->send($request);
617
+ $this->assertInstanceOf('GuzzleHttp\Message\FutureResponse', $res);
618
+ try {
619
+ $res->wait();
620
+ $this->fail('did not throw');
621
+ } catch (RequestException $e) {
622
+ $this->assertContains('404', $e->getMessage());
623
+ }
624
+ }
625
+
626
+ public function testReturnsFutureForResponseWhenRequested()
627
+ {
628
+ $client = new Client(['handler' => new MockHandler(['status' => 200])]);
629
+ $request = $client->createRequest('GET', 'http://localhost:123/foo', [
630
+ 'future' => true
631
+ ]);
632
+ $res = $client->send($request);
633
+ $this->assertInstanceOf('GuzzleHttp\Message\FutureResponse', $res);
634
+ $this->assertEquals(200, $res->getStatusCode());
635
+ }
636
+
637
+ public function testCanUseUrlWithCustomQuery()
638
+ {
639
+ $client = new Client();
640
+ $url = Url::fromString('http://foo.com/bar');
641
+ $query = new Query(['baz' => '123%20']);
642
+ $query->setEncodingType(false);
643
+ $url->setQuery($query);
644
+ $r = $client->createRequest('GET', $url);
645
+ $this->assertEquals('http://foo.com/bar?baz=123%20', $r->getUrl());
646
+ }
647
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/tests/CollectionTest.php ADDED
@@ -0,0 +1,416 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace GuzzleHttp\Tests;
4
+
5
+ use GuzzleHttp\Collection;
6
+
7
+ class CollectionTest extends \PHPUnit_Framework_TestCase
8
+ {
9
+ /** @var Collection */
10
+ protected $coll;
11
+
12
+ protected function setUp()
13
+ {
14
+ $this->coll = new Collection();
15
+ }
16
+
17
+ public function testConstructorCanBeCalledWithNoParams()
18
+ {
19
+ $this->coll = new Collection();
20
+ $p = $this->coll->toArray();
21
+ $this->assertEmpty($p, '-> Collection must be empty when no data is passed');
22
+ }
23
+
24
+ public function testConstructorCanBeCalledWithParams()
25
+ {
26
+ $testData = array(
27
+ 'test' => 'value',
28
+ 'test_2' => 'value2'
29
+ );
30
+ $this->coll = new Collection($testData);
31
+ $this->assertEquals($this->coll->toArray(), $testData);
32
+ $this->assertEquals($this->coll->toArray(), $this->coll->toArray());
33
+ }
34
+
35
+ public function testImplementsIteratorAggregate()
36
+ {
37
+ $this->coll->set('key', 'value');
38
+ $this->assertInstanceOf('ArrayIterator', $this->coll->getIterator());
39
+ $this->assertEquals(1, count($this->coll));
40
+ $total = 0;
41
+ foreach ($this->coll as $key => $value) {
42
+ $this->assertEquals('key', $key);
43
+ $this->assertEquals('value', $value);
44
+ $total++;
45
+ }
46
+ $this->assertEquals(1, $total);
47
+ }
48
+
49
+ public function testCanAddValuesToExistingKeysByUsingArray()
50
+ {
51
+ $this->coll->add('test', 'value1');
52
+ $this->assertEquals($this->coll->toArray(), array('test' => 'value1'));
53
+ $this->coll->add('test', 'value2');
54
+ $this->assertEquals($this->coll->toArray(), array('test' => array('value1', 'value2')));
55
+ $this->coll->add('test', 'value3');
56
+ $this->assertEquals($this->coll->toArray(), array('test' => array('value1', 'value2', 'value3')));
57
+ }
58
+
59
+ public function testHandlesMergingInDisparateDataSources()
60
+ {
61
+ $params = array(
62
+ 'test' => 'value1',
63
+ 'test2' => 'value2',
64
+ 'test3' => array('value3', 'value4')
65
+ );
66
+ $this->coll->merge($params);
67
+ $this->assertEquals($this->coll->toArray(), $params);
68
+ $this->coll->merge(new Collection(['test4' => 'hi']));
69
+ $this->assertEquals(
70
+ $this->coll->toArray(),
71
+ $params + ['test4' => 'hi']
72
+ );
73
+ }
74
+
75
+ public function testCanClearAllDataOrSpecificKeys()
76
+ {
77
+ $this->coll->merge(array(
78
+ 'test' => 'value1',
79
+ 'test2' => 'value2'
80
+ ));
81
+
82
+ // Clear a specific parameter by name
83
+ $this->coll->remove('test');
84
+
85
+ $this->assertEquals($this->coll->toArray(), array(
86
+ 'test2' => 'value2'
87
+ ));
88
+
89
+ // Clear all parameters
90
+ $this->coll->clear();
91
+
92
+ $this->assertEquals($this->coll->toArray(), array());
93
+ }
94
+
95
+ public function testProvidesKeys()
96
+ {
97
+ $this->assertEquals(array(), $this->coll->getKeys());
98
+ $this->coll->merge(array(
99
+ 'test1' => 'value1',
100
+ 'test2' => 'value2'
101
+ ));
102
+ $this->assertEquals(array('test1', 'test2'), $this->coll->getKeys());
103
+ // Returns the cached array previously returned
104
+ $this->assertEquals(array('test1', 'test2'), $this->coll->getKeys());
105
+ $this->coll->remove('test1');
106
+ $this->assertEquals(array('test2'), $this->coll->getKeys());
107
+ $this->coll->add('test3', 'value3');
108
+ $this->assertEquals(array('test2', 'test3'), $this->coll->getKeys());
109
+ }
110
+
111
+ public function testChecksIfHasKey()
112
+ {
113
+ $this->assertFalse($this->coll->hasKey('test'));
114
+ $this->coll->add('test', 'value');
115
+ $this->assertEquals(true, $this->coll->hasKey('test'));
116
+ $this->coll->add('test2', 'value2');
117
+ $this->assertEquals(true, $this->coll->hasKey('test'));
118
+ $this->assertEquals(true, $this->coll->hasKey('test2'));
119
+ $this->assertFalse($this->coll->hasKey('testing'));
120
+ $this->assertEquals(false, $this->coll->hasKey('AB-C', 'junk'));
121
+ }
122
+
123
+ public function testChecksIfHasValue()
124
+ {
125
+ $this->assertFalse($this->coll->hasValue('value'));
126
+ $this->coll->add('test', 'value');
127
+ $this->assertEquals('test', $this->coll->hasValue('value'));
128
+ $this->coll->add('test2', 'value2');
129
+ $this->assertEquals('test', $this->coll->hasValue('value'));
130
+ $this->assertEquals('test2', $this->coll->hasValue('value2'));
131
+ $this->assertFalse($this->coll->hasValue('val'));
132
+ }
133
+
134
+ public function testImplementsCount()
135
+ {
136
+ $data = new Collection();
137
+ $this->assertEquals(0, $data->count());
138
+ $data->add('key', 'value');
139
+ $this->assertEquals(1, count($data));
140
+ $data->add('key', 'value2');
141
+ $this->assertEquals(1, count($data));
142
+ $data->add('key_2', 'value3');
143
+ $this->assertEquals(2, count($data));
144
+ }
145
+
146
+ public function testAddParamsByMerging()
147
+ {
148
+ $params = array(
149
+ 'test' => 'value1',
150
+ 'test2' => 'value2',
151
+ 'test3' => array('value3', 'value4')
152
+ );
153
+
154
+ // Add some parameters
155
+ $this->coll->merge($params);
156
+
157
+ // Add more parameters by merging them in
158
+ $this->coll->merge(array(
159
+ 'test' => 'another',
160
+ 'different_key' => 'new value'
161
+ ));
162
+
163
+ $this->assertEquals(array(
164
+ 'test' => array('value1', 'another'),
165
+ 'test2' => 'value2',
166
+ 'test3' => array('value3', 'value4'),
167
+ 'different_key' => 'new value'
168
+ ), $this->coll->toArray());
169
+ }
170
+
171
+ public function testAllowsFunctionalFilter()
172
+ {
173
+ $this->coll->merge(array(
174
+ 'fruit' => 'apple',
175
+ 'number' => 'ten',
176
+ 'prepositions' => array('about', 'above', 'across', 'after'),
177
+ 'same_number' => 'ten'
178
+ ));
179
+
180
+ $filtered = $this->coll->filter(function ($key, $value) {
181
+ return $value == 'ten';
182
+ });
183
+
184
+ $this->assertNotSame($filtered, $this->coll);
185
+
186
+ $this->assertEquals(array(
187
+ 'number' => 'ten',
188
+ 'same_number' => 'ten'
189
+ ), $filtered->toArray());
190
+ }
191
+
192
+ public function testAllowsFunctionalMapping()
193
+ {
194
+ $this->coll->merge(array(
195
+ 'number_1' => 1,
196
+ 'number_2' => 2,
197
+ 'number_3' => 3
198
+ ));
199
+
200
+ $mapped = $this->coll->map(function ($key, $value) {
201
+ return $value * $value;
202
+ });
203
+
204
+ $this->assertNotSame($mapped, $this->coll);
205
+
206
+ $this->assertEquals(array(
207
+ 'number_1' => 1,
208
+ 'number_2' => 4,
209
+ 'number_3' => 9
210
+ ), $mapped->toArray());
211
+ }
212
+
213
+ public function testImplementsArrayAccess()
214
+ {
215
+ $this->coll->merge(array(
216
+ 'k1' => 'v1',
217
+ 'k2' => 'v2'
218
+ ));
219
+
220
+ $this->assertTrue($this->coll->offsetExists('k1'));
221
+ $this->assertFalse($this->coll->offsetExists('Krull'));
222
+
223
+ $this->coll->offsetSet('k3', 'v3');
224
+ $this->assertEquals('v3', $this->coll->offsetGet('k3'));
225
+ $this->assertEquals('v3', $this->coll->get('k3'));
226
+
227
+ $this->coll->offsetUnset('k1');
228
+ $this->assertFalse($this->coll->offsetExists('k1'));
229
+ }
230
+
231
+ public function testCanReplaceAllData()
232
+ {
233
+ $this->coll->replace(array('a' => '123'));
234
+ $this->assertEquals(array('a' => '123'), $this->coll->toArray());
235
+ }
236
+
237
+ public function testPreparesFromConfig()
238
+ {
239
+ $c = Collection::fromConfig(array(
240
+ 'a' => '123',
241
+ 'base_url' => 'http://www.test.com/'
242
+ ), array(
243
+ 'a' => 'xyz',
244
+ 'b' => 'lol'
245
+ ), array('a'));
246
+
247
+ $this->assertInstanceOf('GuzzleHttp\Collection', $c);
248
+ $this->assertEquals(array(
249
+ 'a' => '123',
250
+ 'b' => 'lol',
251
+ 'base_url' => 'http://www.test.com/'
252
+ ), $c->toArray());
253
+
254
+ try {
255
+ Collection::fromConfig(array(), array(), array('a'));
256
+ $this->fail('Exception not throw when missing config');
257
+ } catch (\InvalidArgumentException $e) {
258
+ }
259
+ }
260
+
261
+ function falseyDataProvider()
262
+ {
263
+ return array(
264
+ array(false, false),
265
+ array(null, null),
266
+ array('', ''),
267
+ array(array(), array()),
268
+ array(0, 0),
269
+ );
270
+ }
271
+
272
+ /**
273
+ * @dataProvider falseyDataProvider
274
+ */
275
+ public function testReturnsCorrectData($a, $b)
276
+ {
277
+ $c = new Collection(array('value' => $a));
278
+ $this->assertSame($b, $c->get('value'));
279
+ }
280
+
281
+ public function testRetrievesNestedKeysUsingPath()
282
+ {
283
+ $data = array(
284
+ 'foo' => 'bar',
285
+ 'baz' => array(
286
+ 'mesa' => array(
287
+ 'jar' => 'jar'
288
+ )
289
+ )
290
+ );
291
+ $collection = new Collection($data);
292
+ $this->assertEquals('bar', $collection->getPath('foo'));
293
+ $this->assertEquals('jar', $collection->getPath('baz/mesa/jar'));
294
+ $this->assertNull($collection->getPath('wewewf'));
295
+ $this->assertNull($collection->getPath('baz/mesa/jar/jar'));
296
+ }
297
+
298
+ public function testFalseyKeysStillDescend()
299
+ {
300
+ $collection = new Collection(array(
301
+ '0' => array(
302
+ 'a' => 'jar'
303
+ ),
304
+ 1 => 'other'
305
+ ));
306
+ $this->assertEquals('jar', $collection->getPath('0/a'));
307
+ $this->assertEquals('other', $collection->getPath('1'));
308
+ }
309
+
310
+ public function getPathProvider()
311
+ {
312
+ $data = array(
313
+ 'foo' => 'bar',
314
+ 'baz' => array(
315
+ 'mesa' => array(
316
+ 'jar' => 'jar',
317
+ 'array' => array('a', 'b', 'c')
318
+ ),
319
+ 'bar' => array(
320
+ 'baz' => 'bam',
321
+ 'array' => array('d', 'e', 'f')
322
+ )
323
+ ),
324
+ 'bam' => array(
325
+ array('foo' => 1),
326
+ array('foo' => 2),
327
+ array('array' => array('h', 'i'))
328
+ )
329
+ );
330
+ $c = new Collection($data);
331
+
332
+ return array(
333
+ // Simple path selectors
334
+ array($c, 'foo', 'bar'),
335
+ array($c, 'baz', $data['baz']),
336
+ array($c, 'bam', $data['bam']),
337
+ array($c, 'baz/mesa', $data['baz']['mesa']),
338
+ array($c, 'baz/mesa/jar', 'jar'),
339
+ // Does not barf on missing keys
340
+ array($c, 'fefwfw', null),
341
+ array($c, 'baz/mesa/array', $data['baz']['mesa']['array'])
342
+ );
343
+ }
344
+
345
+ /**
346
+ * @dataProvider getPathProvider
347
+ */
348
+ public function testGetPath(Collection $c, $path, $expected, $separator = '/')
349
+ {
350
+ $this->assertEquals($expected, $c->getPath($path, $separator));
351
+ }
352
+
353
+ public function testOverridesSettings()
354
+ {
355
+ $c = new Collection(array('foo' => 1, 'baz' => 2, 'bar' => 3));
356
+ $c->overwriteWith(array('foo' => 10, 'bar' => 300));
357
+ $this->assertEquals(array('foo' => 10, 'baz' => 2, 'bar' => 300), $c->toArray());
358
+ }
359
+
360
+ public function testOverwriteWithCollection()
361
+ {
362
+ $c = new Collection(array('foo' => 1, 'baz' => 2, 'bar' => 3));
363
+ $b = new Collection(array('foo' => 10, 'bar' => 300));
364
+ $c->overwriteWith($b);
365
+ $this->assertEquals(array('foo' => 10, 'baz' => 2, 'bar' => 300), $c->toArray());
366
+ }
367
+
368
+ public function testOverwriteWithTraversable()
369
+ {
370
+ $c = new Collection(array('foo' => 1, 'baz' => 2, 'bar' => 3));
371
+ $b = new Collection(array('foo' => 10, 'bar' => 300));
372
+ $c->overwriteWith($b->getIterator());
373
+ $this->assertEquals(array('foo' => 10, 'baz' => 2, 'bar' => 300), $c->toArray());
374
+ }
375
+
376
+ public function testCanSetNestedPathValueThatDoesNotExist()
377
+ {
378
+ $c = new Collection(array());
379
+ $c->setPath('foo/bar/baz/123', 'hi');
380
+ $this->assertEquals('hi', $c['foo']['bar']['baz']['123']);
381
+ }
382
+
383
+ public function testCanSetNestedPathValueThatExists()
384
+ {
385
+ $c = new Collection(array('foo' => array('bar' => 'test')));
386
+ $c->setPath('foo/bar', 'hi');
387
+ $this->assertEquals('hi', $c['foo']['bar']);
388
+ }
389
+
390
+ /**
391
+ * @expectedException \RuntimeException
392
+ */
393
+ public function testVerifiesNestedPathIsValidAtExactLevel()
394
+ {
395
+ $c = new Collection(array('foo' => 'bar'));
396
+ $c->setPath('foo/bar', 'hi');
397
+ $this->assertEquals('hi', $c['foo']['bar']);
398
+ }
399
+
400
+ /**
401
+ * @expectedException \RuntimeException
402
+ */
403
+ public function testVerifiesThatNestedPathIsValidAtAnyLevel()
404
+ {
405
+ $c = new Collection(array('foo' => 'bar'));
406
+ $c->setPath('foo/bar/baz', 'test');
407
+ }
408
+
409
+ public function testCanAppendToNestedPathValues()
410
+ {
411
+ $c = new Collection();
412
+ $c->setPath('foo/bar/[]', 'a');
413
+ $c->setPath('foo/bar/[]', 'b');
414
+ $this->assertEquals(['a', 'b'], $c['foo']['bar']);
415
+ }
416
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/tests/Cookie/CookieJarTest.php ADDED
@@ -0,0 +1,339 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace GuzzleHttp\Tests\CookieJar;
4
+
5
+ use GuzzleHttp\Cookie\CookieJar;
6
+ use GuzzleHttp\Cookie\SetCookie;
7
+ use GuzzleHttp\Message\Request;
8
+ use GuzzleHttp\Message\Response;
9
+
10
+ /**
11
+ * @covers GuzzleHttp\Cookie\CookieJar
12
+ */
13
+ class CookieJarTest extends \PHPUnit_Framework_TestCase
14
+ {
15
+ /** @var CookieJar */
16
+ private $jar;
17
+
18
+ public function setUp()
19
+ {
20
+ $this->jar = new CookieJar();
21
+ }
22
+
23
+ protected function getTestCookies()
24
+ {
25
+ return [
26
+ new SetCookie(['Name' => 'foo', 'Value' => 'bar', 'Domain' => 'foo.com', 'Path' => '/', 'Discard' => true]),
27
+ new SetCookie(['Name' => 'test', 'Value' => '123', 'Domain' => 'baz.com', 'Path' => '/foo', 'Expires' => 2]),
28
+ new SetCookie(['Name' => 'you', 'Value' => '123', 'Domain' => 'bar.com', 'Path' => '/boo', 'Expires' => time() + 1000])
29
+ ];
30
+ }
31
+
32
+ public function testQuotesBadCookieValues()
33
+ {
34
+ $this->assertEquals('foo', CookieJar::getCookieValue('foo'));
35
+ $this->assertEquals('"foo,bar"', CookieJar::getCookieValue('foo,bar'));
36
+ }
37
+
38
+ public function testCreatesFromArray()
39
+ {
40
+ $jar = CookieJar::fromArray([
41
+ 'foo' => 'bar',
42
+ 'baz' => 'bam'
43
+ ], 'example.com');
44
+ $this->assertCount(2, $jar);
45
+ }
46
+
47
+ /**
48
+ * Provides test data for cookie cookieJar retrieval
49
+ */
50
+ public function getCookiesDataProvider()
51
+ {
52
+ return [
53
+ [['foo', 'baz', 'test', 'muppet', 'googoo'], '', '', '', false],
54
+ [['foo', 'baz', 'muppet', 'googoo'], '', '', '', true],
55
+ [['googoo'], 'www.example.com', '', '', false],
56
+ [['muppet', 'googoo'], 'test.y.example.com', '', '', false],
57
+ [['foo', 'baz'], 'example.com', '', '', false],
58
+ [['muppet'], 'x.y.example.com', '/acme/', '', false],
59
+ [['muppet'], 'x.y.example.com', '/acme/test/', '', false],
60
+ [['googoo'], 'x.y.example.com', '/test/acme/test/', '', false],
61
+ [['foo', 'baz'], 'example.com', '', '', false],
62
+ [['baz'], 'example.com', '', 'baz', false],
63
+ ];
64
+ }
65
+
66
+ public function testStoresAndRetrievesCookies()
67
+ {
68
+ $cookies = $this->getTestCookies();
69
+ foreach ($cookies as $cookie) {
70
+ $this->assertTrue($this->jar->setCookie($cookie));
71
+ }
72
+
73
+ $this->assertEquals(3, count($this->jar));
74
+ $this->assertEquals(3, count($this->jar->getIterator()));
75
+ $this->assertEquals($cookies, $this->jar->getIterator()->getArrayCopy());
76
+ }
77
+
78
+ public function testRemovesTemporaryCookies()
79
+ {
80
+ $cookies = $this->getTestCookies();
81
+ foreach ($this->getTestCookies() as $cookie) {
82
+ $this->jar->setCookie($cookie);
83
+ }
84
+ $this->jar->clearSessionCookies();
85
+ $this->assertEquals(
86
+ [$cookies[1], $cookies[2]],
87
+ $this->jar->getIterator()->getArrayCopy()
88
+ );
89
+ }
90
+
91
+ public function testRemovesSelectively()
92
+ {
93
+ foreach ($this->getTestCookies() as $cookie) {
94
+ $this->jar->setCookie($cookie);
95
+ }
96
+
97
+ // Remove foo.com cookies
98
+ $this->jar->clear('foo.com');
99
+ $this->assertEquals(2, count($this->jar));
100
+ // Try again, removing no further cookies
101
+ $this->jar->clear('foo.com');
102
+ $this->assertEquals(2, count($this->jar));
103
+
104
+ // Remove bar.com cookies with path of /boo
105
+ $this->jar->clear('bar.com', '/boo');
106
+ $this->assertEquals(1, count($this->jar));
107
+
108
+ // Remove cookie by name
109
+ $this->jar->clear(null, null, 'test');
110
+ $this->assertEquals(0, count($this->jar));
111
+ }
112
+
113
+ public function testDoesNotAddIncompleteCookies()
114
+ {
115
+ $this->assertEquals(false, $this->jar->setCookie(new SetCookie()));
116
+ $this->assertFalse($this->jar->setCookie(new SetCookie(array(
117
+ 'Name' => 'foo'
118
+ ))));
119
+ $this->assertFalse($this->jar->setCookie(new SetCookie(array(
120
+ 'Name' => false
121
+ ))));
122
+ $this->assertFalse($this->jar->setCookie(new SetCookie(array(
123
+ 'Name' => true
124
+ ))));
125
+ $this->assertFalse($this->jar->setCookie(new SetCookie(array(
126
+ 'Name' => 'foo',
127
+ 'Domain' => 'foo.com'
128
+ ))));
129
+ }
130
+
131
+ public function testDoesAddValidCookies()
132
+ {
133
+ $this->assertTrue($this->jar->setCookie(new SetCookie(array(
134
+ 'Name' => 'foo',
135
+ 'Domain' => 'foo.com',
136
+ 'Value' => 0
137
+ ))));
138
+ $this->assertTrue($this->jar->setCookie(new SetCookie(array(
139
+ 'Name' => 'foo',
140
+ 'Domain' => 'foo.com',
141
+ 'Value' => 0.0
142
+ ))));
143
+ $this->assertTrue($this->jar->setCookie(new SetCookie(array(
144
+ 'Name' => 'foo',
145
+ 'Domain' => 'foo.com',
146
+ 'Value' => '0'
147
+ ))));
148
+ }
149
+
150
+ public function testOverwritesCookiesThatAreOlderOrDiscardable()
151
+ {
152
+ $t = time() + 1000;
153
+ $data = array(
154
+ 'Name' => 'foo',
155
+ 'Value' => 'bar',
156
+ 'Domain' => '.example.com',
157
+ 'Path' => '/',
158
+ 'Max-Age' => '86400',
159
+ 'Secure' => true,
160
+ 'Discard' => true,
161
+ 'Expires' => $t
162
+ );
163
+
164
+ // Make sure that the discard cookie is overridden with the non-discard
165
+ $this->assertTrue($this->jar->setCookie(new SetCookie($data)));
166
+ $this->assertEquals(1, count($this->jar));
167
+
168
+ $data['Discard'] = false;
169
+ $this->assertTrue($this->jar->setCookie(new SetCookie($data)));
170
+ $this->assertEquals(1, count($this->jar));
171
+
172
+ $c = $this->jar->getIterator()->getArrayCopy();
173
+ $this->assertEquals(false, $c[0]->getDiscard());
174
+
175
+ // Make sure it doesn't duplicate the cookie
176
+ $this->jar->setCookie(new SetCookie($data));
177
+ $this->assertEquals(1, count($this->jar));
178
+
179
+ // Make sure the more future-ful expiration date supersede the other
180
+ $data['Expires'] = time() + 2000;
181
+ $this->assertTrue($this->jar->setCookie(new SetCookie($data)));
182
+ $this->assertEquals(1, count($this->jar));
183
+ $c = $this->jar->getIterator()->getArrayCopy();
184
+ $this->assertNotEquals($t, $c[0]->getExpires());
185
+ }
186
+
187
+ public function testOverwritesCookiesThatHaveChanged()
188
+ {
189
+ $t = time() + 1000;
190
+ $data = array(
191
+ 'Name' => 'foo',
192
+ 'Value' => 'bar',
193
+ 'Domain' => '.example.com',
194
+ 'Path' => '/',
195
+ 'Max-Age' => '86400',
196
+ 'Secure' => true,
197
+ 'Discard' => true,
198
+ 'Expires' => $t
199
+ );
200
+
201
+ // Make sure that the discard cookie is overridden with the non-discard
202
+ $this->assertTrue($this->jar->setCookie(new SetCookie($data)));
203
+
204
+ $data['Value'] = 'boo';
205
+ $this->assertTrue($this->jar->setCookie(new SetCookie($data)));
206
+ $this->assertEquals(1, count($this->jar));
207
+
208
+ // Changing the value plus a parameter also must overwrite the existing one
209
+ $data['Value'] = 'zoo';
210
+ $data['Secure'] = false;
211
+ $this->assertTrue($this->jar->setCookie(new SetCookie($data)));
212
+ $this->assertEquals(1, count($this->jar));
213
+
214
+ $c = $this->jar->getIterator()->getArrayCopy();
215
+ $this->assertEquals('zoo', $c[0]->getValue());
216
+ }
217
+
218
+ public function testAddsCookiesFromResponseWithRequest()
219
+ {
220
+ $response = new Response(200, array(
221
+ 'Set-Cookie' => "fpc=d=.Hm.yh4.1XmJWjJfs4orLQzKzPImxklQoxXSHOZATHUSEFciRueW_7704iYUtsXNEXq0M92Px2glMdWypmJ7HIQl6XIUvrZimWjQ3vIdeuRbI.FNQMAfcxu_XN1zSx7l.AcPdKL6guHc2V7hIQFhnjRW0rxm2oHY1P4bGQxFNz7f.tHm12ZD3DbdMDiDy7TBXsuP4DM-&v=2; expires=Fri, 02-Mar-2019 02:17:40 GMT;"
222
+ ));
223
+ $request = new Request('GET', 'http://www.example.com');
224
+ $this->jar->extractCookies($request, $response);
225
+ $this->assertEquals(1, count($this->jar));
226
+ }
227
+
228
+ public function getMatchingCookiesDataProvider()
229
+ {
230
+ return array(
231
+ array('https://example.com', 'foo=bar; baz=foobar'),
232
+ array('http://example.com', ''),
233
+ array('https://example.com:8912', 'foo=bar; baz=foobar'),
234
+ array('https://foo.example.com', 'foo=bar; baz=foobar'),
235
+ array('http://foo.example.com/test/acme/', 'googoo=gaga')
236
+ );
237
+ }
238
+
239
+ /**
240
+ * @dataProvider getMatchingCookiesDataProvider
241
+ */
242
+ public function testReturnsCookiesMatchingRequests($url, $cookies)
243
+ {
244
+ $bag = [
245
+ new SetCookie([
246
+ 'Name' => 'foo',
247
+ 'Value' => 'bar',
248
+ 'Domain' => 'example.com',
249
+ 'Path' => '/',
250
+ 'Max-Age' => '86400',
251
+ 'Secure' => true
252
+ ]),
253
+ new SetCookie([
254
+ 'Name' => 'baz',
255
+ 'Value' => 'foobar',
256
+ 'Domain' => 'example.com',
257
+ 'Path' => '/',
258
+ 'Max-Age' => '86400',
259
+ 'Secure' => true
260
+ ]),
261
+ new SetCookie([
262
+ 'Name' => 'test',
263
+ 'Value' => '123',
264
+ 'Domain' => 'www.foobar.com',
265
+ 'Path' => '/path/',
266
+ 'Discard' => true
267
+ ]),
268
+ new SetCookie([
269
+ 'Name' => 'muppet',
270
+ 'Value' => 'cookie_monster',
271
+ 'Domain' => '.y.example.com',
272
+ 'Path' => '/acme/',
273
+ 'Expires' => time() + 86400
274
+ ]),
275
+ new SetCookie([
276
+ 'Name' => 'googoo',
277
+ 'Value' => 'gaga',
278
+ 'Domain' => '.example.com',
279
+ 'Path' => '/test/acme/',
280
+ 'Max-Age' => 1500
281
+ ])
282
+ ];
283
+
284
+ foreach ($bag as $cookie) {
285
+ $this->jar->setCookie($cookie);
286
+ }
287
+
288
+ $request = new Request('GET', $url);
289
+ $this->jar->addCookieHeader($request);
290
+ $this->assertEquals($cookies, $request->getHeader('Cookie'));
291
+ }
292
+
293
+ /**
294
+ * @expectedException \RuntimeException
295
+ * @expectedExceptionMessage Invalid cookie: Cookie name must not cannot invalid characters:
296
+ */
297
+ public function testThrowsExceptionWithStrictMode()
298
+ {
299
+ $a = new CookieJar(true);
300
+ $a->setCookie(new SetCookie(['Name' => "abc\n", 'Value' => 'foo', 'Domain' => 'bar']));
301
+ }
302
+
303
+ public function testDeletesCookiesByName()
304
+ {
305
+ $cookies = $this->getTestCookies();
306
+ $cookies[] = new SetCookie([
307
+ 'Name' => 'other',
308
+ 'Value' => '123',
309
+ 'Domain' => 'bar.com',
310
+ 'Path' => '/boo',
311
+ 'Expires' => time() + 1000
312
+ ]);
313
+ $jar = new CookieJar();
314
+ foreach ($cookies as $cookie) {
315
+ $jar->setCookie($cookie);
316
+ }
317
+ $this->assertCount(4, $jar);
318
+ $jar->clear('bar.com', '/boo', 'other');
319
+ $this->assertCount(3, $jar);
320
+ $names = array_map(function (SetCookie $c) {
321
+ return $c->getName();
322
+ }, $jar->getIterator()->getArrayCopy());
323
+ $this->assertEquals(['foo', 'test', 'you'], $names);
324
+ }
325
+
326
+ public function testCanConvertToAndLoadFromArray()
327
+ {
328
+ $jar = new CookieJar(true);
329
+ foreach ($this->getTestCookies() as $cookie) {
330
+ $jar->setCookie($cookie);
331
+ }
332
+ $this->assertCount(3, $jar);
333
+ $arr = $jar->toArray();
334
+ $this->assertCount(3, $arr);
335
+ $newCookieJar = new CookieJar(false, $arr);
336
+ $this->assertCount(3, $newCookieJar);
337
+ $this->assertSame($jar->toArray(), $newCookieJar->toArray());
338
+ }
339
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/tests/Cookie/FileCookieJarTest.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\CookieJar;
3
+
4
+ use GuzzleHttp\Cookie\FileCookieJar;
5
+ use GuzzleHttp\Cookie\SetCookie;
6
+
7
+ /**
8
+ * @covers GuzzleHttp\Cookie\FileCookieJar
9
+ */
10
+ class FileCookieJarTest extends \PHPUnit_Framework_TestCase
11
+ {
12
+ private $file;
13
+
14
+ public function setUp()
15
+ {
16
+ $this->file = tempnam('/tmp', 'file-cookies');
17
+ }
18
+
19
+ /**
20
+ * @expectedException \RuntimeException
21
+ */
22
+ public function testValidatesCookieFile()
23
+ {
24
+ file_put_contents($this->file, 'true');
25
+ new FileCookieJar($this->file);
26
+ }
27
+
28
+ public function testLoadsFromFileFile()
29
+ {
30
+ $jar = new FileCookieJar($this->file);
31
+ $this->assertEquals([], $jar->getIterator()->getArrayCopy());
32
+ unlink($this->file);
33
+ }
34
+
35
+ public function testPersistsToFileFile()
36
+ {
37
+ $jar = new FileCookieJar($this->file);
38
+ $jar->setCookie(new SetCookie([
39
+ 'Name' => 'foo',
40
+ 'Value' => 'bar',
41
+ 'Domain' => 'foo.com',
42
+ 'Expires' => time() + 1000
43
+ ]));
44
+ $jar->setCookie(new SetCookie([
45
+ 'Name' => 'baz',
46
+ 'Value' => 'bar',
47
+ 'Domain' => 'foo.com',
48
+ 'Expires' => time() + 1000
49
+ ]));
50
+ $jar->setCookie(new SetCookie([
51
+ 'Name' => 'boo',
52
+ 'Value' => 'bar',
53
+ 'Domain' => 'foo.com',
54
+ ]));
55
+
56
+ $this->assertEquals(3, count($jar));
57
+ unset($jar);
58
+
59
+ // Make sure it wrote to the file
60
+ $contents = file_get_contents($this->file);
61
+ $this->assertNotEmpty($contents);
62
+
63
+ // Load the cookieJar from the file
64
+ $jar = new FileCookieJar($this->file);
65
+
66
+ // Weeds out temporary and session cookies
67
+ $this->assertEquals(2, count($jar));
68
+ unset($jar);
69
+ unlink($this->file);
70
+ }
71
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/tests/Cookie/SessionCookieJarTest.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace GuzzleHttp\Tests\CookieJar;
4
+
5
+ use GuzzleHttp\Cookie\SessionCookieJar;
6
+ use GuzzleHttp\Cookie\SetCookie;
7
+
8
+ /**
9
+ * @covers GuzzleHttp\Cookie\SessionCookieJar
10
+ */
11
+ class SessionCookieJarTest extends \PHPUnit_Framework_TestCase
12
+ {
13
+ private $sessionVar;
14
+
15
+ public function setUp()
16
+ {
17
+ $this->sessionVar = 'sessionKey';
18
+
19
+ if (!isset($_SESSION)) {
20
+ $_SESSION = array();
21
+ }
22
+ }
23
+
24
+ /**
25
+ * @expectedException \RuntimeException
26
+ */
27
+ public function testValidatesCookieSession()
28
+ {
29
+ $_SESSION[$this->sessionVar] = 'true';
30
+ new SessionCookieJar($this->sessionVar);
31
+ }
32
+
33
+ public function testLoadsFromSession()
34
+ {
35
+ $jar = new SessionCookieJar($this->sessionVar);
36
+ $this->assertEquals([], $jar->getIterator()->getArrayCopy());
37
+ unset($_SESSION[$this->sessionVar]);
38
+ }
39
+
40
+ public function testPersistsToSession()
41
+ {
42
+ $jar = new SessionCookieJar($this->sessionVar);
43
+ $jar->setCookie(new SetCookie([
44
+ 'Name' => 'foo',
45
+ 'Value' => 'bar',
46
+ 'Domain' => 'foo.com',
47
+ 'Expires' => time() + 1000
48
+ ]));
49
+ $jar->setCookie(new SetCookie([
50
+ 'Name' => 'baz',
51
+ 'Value' => 'bar',
52
+ 'Domain' => 'foo.com',
53
+ 'Expires' => time() + 1000
54
+ ]));
55
+ $jar->setCookie(new SetCookie([
56
+ 'Name' => 'boo',
57
+ 'Value' => 'bar',
58
+ 'Domain' => 'foo.com',
59
+ ]));
60
+
61
+ $this->assertEquals(3, count($jar));
62
+ unset($jar);
63
+
64
+ // Make sure it wrote to the sessionVar in $_SESSION
65
+ $contents = $_SESSION[$this->sessionVar];
66
+ $this->assertNotEmpty($contents);
67
+
68
+ // Load the cookieJar from the file
69
+ $jar = new SessionCookieJar($this->sessionVar);
70
+
71
+ // Weeds out temporary and session cookies
72
+ $this->assertEquals(2, count($jar));
73
+ unset($jar);
74
+ unset($_SESSION[$this->sessionVar]);
75
+ }
76
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/tests/Cookie/SetCookieTest.php ADDED
@@ -0,0 +1,364 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace GuzzleHttp\Tests\CookieJar;
4
+
5
+ use GuzzleHttp\Cookie\SetCookie;
6
+
7
+ /**
8
+ * @covers GuzzleHttp\Cookie\SetCookie
9
+ */
10
+ class SetCookieTest extends \PHPUnit_Framework_TestCase
11
+ {
12
+ public function testInitializesDefaultValues()
13
+ {
14
+ $cookie = new SetCookie();
15
+ $this->assertEquals('/', $cookie->getPath());
16
+ }
17
+
18
+ public function testConvertsDateTimeMaxAgeToUnixTimestamp()
19
+ {
20
+ $cookie = new SetCookie(['Expires' => 'November 20, 1984']);
21
+ $this->assertInternalType('integer', $cookie->getExpires());
22
+ }
23
+
24
+ public function testAddsExpiresBasedOnMaxAge()
25
+ {
26
+ $t = time();
27
+ $cookie = new SetCookie(['Max-Age' => 100]);
28
+ $this->assertEquals($t + 100, $cookie->getExpires());
29
+ }
30
+
31
+ public function testHoldsValues()
32
+ {
33
+ $t = time();
34
+ $data = array(
35
+ 'Name' => 'foo',
36
+ 'Value' => 'baz',
37
+ 'Path' => '/bar',
38
+ 'Domain' => 'baz.com',
39
+ 'Expires' => $t,
40
+ 'Max-Age' => 100,
41
+ 'Secure' => true,
42
+ 'Discard' => true,
43
+ 'HttpOnly' => true,
44
+ 'foo' => 'baz',
45
+ 'bar' => 'bam'
46
+ );
47
+
48
+ $cookie = new SetCookie($data);
49
+ $this->assertEquals($data, $cookie->toArray());
50
+
51
+ $this->assertEquals('foo', $cookie->getName());
52
+ $this->assertEquals('baz', $cookie->getValue());
53
+ $this->assertEquals('baz.com', $cookie->getDomain());
54
+ $this->assertEquals('/bar', $cookie->getPath());
55
+ $this->assertEquals($t, $cookie->getExpires());
56
+ $this->assertEquals(100, $cookie->getMaxAge());
57
+ $this->assertTrue($cookie->getSecure());
58
+ $this->assertTrue($cookie->getDiscard());
59
+ $this->assertTrue($cookie->getHttpOnly());
60
+ $this->assertEquals('baz', $cookie->toArray()['foo']);
61
+ $this->assertEquals('bam', $cookie->toArray()['bar']);
62
+
63
+ $cookie->setName('a');
64
+ $cookie->setValue('b');
65
+ $cookie->setPath('c');
66
+ $cookie->setDomain('bar.com');
67
+ $cookie->setExpires(10);
68
+ $cookie->setMaxAge(200);
69
+ $cookie->setSecure(false);
70
+ $cookie->setHttpOnly(false);
71
+ $cookie->setDiscard(false);
72
+
73
+ $this->assertEquals('a', $cookie->getName());
74
+ $this->assertEquals('b', $cookie->getValue());
75
+ $this->assertEquals('c', $cookie->getPath());
76
+ $this->assertEquals('bar.com', $cookie->getDomain());
77
+ $this->assertEquals(10, $cookie->getExpires());
78
+ $this->assertEquals(200, $cookie->getMaxAge());
79
+ $this->assertFalse($cookie->getSecure());
80
+ $this->assertFalse($cookie->getDiscard());
81
+ $this->assertFalse($cookie->getHttpOnly());
82
+ }
83
+
84
+ public function testDeterminesIfExpired()
85
+ {
86
+ $c = new SetCookie();
87
+ $c->setExpires(10);
88
+ $this->assertTrue($c->isExpired());
89
+ $c->setExpires(time() + 10000);
90
+ $this->assertFalse($c->isExpired());
91
+ }
92
+
93
+ public function testMatchesDomain()
94
+ {
95
+ $cookie = new SetCookie();
96
+ $this->assertTrue($cookie->matchesDomain('baz.com'));
97
+
98
+ $cookie->setDomain('baz.com');
99
+ $this->assertTrue($cookie->matchesDomain('baz.com'));
100
+ $this->assertFalse($cookie->matchesDomain('bar.com'));
101
+
102
+ $cookie->setDomain('.baz.com');
103
+ $this->assertTrue($cookie->matchesDomain('.baz.com'));
104
+ $this->assertTrue($cookie->matchesDomain('foo.baz.com'));
105
+ $this->assertFalse($cookie->matchesDomain('baz.bar.com'));
106
+ $this->assertTrue($cookie->matchesDomain('baz.com'));
107
+
108
+ $cookie->setDomain('.127.0.0.1');
109
+ $this->assertTrue($cookie->matchesDomain('127.0.0.1'));
110
+
111
+ $cookie->setDomain('127.0.0.1');
112
+ $this->assertTrue($cookie->matchesDomain('127.0.0.1'));
113
+
114
+ $cookie->setDomain('.com.');
115
+ $this->assertFalse($cookie->matchesDomain('baz.com'));
116
+
117
+ $cookie->setDomain('.local');
118
+ $this->assertTrue($cookie->matchesDomain('example.local'));
119
+ }
120
+
121
+ public function testMatchesPath()
122
+ {
123
+ $cookie = new SetCookie();
124
+ $this->assertTrue($cookie->matchesPath('/foo'));
125
+
126
+ $cookie->setPath('/foo');
127
+ $this->assertTrue($cookie->matchesPath('/foo'));
128
+ $this->assertTrue($cookie->matchesPath('/foo/bar'));
129
+ $this->assertFalse($cookie->matchesPath('/bar'));
130
+ }
131
+
132
+ public function cookieValidateProvider()
133
+ {
134
+ return array(
135
+ array('foo', 'baz', 'bar', true),
136
+ array('0', '0', '0', true),
137
+ array('', 'baz', 'bar', 'The cookie name must not be empty'),
138
+ array('foo', '', 'bar', 'The cookie value must not be empty'),
139
+ array('foo', 'baz', '', 'The cookie domain must not be empty'),
140
+ array("foo\r", 'baz', '0', 'Cookie name must not cannot invalid characters: =,; \t\r\n\013\014'),
141
+ );
142
+ }
143
+
144
+ /**
145
+ * @dataProvider cookieValidateProvider
146
+ */
147
+ public function testValidatesCookies($name, $value, $domain, $result)
148
+ {
149
+ $cookie = new SetCookie(array(
150
+ 'Name' => $name,
151
+ 'Value' => $value,
152
+ 'Domain' => $domain
153
+ ));
154
+ $this->assertSame($result, $cookie->validate());
155
+ }
156
+
157
+ public function testDoesNotMatchIp()
158
+ {
159
+ $cookie = new SetCookie(['Domain' => '192.168.16.']);
160
+ $this->assertFalse($cookie->matchesDomain('192.168.16.121'));
161
+ }
162
+
163
+ public function testConvertsToString()
164
+ {
165
+ $t = 1382916008;
166
+ $cookie = new SetCookie([
167
+ 'Name' => 'test',
168
+ 'Value' => '123',
169
+ 'Domain' => 'foo.com',
170
+ 'Expires' => $t,
171
+ 'Path' => '/abc',
172
+ 'HttpOnly' => true,
173
+ 'Secure' => true
174
+ ]);
175
+ $this->assertEquals(
176
+ 'test=123; Domain=foo.com; Path=/abc; Expires=Sun, 27 Oct 2013 23:20:08 GMT; Secure; HttpOnly',
177
+ (string) $cookie
178
+ );
179
+ }
180
+
181
+ /**
182
+ * Provides the parsed information from a cookie
183
+ *
184
+ * @return array
185
+ */
186
+ public function cookieParserDataProvider()
187
+ {
188
+ return array(
189
+ array(
190
+ 'ASIHTTPRequestTestCookie=This+is+the+value; expires=Sat, 26-Jul-2008 17:00:42 GMT; path=/tests; domain=allseeing-i.com; PHPSESSID=6c951590e7a9359bcedde25cda73e43c; path=/";',
191
+ array(
192
+ 'Domain' => 'allseeing-i.com',
193
+ 'Path' => '/',
194
+ 'PHPSESSID' => '6c951590e7a9359bcedde25cda73e43c',
195
+ 'Max-Age' => NULL,
196
+ 'Expires' => 'Sat, 26-Jul-2008 17:00:42 GMT',
197
+ 'Secure' => NULL,
198
+ 'Discard' => NULL,
199
+ 'Name' => 'ASIHTTPRequestTestCookie',
200
+ 'Value' => 'This+is+the+value',
201
+ 'HttpOnly' => false
202
+ )
203
+ ),
204
+ array('', []),
205
+ array('foo', []),
206
+ // Test setting a blank value for a cookie
207
+ array(array(
208
+ 'foo=', 'foo =', 'foo =;', 'foo= ;', 'foo =', 'foo= '),
209
+ array(
210
+ 'Name' => 'foo',
211
+ 'Value' => '',
212
+ 'Discard' => null,
213
+ 'Domain' => null,
214
+ 'Expires' => null,
215
+ 'Max-Age' => null,
216
+ 'Path' => '/',
217
+ 'Secure' => null,
218
+ 'HttpOnly' => false
219
+ )
220
+ ),
221
+ // Test setting a value and removing quotes
222
+ array(array(
223
+ 'foo=1', 'foo =1', 'foo =1;', 'foo=1 ;', 'foo =1', 'foo= 1', 'foo = 1 ;', 'foo="1"', 'foo="1";', 'foo= "1";'),
224
+ array(
225
+ 'Name' => 'foo',
226
+ 'Value' => '1',
227
+ 'Discard' => null,
228
+ 'Domain' => null,
229
+ 'Expires' => null,
230
+ 'Max-Age' => null,
231
+ 'Path' => '/',
232
+ 'Secure' => null,
233
+ 'HttpOnly' => false
234
+ )
235
+ ),
236
+ // Some of the following tests are based on http://framework.zend.com/svn/framework/standard/trunk/tests/Zend/Http/CookieTest.php
237
+ array(
238
+ 'justacookie=foo; domain=example.com',
239
+ array(
240
+ 'Name' => 'justacookie',
241
+ 'Value' => 'foo',
242
+ 'Domain' => 'example.com',
243
+ 'Discard' => null,
244
+ 'Expires' => null,
245
+ 'Max-Age' => null,
246
+ 'Path' => '/',
247
+ 'Secure' => null,
248
+ 'HttpOnly' => false
249
+ )
250
+ ),
251
+ array(
252
+ 'expires=tomorrow; secure; path=/Space Out/; expires=Tue, 21-Nov-2006 08:33:44 GMT; domain=.example.com',
253
+ array(
254
+ 'Name' => 'expires',
255
+ 'Value' => 'tomorrow',
256
+ 'Domain' => '.example.com',
257
+ 'Path' => '/Space Out/',
258
+ 'Expires' => 'Tue, 21-Nov-2006 08:33:44 GMT',
259
+ 'Discard' => null,
260
+ 'Secure' => true,
261
+ 'Max-Age' => null,
262
+ 'HttpOnly' => false
263
+ )
264
+ ),
265
+ array(
266
+ 'domain=unittests; expires=Tue, 21-Nov-2006 08:33:44 GMT; domain=example.com; path=/some value/',
267
+ array(
268
+ 'Name' => 'domain',
269
+ 'Value' => 'unittests',
270
+ 'Domain' => 'example.com',
271
+ 'Path' => '/some value/',
272
+ 'Expires' => 'Tue, 21-Nov-2006 08:33:44 GMT',
273
+ 'Secure' => false,
274
+ 'Discard' => null,
275
+ 'Max-Age' => null,
276
+ 'HttpOnly' => false
277
+ )
278
+ ),
279
+ array(
280
+ 'path=indexAction; path=/; domain=.foo.com; expires=Tue, 21-Nov-2006 08:33:44 GMT',
281
+ array(
282
+ 'Name' => 'path',
283
+ 'Value' => 'indexAction',
284
+ 'Domain' => '.foo.com',
285
+ 'Path' => '/',
286
+ 'Expires' => 'Tue, 21-Nov-2006 08:33:44 GMT',
287
+ 'Secure' => false,
288
+ 'Discard' => null,
289
+ 'Max-Age' => null,
290
+ 'HttpOnly' => false
291
+ )
292
+ ),
293
+ array(
294
+ 'secure=sha1; secure; SECURE; domain=some.really.deep.domain.com; version=1; Max-Age=86400',
295
+ array(
296
+ 'Name' => 'secure',
297
+ 'Value' => 'sha1',
298
+ 'Domain' => 'some.really.deep.domain.com',
299
+ 'Path' => '/',
300
+ 'Secure' => true,
301
+ 'Discard' => null,
302
+ 'Expires' => time() + 86400,
303
+ 'Max-Age' => 86400,
304
+ 'HttpOnly' => false,
305
+ 'version' => '1'
306
+ )
307
+ ),
308
+ array(
309
+ 'PHPSESSID=123456789+abcd%2Cef; secure; discard; domain=.localdomain; path=/foo/baz; expires=Tue, 21-Nov-2006 08:33:44 GMT;',
310
+ array(
311
+ 'Name' => 'PHPSESSID',
312
+ 'Value' => '123456789+abcd%2Cef',
313
+ 'Domain' => '.localdomain',
314
+ 'Path' => '/foo/baz',
315
+ 'Expires' => 'Tue, 21-Nov-2006 08:33:44 GMT',
316
+ 'Secure' => true,
317
+ 'Discard' => true,
318
+ 'Max-Age' => null,
319
+ 'HttpOnly' => false
320
+ )
321
+ ),
322
+ );
323
+ }
324
+
325
+ /**
326
+ * @dataProvider cookieParserDataProvider
327
+ */
328
+ public function testParseCookie($cookie, $parsed)
329
+ {
330
+ foreach ((array) $cookie as $v) {
331
+ $c = SetCookie::fromString($v);
332
+ $p = $c->toArray();
333
+
334
+ if (isset($p['Expires'])) {
335
+ // Remove expires values from the assertion if they are relatively equal
336
+ if (abs($p['Expires'] != strtotime($parsed['Expires'])) < 40) {
337
+ unset($p['Expires']);
338
+ unset($parsed['Expires']);
339
+ }
340
+ }
341
+
342
+ if (!empty($parsed)) {
343
+ foreach ($parsed as $key => $value) {
344
+ $this->assertEquals($parsed[$key], $p[$key], 'Comparing ' . $key . ' ' . var_export($value, true) . ' : ' . var_export($parsed, true) . ' | ' . var_export($p, true));
345
+ }
346
+ foreach ($p as $key => $value) {
347
+ $this->assertEquals($p[$key], $parsed[$key], 'Comparing ' . $key . ' ' . var_export($value, true) . ' : ' . var_export($parsed, true) . ' | ' . var_export($p, true));
348
+ }
349
+ } else {
350
+ $this->assertEquals([
351
+ 'Name' => null,
352
+ 'Value' => null,
353
+ 'Domain' => null,
354
+ 'Path' => '/',
355
+ 'Max-Age' => null,
356
+ 'Expires' => null,
357
+ 'Secure' => false,
358
+ 'Discard' => false,
359
+ 'HttpOnly' => false,
360
+ ], $p);
361
+ }
362
+ }
363
+ }
364
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/tests/Event/AbstractEventTest.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Event;
3
+
4
+ class AbstractEventTest extends \PHPUnit_Framework_TestCase
5
+ {
6
+ public function testStopsPropagation()
7
+ {
8
+ $e = $this->getMockBuilder('GuzzleHttp\Event\AbstractEvent')
9
+ ->getMockForAbstractClass();
10
+ $this->assertFalse($e->isPropagationStopped());
11
+ $e->stopPropagation();
12
+ $this->assertTrue($e->isPropagationStopped());
13
+ }
14
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/tests/Event/AbstractRequestEventTest.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Event;
3
+
4
+ use GuzzleHttp\Client;
5
+ use GuzzleHttp\Transaction;
6
+ use GuzzleHttp\Message\Request;
7
+
8
+ /**
9
+ * @covers GuzzleHttp\Event\AbstractRequestEvent
10
+ */
11
+ class AbstractRequestEventTest extends \PHPUnit_Framework_TestCase
12
+ {
13
+ public function testHasTransactionMethods()
14
+ {
15
+ $t = new Transaction(new Client(), new Request('GET', '/'));
16
+ $e = $this->getMockBuilder('GuzzleHttp\Event\AbstractRequestEvent')
17
+ ->setConstructorArgs([$t])
18
+ ->getMockForAbstractClass();
19
+ $this->assertSame($t->client, $e->getClient());
20
+ $this->assertSame($t->request, $e->getRequest());
21
+ }
22
+
23
+ public function testHasTransaction()
24
+ {
25
+ $t = new Transaction(new Client(), new Request('GET', '/'));
26
+ $e = $this->getMockBuilder('GuzzleHttp\Event\AbstractRequestEvent')
27
+ ->setConstructorArgs([$t])
28
+ ->getMockForAbstractClass();
29
+ $r = new \ReflectionMethod($e, 'getTransaction');
30
+ $r->setAccessible(true);
31
+ $this->assertSame($t, $r->invoke($e));
32
+ }
33
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/tests/Event/AbstractRetryableEventTest.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Event;
3
+
4
+ use GuzzleHttp\Client;
5
+ use GuzzleHttp\Transaction;
6
+ use GuzzleHttp\Message\Request;
7
+
8
+ /**
9
+ * @covers GuzzleHttp\Event\AbstractRetryableEvent
10
+ */
11
+ class AbstractRetryableEventTest extends \PHPUnit_Framework_TestCase
12
+ {
13
+ public function testCanRetry()
14
+ {
15
+ $t = new Transaction(new Client(), new Request('GET', '/'));
16
+ $t->transferInfo = ['foo' => 'bar'];
17
+ $e = $this->getMockBuilder('GuzzleHttp\Event\AbstractRetryableEvent')
18
+ ->setConstructorArgs([$t])
19
+ ->getMockForAbstractClass();
20
+ $e->retry();
21
+ $this->assertTrue($e->isPropagationStopped());
22
+ $this->assertEquals('retry', $t->state);
23
+ }
24
+
25
+ public function testCanRetryAfterDelay()
26
+ {
27
+ $t = new Transaction(new Client(), new Request('GET', '/'));
28
+ $t->transferInfo = ['foo' => 'bar'];
29
+ $e = $this->getMockBuilder('GuzzleHttp\Event\AbstractRetryableEvent')
30
+ ->setConstructorArgs([$t])
31
+ ->getMockForAbstractClass();
32
+ $e->retry(10);
33
+ $this->assertTrue($e->isPropagationStopped());
34
+ $this->assertEquals('retry', $t->state);
35
+ $this->assertEquals(10, $t->request->getConfig()->get('delay'));
36
+ }
37
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/tests/Event/AbstractTransferEventTest.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Event;
3
+
4
+ use GuzzleHttp\Client;
5
+ use GuzzleHttp\Message\Response;
6
+ use GuzzleHttp\Transaction;
7
+ use GuzzleHttp\Message\Request;
8
+
9
+ /**
10
+ * @covers GuzzleHttp\Event\AbstractTransferEvent
11
+ */
12
+ class AbstractTransferEventTest extends \PHPUnit_Framework_TestCase
13
+ {
14
+ public function testHasStats()
15
+ {
16
+ $t = new Transaction(new Client(), new Request('GET', '/'));
17
+ $t->transferInfo = ['foo' => 'bar'];
18
+ $e = $this->getMockBuilder('GuzzleHttp\Event\AbstractTransferEvent')
19
+ ->setConstructorArgs([$t])
20
+ ->getMockForAbstractClass();
21
+ $this->assertNull($e->getTransferInfo('baz'));
22
+ $this->assertEquals('bar', $e->getTransferInfo('foo'));
23
+ $this->assertEquals($t->transferInfo, $e->getTransferInfo());
24
+ }
25
+
26
+ public function testHasResponse()
27
+ {
28
+ $t = new Transaction(new Client(), new Request('GET', '/'));
29
+ $t->response = new Response(200);
30
+ $e = $this->getMockBuilder('GuzzleHttp\Event\AbstractTransferEvent')
31
+ ->setConstructorArgs([$t])
32
+ ->getMockForAbstractClass();
33
+ $this->assertTrue($e->hasResponse());
34
+ $this->assertSame($t->response, $e->getResponse());
35
+ }
36
+
37
+ public function testCanInterceptWithResponse()
38
+ {
39
+ $t = new Transaction(new Client(), new Request('GET', '/'));
40
+ $r = new Response(200);
41
+ $e = $this->getMockBuilder('GuzzleHttp\Event\AbstractTransferEvent')
42
+ ->setConstructorArgs([$t])
43
+ ->getMockForAbstractClass();
44
+ $e->intercept($r);
45
+ $this->assertSame($t->response, $r);
46
+ $this->assertSame($t->response, $e->getResponse());
47
+ $this->assertTrue($e->isPropagationStopped());
48
+ }
49
+
50
+ public function testReturnsNumberOfRetries()
51
+ {
52
+ $t = new Transaction(new Client(), new Request('GET', '/'));
53
+ $t->retries = 2;
54
+ $e = $this->getMockBuilder('GuzzleHttp\Event\AbstractTransferEvent')
55
+ ->setConstructorArgs([$t])
56
+ ->getMockForAbstractClass();
57
+ $this->assertEquals(2, $e->getRetryCount());
58
+ }
59
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/tests/Event/BeforeEventTest.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Event;
3
+
4
+ use GuzzleHttp\Transaction;
5
+ use GuzzleHttp\Client;
6
+ use GuzzleHttp\Event\BeforeEvent;
7
+ use GuzzleHttp\Message\Request;
8
+ use GuzzleHttp\Message\Response;
9
+
10
+ /**
11
+ * @covers GuzzleHttp\Event\BeforeEvent
12
+ */
13
+ class BeforeEventTest extends \PHPUnit_Framework_TestCase
14
+ {
15
+ public function testInterceptsWithEvent()
16
+ {
17
+ $t = new Transaction(new Client(), new Request('GET', '/'));
18
+ $t->exception = new \Exception('foo');
19
+ $e = new BeforeEvent($t);
20
+ $response = new Response(200);
21
+ $e->intercept($response);
22
+ $this->assertTrue($e->isPropagationStopped());
23
+ $this->assertSame($t->response, $response);
24
+ $this->assertNull($t->exception);
25
+ }
26
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/tests/Event/EmitterTest.php ADDED
@@ -0,0 +1,363 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Event;
3
+
4
+ use GuzzleHttp\Event\Emitter;
5
+ use GuzzleHttp\Event\EventInterface;
6
+ use GuzzleHttp\Event\SubscriberInterface;
7
+
8
+ /**
9
+ * @link https://github.com/symfony/symfony/blob/master/src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php Based on this test.
10
+ */
11
+ class EmitterTest extends \PHPUnit_Framework_TestCase
12
+ {
13
+ /* Some pseudo events */
14
+ const preFoo = 'pre.foo';
15
+ const postFoo = 'post.foo';
16
+ const preBar = 'pre.bar';
17
+ const postBar = 'post.bar';
18
+
19
+ /** @var Emitter */
20
+ private $emitter;
21
+ private $listener;
22
+
23
+ protected function setUp()
24
+ {
25
+ $this->emitter = new Emitter();
26
+ $this->listener = new TestEventListener();
27
+ }
28
+
29
+ protected function tearDown()
30
+ {
31
+ $this->emitter = null;
32
+ $this->listener = null;
33
+ }
34
+
35
+ public function testInitialState()
36
+ {
37
+ $this->assertEquals(array(), $this->emitter->listeners());
38
+ }
39
+
40
+ public function testAddListener()
41
+ {
42
+ $this->emitter->on('pre.foo', array($this->listener, 'preFoo'));
43
+ $this->emitter->on('post.foo', array($this->listener, 'postFoo'));
44
+ $this->assertTrue($this->emitter->hasListeners(self::preFoo));
45
+ $this->assertTrue($this->emitter->hasListeners(self::preFoo));
46
+ $this->assertCount(1, $this->emitter->listeners(self::postFoo));
47
+ $this->assertCount(1, $this->emitter->listeners(self::postFoo));
48
+ $this->assertCount(2, $this->emitter->listeners());
49
+ }
50
+
51
+ public function testGetListenersSortsByPriority()
52
+ {
53
+ $listener1 = new TestEventListener();
54
+ $listener2 = new TestEventListener();
55
+ $listener3 = new TestEventListener();
56
+ $listener1->name = '1';
57
+ $listener2->name = '2';
58
+ $listener3->name = '3';
59
+
60
+ $this->emitter->on('pre.foo', array($listener1, 'preFoo'), -10);
61
+ $this->emitter->on('pre.foo', array($listener2, 'preFoo'), 10);
62
+ $this->emitter->on('pre.foo', array($listener3, 'preFoo'));
63
+
64
+ $expected = array(
65
+ array($listener2, 'preFoo'),
66
+ array($listener3, 'preFoo'),
67
+ array($listener1, 'preFoo'),
68
+ );
69
+
70
+ $this->assertSame($expected, $this->emitter->listeners('pre.foo'));
71
+ }
72
+
73
+ public function testGetAllListenersSortsByPriority()
74
+ {
75
+ $listener1 = new TestEventListener();
76
+ $listener2 = new TestEventListener();
77
+ $listener3 = new TestEventListener();
78
+ $listener4 = new TestEventListener();
79
+ $listener5 = new TestEventListener();
80
+ $listener6 = new TestEventListener();
81
+
82
+ $this->emitter->on('pre.foo', [$listener1, 'preFoo'], -10);
83
+ $this->emitter->on('pre.foo', [$listener2, 'preFoo']);
84
+ $this->emitter->on('pre.foo', [$listener3, 'preFoo'], 10);
85
+ $this->emitter->on('post.foo', [$listener4, 'preFoo'], -10);
86
+ $this->emitter->on('post.foo', [$listener5, 'preFoo']);
87
+ $this->emitter->on('post.foo', [$listener6, 'preFoo'], 10);
88
+
89
+ $expected = [
90
+ 'pre.foo' => [[$listener3, 'preFoo'], [$listener2, 'preFoo'], [$listener1, 'preFoo']],
91
+ 'post.foo' => [[$listener6, 'preFoo'], [$listener5, 'preFoo'], [$listener4, 'preFoo']],
92
+ ];
93
+
94
+ $this->assertSame($expected, $this->emitter->listeners());
95
+ }
96
+
97
+ public function testDispatch()
98
+ {
99
+ $this->emitter->on('pre.foo', array($this->listener, 'preFoo'));
100
+ $this->emitter->on('post.foo', array($this->listener, 'postFoo'));
101
+ $this->emitter->emit(self::preFoo, $this->getEvent());
102
+ $this->assertTrue($this->listener->preFooInvoked);
103
+ $this->assertFalse($this->listener->postFooInvoked);
104
+ $this->assertInstanceOf('GuzzleHttp\Event\EventInterface', $this->emitter->emit(self::preFoo, $this->getEvent()));
105
+ $event = $this->getEvent();
106
+ $return = $this->emitter->emit(self::preFoo, $event);
107
+ $this->assertSame($event, $return);
108
+ }
109
+
110
+ public function testDispatchForClosure()
111
+ {
112
+ $invoked = 0;
113
+ $listener = function () use (&$invoked) {
114
+ $invoked++;
115
+ };
116
+ $this->emitter->on('pre.foo', $listener);
117
+ $this->emitter->on('post.foo', $listener);
118
+ $this->emitter->emit(self::preFoo, $this->getEvent());
119
+ $this->assertEquals(1, $invoked);
120
+ }
121
+
122
+ public function testStopEventPropagation()
123
+ {
124
+ $otherListener = new TestEventListener();
125
+
126
+ // postFoo() stops the propagation, so only one listener should
127
+ // be executed
128
+ // Manually set priority to enforce $this->listener to be called first
129
+ $this->emitter->on('post.foo', array($this->listener, 'postFoo'), 10);
130
+ $this->emitter->on('post.foo', array($otherListener, 'preFoo'));
131
+ $this->emitter->emit(self::postFoo, $this->getEvent());
132
+ $this->assertTrue($this->listener->postFooInvoked);
133
+ $this->assertFalse($otherListener->postFooInvoked);
134
+ }
135
+
136
+ public function testDispatchByPriority()
137
+ {
138
+ $invoked = array();
139
+ $listener1 = function () use (&$invoked) {
140
+ $invoked[] = '1';
141
+ };
142
+ $listener2 = function () use (&$invoked) {
143
+ $invoked[] = '2';
144
+ };
145
+ $listener3 = function () use (&$invoked) {
146
+ $invoked[] = '3';
147
+ };
148
+ $this->emitter->on('pre.foo', $listener1, -10);
149
+ $this->emitter->on('pre.foo', $listener2);
150
+ $this->emitter->on('pre.foo', $listener3, 10);
151
+ $this->emitter->emit(self::preFoo, $this->getEvent());
152
+ $this->assertEquals(array('3', '2', '1'), $invoked);
153
+ }
154
+
155
+ public function testRemoveListener()
156
+ {
157
+ $this->emitter->on('pre.bar', [$this->listener, 'preFoo']);
158
+ $this->assertNotEmpty($this->emitter->listeners(self::preBar));
159
+ $this->emitter->removeListener('pre.bar', [$this->listener, 'preFoo']);
160
+ $this->assertEmpty($this->emitter->listeners(self::preBar));
161
+ $this->emitter->removeListener('notExists', [$this->listener, 'preFoo']);
162
+ }
163
+
164
+ public function testAddSubscriber()
165
+ {
166
+ $eventSubscriber = new TestEventSubscriber();
167
+ $this->emitter->attach($eventSubscriber);
168
+ $this->assertNotEmpty($this->emitter->listeners(self::preFoo));
169
+ $this->assertNotEmpty($this->emitter->listeners(self::postFoo));
170
+ }
171
+
172
+ public function testAddSubscriberWithMultiple()
173
+ {
174
+ $eventSubscriber = new TestEventSubscriberWithMultiple();
175
+ $this->emitter->attach($eventSubscriber);
176
+ $listeners = $this->emitter->listeners('pre.foo');
177
+ $this->assertNotEmpty($this->emitter->listeners(self::preFoo));
178
+ $this->assertCount(2, $listeners);
179
+ }
180
+
181
+ public function testAddSubscriberWithPriorities()
182
+ {
183
+ $eventSubscriber = new TestEventSubscriber();
184
+ $this->emitter->attach($eventSubscriber);
185
+
186
+ $eventSubscriber = new TestEventSubscriberWithPriorities();
187
+ $this->emitter->attach($eventSubscriber);
188
+
189
+ $listeners = $this->emitter->listeners('pre.foo');
190
+ $this->assertNotEmpty($this->emitter->listeners(self::preFoo));
191
+ $this->assertCount(2, $listeners);
192
+ $this->assertInstanceOf('GuzzleHttp\Tests\Event\TestEventSubscriberWithPriorities', $listeners[0][0]);
193
+ }
194
+
195
+ public function testdetach()
196
+ {
197
+ $eventSubscriber = new TestEventSubscriber();
198
+ $this->emitter->attach($eventSubscriber);
199
+ $this->assertNotEmpty($this->emitter->listeners(self::preFoo));
200
+ $this->assertNotEmpty($this->emitter->listeners(self::postFoo));
201
+ $this->emitter->detach($eventSubscriber);
202
+ $this->assertEmpty($this->emitter->listeners(self::preFoo));
203
+ $this->assertEmpty($this->emitter->listeners(self::postFoo));
204
+ }
205
+
206
+ public function testdetachWithPriorities()
207
+ {
208
+ $eventSubscriber = new TestEventSubscriberWithPriorities();
209
+ $this->emitter->attach($eventSubscriber);
210
+ $this->assertNotEmpty($this->emitter->listeners(self::preFoo));
211
+ $this->assertNotEmpty($this->emitter->listeners(self::postFoo));
212
+ $this->emitter->detach($eventSubscriber);
213
+ $this->assertEmpty($this->emitter->listeners(self::preFoo));
214
+ $this->assertEmpty($this->emitter->listeners(self::postFoo));
215
+ }
216
+
217
+ public function testEventReceivesEventNameAsArgument()
218
+ {
219
+ $listener = new TestWithDispatcher();
220
+ $this->emitter->on('test', array($listener, 'foo'));
221
+ $this->assertNull($listener->name);
222
+ $this->emitter->emit('test', $this->getEvent());
223
+ $this->assertEquals('test', $listener->name);
224
+ }
225
+
226
+ /**
227
+ * @see https://bugs.php.net/bug.php?id=62976
228
+ *
229
+ * This bug affects:
230
+ * - The PHP 5.3 branch for versions < 5.3.18
231
+ * - The PHP 5.4 branch for versions < 5.4.8
232
+ * - The PHP 5.5 branch is not affected
233
+ */
234
+ public function testWorkaroundForPhpBug62976()
235
+ {
236
+ $dispatcher = new Emitter();
237
+ $dispatcher->on('bug.62976', new CallableClass());
238
+ $dispatcher->removeListener('bug.62976', function () {});
239
+ $this->assertNotEmpty($dispatcher->listeners('bug.62976'));
240
+ }
241
+
242
+ public function testRegistersEventsOnce()
243
+ {
244
+ $this->emitter->once('pre.foo', array($this->listener, 'preFoo'));
245
+ $this->emitter->on('pre.foo', array($this->listener, 'preFoo'));
246
+ $this->assertCount(2, $this->emitter->listeners(self::preFoo));
247
+ $this->emitter->emit(self::preFoo, $this->getEvent());
248
+ $this->assertTrue($this->listener->preFooInvoked);
249
+ $this->assertCount(1, $this->emitter->listeners(self::preFoo));
250
+ }
251
+
252
+ public function testReturnsEmptyArrayForNonExistentEvent()
253
+ {
254
+ $this->assertEquals([], $this->emitter->listeners('doesnotexist'));
255
+ }
256
+
257
+ public function testCanAddFirstAndLastListeners()
258
+ {
259
+ $b = '';
260
+ $this->emitter->on('foo', function () use (&$b) { $b .= 'a'; }, 'first'); // 1
261
+ $this->emitter->on('foo', function () use (&$b) { $b .= 'b'; }, 'last'); // 0
262
+ $this->emitter->on('foo', function () use (&$b) { $b .= 'c'; }, 'first'); // 2
263
+ $this->emitter->on('foo', function () use (&$b) { $b .= 'd'; }, 'first'); // 3
264
+ $this->emitter->on('foo', function () use (&$b) { $b .= 'e'; }, 'first'); // 4
265
+ $this->emitter->on('foo', function () use (&$b) { $b .= 'f'; }); // 0
266
+ $this->emitter->emit('foo', $this->getEvent());
267
+ $this->assertEquals('edcabf', $b);
268
+ }
269
+
270
+ /**
271
+ * @return \GuzzleHttp\Event\EventInterface
272
+ */
273
+ private function getEvent()
274
+ {
275
+ return $this->getMockBuilder('GuzzleHttp\Event\AbstractEvent')
276
+ ->getMockForAbstractClass();
277
+ }
278
+ }
279
+
280
+ class CallableClass
281
+ {
282
+ public function __invoke()
283
+ {
284
+ }
285
+ }
286
+
287
+ class TestEventListener
288
+ {
289
+ public $preFooInvoked = false;
290
+ public $postFooInvoked = false;
291
+
292
+ /* Listener methods */
293
+
294
+ public function preFoo(EventInterface $e)
295
+ {
296
+ $this->preFooInvoked = true;
297
+ }
298
+
299
+ public function postFoo(EventInterface $e)
300
+ {
301
+ $this->postFooInvoked = true;
302
+
303
+ $e->stopPropagation();
304
+ }
305
+
306
+ /**
307
+ * @expectedException \PHPUnit_Framework_Error_Deprecated
308
+ */
309
+ public function testHasDeprecatedAddListener()
310
+ {
311
+ $emitter = new Emitter();
312
+ $emitter->addListener('foo', function () {});
313
+ }
314
+
315
+ /**
316
+ * @expectedException \PHPUnit_Framework_Error_Deprecated
317
+ */
318
+ public function testHasDeprecatedAddSubscriber()
319
+ {
320
+ $emitter = new Emitter();
321
+ $emitter->addSubscriber('foo', new TestEventSubscriber());
322
+ }
323
+ }
324
+
325
+ class TestWithDispatcher
326
+ {
327
+ public $name;
328
+
329
+ public function foo(EventInterface $e, $name)
330
+ {
331
+ $this->name = $name;
332
+ }
333
+ }
334
+
335
+ class TestEventSubscriber extends TestEventListener implements SubscriberInterface
336
+ {
337
+ public function getEvents()
338
+ {
339
+ return [
340
+ 'pre.foo' => ['preFoo'],
341
+ 'post.foo' => ['postFoo']
342
+ ];
343
+ }
344
+ }
345
+
346
+ class TestEventSubscriberWithPriorities extends TestEventListener implements SubscriberInterface
347
+ {
348
+ public function getEvents()
349
+ {
350
+ return [
351
+ 'pre.foo' => ['preFoo', 10],
352
+ 'post.foo' => ['postFoo']
353
+ ];
354
+ }
355
+ }
356
+
357
+ class TestEventSubscriberWithMultiple extends TestEventListener implements SubscriberInterface
358
+ {
359
+ public function getEvents()
360
+ {
361
+ return ['pre.foo' => [['preFoo', 10],['preFoo', 20]]];
362
+ }
363
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/tests/Event/ErrorEventTest.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Event;
3
+
4
+ use GuzzleHttp\Transaction;
5
+ use GuzzleHttp\Client;
6
+ use GuzzleHttp\Event\ErrorEvent;
7
+ use GuzzleHttp\Exception\RequestException;
8
+ use GuzzleHttp\Message\Request;
9
+
10
+ /**
11
+ * @covers GuzzleHttp\Event\ErrorEvent
12
+ */
13
+ class ErrorEventTest extends \PHPUnit_Framework_TestCase
14
+ {
15
+ public function testInterceptsWithEvent()
16
+ {
17
+ $t = new Transaction(new Client(), new Request('GET', '/'));
18
+ $except = new RequestException('foo', $t->request);
19
+ $t->exception = $except;
20
+ $e = new ErrorEvent($t);
21
+ $this->assertSame($e->getException(), $t->exception);
22
+ }
23
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/tests/Event/HasEmitterTraitTest.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Event;
3
+
4
+ use GuzzleHttp\Event\HasEmitterInterface;
5
+ use GuzzleHttp\Event\HasEmitterTrait;
6
+
7
+ class AbstractHasEmitter implements HasEmitterInterface
8
+ {
9
+ use HasEmitterTrait;
10
+ }
11
+
12
+ /**
13
+ * @covers GuzzleHttp\Event\HasEmitterTrait
14
+ */
15
+ class HasEmitterTraitTest extends \PHPUnit_Framework_TestCase
16
+ {
17
+ public function testHelperAttachesSubscribers()
18
+ {
19
+ $mock = $this->getMockBuilder('GuzzleHttp\Tests\Event\AbstractHasEmitter')
20
+ ->getMockForAbstractClass();
21
+
22
+ $result = $mock->getEmitter();
23
+ $this->assertInstanceOf('GuzzleHttp\Event\EmitterInterface', $result);
24
+ $result2 = $mock->getEmitter();
25
+ $this->assertSame($result, $result2);
26
+ }
27
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/tests/Event/ListenerAttacherTraitTest.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Event;
3
+
4
+ use GuzzleHttp\Event\HasEmitterInterface;
5
+ use GuzzleHttp\Event\HasEmitterTrait;
6
+ use GuzzleHttp\Event\ListenerAttacherTrait;
7
+
8
+ class ObjectWithEvents implements HasEmitterInterface
9
+ {
10
+ use HasEmitterTrait, ListenerAttacherTrait;
11
+
12
+ public $listeners = [];
13
+
14
+ public function __construct(array $args = [])
15
+ {
16
+ $this->listeners = $this->prepareListeners($args, ['foo', 'bar']);
17
+ $this->attachListeners($this, $this->listeners);
18
+ }
19
+ }
20
+
21
+ class ListenerAttacherTraitTest extends \PHPUnit_Framework_TestCase
22
+ {
23
+ public function testRegistersEvents()
24
+ {
25
+ $fn = function () {};
26
+ $o = new ObjectWithEvents([
27
+ 'foo' => $fn,
28
+ 'bar' => $fn,
29
+ ]);
30
+
31
+ $this->assertEquals([
32
+ ['name' => 'foo', 'fn' => $fn, 'priority' => 0, 'once' => false],
33
+ ['name' => 'bar', 'fn' => $fn, 'priority' => 0, 'once' => false],
34
+ ], $o->listeners);
35
+
36
+ $this->assertCount(1, $o->getEmitter()->listeners('foo'));
37
+ $this->assertCount(1, $o->getEmitter()->listeners('bar'));
38
+ }
39
+
40
+ public function testRegistersEventsWithPriorities()
41
+ {
42
+ $fn = function () {};
43
+ $o = new ObjectWithEvents([
44
+ 'foo' => ['fn' => $fn, 'priority' => 99, 'once' => true],
45
+ 'bar' => ['fn' => $fn, 'priority' => 50],
46
+ ]);
47
+
48
+ $this->assertEquals([
49
+ ['name' => 'foo', 'fn' => $fn, 'priority' => 99, 'once' => true],
50
+ ['name' => 'bar', 'fn' => $fn, 'priority' => 50, 'once' => false],
51
+ ], $o->listeners);
52
+ }
53
+
54
+ public function testRegistersMultipleEvents()
55
+ {
56
+ $fn = function () {};
57
+ $eventArray = [['fn' => $fn], ['fn' => $fn]];
58
+ $o = new ObjectWithEvents([
59
+ 'foo' => $eventArray,
60
+ 'bar' => $eventArray,
61
+ ]);
62
+
63
+ $this->assertEquals([
64
+ ['name' => 'foo', 'fn' => $fn, 'priority' => 0, 'once' => false],
65
+ ['name' => 'foo', 'fn' => $fn, 'priority' => 0, 'once' => false],
66
+ ['name' => 'bar', 'fn' => $fn, 'priority' => 0, 'once' => false],
67
+ ['name' => 'bar', 'fn' => $fn, 'priority' => 0, 'once' => false],
68
+ ], $o->listeners);
69
+
70
+ $this->assertCount(2, $o->getEmitter()->listeners('foo'));
71
+ $this->assertCount(2, $o->getEmitter()->listeners('bar'));
72
+ }
73
+
74
+ public function testRegistersEventsWithOnce()
75
+ {
76
+ $called = 0;
77
+ $fn = function () use (&$called) { $called++; };
78
+ $o = new ObjectWithEvents(['foo' => ['fn' => $fn, 'once' => true]]);
79
+ $ev = $this->getMock('GuzzleHttp\Event\EventInterface');
80
+ $o->getEmitter()->emit('foo', $ev);
81
+ $o->getEmitter()->emit('foo', $ev);
82
+ $this->assertEquals(1, $called);
83
+ }
84
+
85
+ /**
86
+ * @expectedException \InvalidArgumentException
87
+ */
88
+ public function testValidatesEvents()
89
+ {
90
+ new ObjectWithEvents(['foo' => 'bar']);
91
+ }
92
+ }
app/code/community/Nektria/ReCS/lib/vendor/guzzlehttp/guzzle/tests/Event/ProgressEventTest.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace GuzzleHttp\Tests\Event;
3
+
4
+ use GuzzleHttp\Client;
5
+ use GuzzleHttp\Event\ProgressEvent;
6
+ use GuzzleHttp\Message\Request;
7
+ use GuzzleHttp\Transaction;
8
+
9
+ /**
10
+ * @covers GuzzleHttp\Event\ProgressEvent
11
+ */
12
+ class ProgressEventTest extends \PHPUnit_Framework_TestCase
13
+ {
14
+ public function testContainsNumbers()
15
+ {
16
+ $t =