Google Pagespeed Insights - Version 4.0.0-beta1

Version Description

  • Migrating to the latest version of the Google Pagespeed Insights API (v5). This comes with pretty big changes to reporting and is incompatible with previous API versions
  • Removed Google PHP API library to work with the latest version of Google Pagespeed Insights, and also to shed the bulk of the library from this plugin
  • Bugfix SQL Mutex lock key not unique per installation causing issues when trying to run this plugin on multiple sites sharing the same SQL server
Download this release

Release Info

Developer mattkeys
Plugin Icon 128x128 Google Pagespeed Insights
Version 4.0.0-beta1
Comparing to
See all releases

Code changes from version 3.0.4 to 4.0.0-beta1

Files changed (222) hide show
  1. assets/css/gpagespeedi_styles.css +243 -65
  2. assets/js/details.js +127 -138
  3. assets/js/global.js +27 -1
  4. assets/js/summary.js +143 -74
  5. assets/js/templates/details/audits-criticalrequestchain.php +49 -0
  6. assets/js/templates/details/audits-filmstrip.php +8 -0
  7. assets/js/templates/details/audits-opportunity.php +47 -0
  8. assets/js/templates/details/audits-table.php +50 -0
  9. assets/js/templates/details/rule_blocks.php +1 -1
  10. assets/js/templates/details/statistics.php +1 -1
  11. assets/js/templates/summary/areas_of_improvement.php +1 -1
  12. assets/js/view-snapshot.js +213 -54
  13. classes/class-GPI-Actions.php +7 -3
  14. classes/class-GPI-Activation.php +50 -33
  15. classes/class-GPI-Admin.php +144 -98
  16. classes/class-GPI-Core.php +61 -161
  17. classes/class-GPI-List-Table.php +14 -10
  18. classes/class-GPI-Pagespeed-API.php +227 -0
  19. classes/class-GPI-Uninstall.php +5 -0
  20. google-pagespeed-insights.php +8 -3
  21. lib/google-api-php-client/LICENSE +0 -203
  22. lib/google-api-php-client/README.md +0 -368
  23. lib/google-api-php-client/src/Google/AccessToken/Revoke.php +0 -78
  24. lib/google-api-php-client/src/Google/AccessToken/Verify.php +0 -269
  25. lib/google-api-php-client/src/Google/AuthHandler/AuthHandlerFactory.php +0 -42
  26. lib/google-api-php-client/src/Google/AuthHandler/Guzzle5AuthHandler.php +0 -99
  27. lib/google-api-php-client/src/Google/AuthHandler/Guzzle6AuthHandler.php +0 -106
  28. lib/google-api-php-client/src/Google/Client.php +0 -1118
  29. lib/google-api-php-client/src/Google/Collection.php +0 -101
  30. lib/google-api-php-client/src/Google/Exception.php +0 -20
  31. lib/google-api-php-client/src/Google/Http/Batch.php +0 -249
  32. lib/google-api-php-client/src/Google/Http/MediaFileUpload.php +0 -351
  33. lib/google-api-php-client/src/Google/Http/REST.php +0 -182
  34. lib/google-api-php-client/src/Google/Model.php +0 -324
  35. lib/google-api-php-client/src/Google/Service.php +0 -56
  36. lib/google-api-php-client/src/Google/Service/Exception.php +0 -68
  37. lib/google-api-php-client/src/Google/Service/README.md +0 -5
  38. lib/google-api-php-client/src/Google/Service/Resource.php +0 -296
  39. lib/google-api-php-client/src/Google/Task/Exception.php +0 -20
  40. lib/google-api-php-client/src/Google/Task/Retryable.php +0 -24
  41. lib/google-api-php-client/src/Google/Task/Runner.php +0 -281
  42. lib/google-api-php-client/src/Google/Utils/UriTemplate.php +0 -333
  43. lib/google-api-php-client/src/Google/autoload.php +0 -21
  44. lib/google-api-php-client/vendor/autoload.php +0 -7
  45. lib/google-api-php-client/vendor/composer/ClassLoader.php +0 -445
  46. lib/google-api-php-client/vendor/composer/LICENSE +0 -21
  47. lib/google-api-php-client/vendor/composer/autoload_classmap.php +0 -39
  48. lib/google-api-php-client/vendor/composer/autoload_files.php +0 -12
  49. lib/google-api-php-client/vendor/composer/autoload_namespaces.php +0 -18
  50. lib/google-api-php-client/vendor/composer/autoload_psr4.php +0 -17
  51. lib/google-api-php-client/vendor/composer/autoload_real.php +0 -74
  52. lib/google-api-php-client/vendor/composer/autoload_static.php +0 -176
  53. lib/google-api-php-client/vendor/composer/include_paths.php +0 -10
  54. lib/google-api-php-client/vendor/composer/installed.json +0 -720
  55. lib/google-api-php-client/vendor/firebase/php-jwt/Firebase/PHP-JWT/.gitignore +0 -3
  56. lib/google-api-php-client/vendor/firebase/php-jwt/Firebase/PHP-JWT/.travis.yml +0 -13
  57. lib/google-api-php-client/vendor/firebase/php-jwt/Firebase/PHP-JWT/Authentication/JWT.php +0 -326
  58. lib/google-api-php-client/vendor/firebase/php-jwt/Firebase/PHP-JWT/Exceptions/BeforeValidException.php +0 -6
  59. lib/google-api-php-client/vendor/firebase/php-jwt/Firebase/PHP-JWT/Exceptions/ExpiredException.php +0 -6
  60. lib/google-api-php-client/vendor/firebase/php-jwt/Firebase/PHP-JWT/Exceptions/SignatureInvalidException.php +0 -6
  61. lib/google-api-php-client/vendor/firebase/php-jwt/Firebase/PHP-JWT/LICENSE +0 -30
  62. lib/google-api-php-client/vendor/firebase/php-jwt/Firebase/PHP-JWT/README.md +0 -66
  63. lib/google-api-php-client/vendor/firebase/php-jwt/Firebase/PHP-JWT/composer.json +0 -27
  64. lib/google-api-php-client/vendor/firebase/php-jwt/Firebase/PHP-JWT/package.xml +0 -77
  65. lib/google-api-php-client/vendor/firebase/php-jwt/Firebase/PHP-JWT/phpunit.xml.dist +0 -19
  66. lib/google-api-php-client/vendor/firebase/php-jwt/Firebase/PHP-JWT/run-tests.sh +0 -38
  67. lib/google-api-php-client/vendor/google/apiclient-services/.gitignore +0 -4
  68. lib/google-api-php-client/vendor/google/apiclient-services/.travis.yml +0 -14
  69. lib/google-api-php-client/vendor/google/apiclient-services/CONTRIBUTING.md +0 -22
  70. lib/google-api-php-client/vendor/google/apiclient-services/LICENSE +0 -203
  71. lib/google-api-php-client/vendor/google/apiclient-services/README.md +0 -30
  72. lib/google-api-php-client/vendor/google/apiclient-services/composer.json +0 -19
  73. lib/google-api-php-client/vendor/google/apiclient-services/phpunit.xml +0 -11
  74. lib/google-api-php-client/vendor/google/apiclient-services/src/Google/Service/Pagespeedonline.php +0 -93
  75. lib/google-api-php-client/vendor/google/apiclient-services/src/Google/Service/Pagespeedonline/PagespeedApiFormatStringV2.php +0 -47
  76. lib/google-api-php-client/vendor/google/apiclient-services/src/Google/Service/Pagespeedonline/PagespeedApiFormatStringV2Args.php +0 -84
  77. lib/google-api-php-client/vendor/google/apiclient-services/src/Google/Service/Pagespeedonline/PagespeedApiFormatStringV2ArgsRects.php +0 -57
  78. lib/google-api-php-client/vendor/google/apiclient-services/src/Google/Service/Pagespeedonline/PagespeedApiFormatStringV2ArgsSecondaryRects.php +0 -57
  79. lib/google-api-php-client/vendor/google/apiclient-services/src/Google/Service/Pagespeedonline/PagespeedApiImageV2.php +0 -86
  80. lib/google-api-php-client/vendor/google/apiclient-services/src/Google/Service/Pagespeedonline/PagespeedApiImageV2PageRect.php +0 -57
  81. lib/google-api-php-client/vendor/google/apiclient-services/src/Google/Service/Pagespeedonline/Resource/Pagespeedapi.php +0 -52
  82. lib/google-api-php-client/vendor/google/apiclient-services/src/Google/Service/Pagespeedonline/Result.php +0 -147
  83. lib/google-api-php-client/vendor/google/apiclient-services/src/Google/Service/Pagespeedonline/ResultFormattedResults.php +0 -46
  84. lib/google-api-php-client/vendor/google/apiclient-services/src/Google/Service/Pagespeedonline/ResultFormattedResultsRuleResultsElement.php +0 -81
  85. lib/google-api-php-client/vendor/google/apiclient-services/src/Google/Service/Pagespeedonline/ResultFormattedResultsRuleResultsElementUrlBlocks.php +0 -54
  86. lib/google-api-php-client/vendor/google/apiclient-services/src/Google/Service/Pagespeedonline/ResultFormattedResultsRuleResultsElementUrlBlocksUrls.php +0 -54
  87. lib/google-api-php-client/vendor/google/apiclient-services/src/Google/Service/Pagespeedonline/ResultPageStats.php +0 -138
  88. lib/google-api-php-client/vendor/google/apiclient-services/src/Google/Service/Pagespeedonline/ResultRuleGroupsElement.php +0 -30
  89. lib/google-api-php-client/vendor/google/apiclient-services/src/Google/Service/Pagespeedonline/ResultVersion.php +0 -39
  90. lib/google-api-php-client/vendor/google/auth/.editorconfig +0 -18
  91. lib/google-api-php-client/vendor/google/auth/.gitignore +0 -3
  92. lib/google-api-php-client/vendor/google/auth/.php_cs +0 -54
  93. lib/google-api-php-client/vendor/google/auth/.travis.yml +0 -31
  94. lib/google-api-php-client/vendor/google/auth/CHANGELOG.md +0 -18
  95. lib/google-api-php-client/vendor/google/auth/CONTRIBUTING.md +0 -73
  96. lib/google-api-php-client/vendor/google/auth/COPYING +0 -202
  97. lib/google-api-php-client/vendor/google/auth/LICENSE +0 -203
  98. lib/google-api-php-client/vendor/google/auth/README.md +0 -150
  99. lib/google-api-php-client/vendor/google/auth/autoload.php +0 -34
  100. lib/google-api-php-client/vendor/google/auth/composer.json +0 -28
  101. lib/google-api-php-client/vendor/google/auth/phpunit.xml.dist +0 -16
  102. lib/google-api-php-client/vendor/google/auth/src/ApplicationDefaultCredentials.php +0 -173
  103. lib/google-api-php-client/vendor/google/auth/src/Cache/InvalidArgumentException.php +0 -24
  104. lib/google-api-php-client/vendor/google/auth/src/Cache/Item.php +0 -185
  105. lib/google-api-php-client/vendor/google/auth/src/Cache/MemoryCacheItemPool.php +0 -155
  106. lib/google-api-php-client/vendor/google/auth/src/CacheTrait.php +0 -83
  107. lib/google-api-php-client/vendor/google/auth/src/Credentials/AppIdentityCredentials.php +0 -149
  108. lib/google-api-php-client/vendor/google/auth/src/Credentials/GCECredentials.php +0 -219
  109. lib/google-api-php-client/vendor/google/auth/src/Credentials/IAMCredentials.php +0 -89
  110. lib/google-api-php-client/vendor/google/auth/src/Credentials/ServiceAccountCredentials.php +0 -177
  111. lib/google-api-php-client/vendor/google/auth/src/Credentials/ServiceAccountJwtAccessCredentials.php +0 -131
  112. lib/google-api-php-client/vendor/google/auth/src/Credentials/UserRefreshCredentials.php +0 -110
  113. lib/google-api-php-client/vendor/google/auth/src/CredentialsLoader.php +0 -163
  114. lib/google-api-php-client/vendor/google/auth/src/FetchAuthTokenCache.php +0 -108
  115. lib/google-api-php-client/vendor/google/auth/src/FetchAuthTokenInterface.php +0 -55
  116. lib/google-api-php-client/vendor/google/auth/src/HttpHandler/Guzzle5HttpHandler.php +0 -68
  117. lib/google-api-php-client/vendor/google/auth/src/HttpHandler/Guzzle6HttpHandler.php +0 -36
  118. lib/google-api-php-client/vendor/google/auth/src/HttpHandler/HttpHandlerFactory.php +0 -47
  119. lib/google-api-php-client/vendor/google/auth/src/Middleware/AuthTokenMiddleware.php +0 -126
  120. lib/google-api-php-client/vendor/google/auth/src/Middleware/ScopedAccessTokenMiddleware.php +0 -175
  121. lib/google-api-php-client/vendor/google/auth/src/Middleware/SimpleMiddleware.php +0 -93
  122. lib/google-api-php-client/vendor/google/auth/src/OAuth2.php +0 -1306
  123. lib/google-api-php-client/vendor/google/auth/src/Subscriber/AuthTokenSubscriber.php +0 -118
  124. lib/google-api-php-client/vendor/google/auth/src/Subscriber/ScopedAccessTokenSubscriber.php +0 -177
  125. lib/google-api-php-client/vendor/google/auth/src/Subscriber/SimpleSubscriber.php +0 -90
  126. lib/google-api-php-client/vendor/guzzlehttp/guzzle/.travis.yml +0 -41
  127. lib/google-api-php-client/vendor/guzzlehttp/guzzle/CHANGELOG.md +0 -1060
  128. lib/google-api-php-client/vendor/guzzlehttp/guzzle/LICENSE +0 -19
  129. lib/google-api-php-client/vendor/guzzlehttp/guzzle/README.md +0 -70
  130. lib/google-api-php-client/vendor/guzzlehttp/guzzle/UPGRADING.md +0 -1050
  131. lib/google-api-php-client/vendor/guzzlehttp/guzzle/composer.json +0 -33
  132. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/BatchResults.php +0 -148
  133. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Client.php +0 -355
  134. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/ClientInterface.php +0 -150
  135. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Collection.php +0 -236
  136. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php +0 -248
  137. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php +0 -75
  138. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php +0 -86
  139. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php +0 -66
  140. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php +0 -373
  141. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Event/AbstractEvent.php +0 -20
  142. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Event/AbstractRequestEvent.php +0 -61
  143. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Event/AbstractRetryableEvent.php +0 -40
  144. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Event/AbstractTransferEvent.php +0 -63
  145. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Event/BeforeEvent.php +0 -26
  146. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Event/CompleteEvent.php +0 -14
  147. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Event/Emitter.php +0 -145
  148. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Event/EmitterInterface.php +0 -96
  149. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Event/EndEvent.php +0 -28
  150. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Event/ErrorEvent.php +0 -27
  151. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Event/EventInterface.php +0 -23
  152. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Event/HasEmitterInterface.php +0 -15
  153. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Event/HasEmitterTrait.php +0 -20
  154. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Event/ListenerAttacherTrait.php +0 -88
  155. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Event/ProgressEvent.php +0 -51
  156. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Event/RequestEvents.php +0 -56
  157. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Event/SubscriberInterface.php +0 -34
  158. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Exception/BadResponseException.php +0 -7
  159. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Exception/ClientException.php +0 -7
  160. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Exception/ConnectException.php +0 -4
  161. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Exception/CouldNotRewindStreamException.php +0 -4
  162. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Exception/ParseException.php +0 -31
  163. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php +0 -121
  164. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Exception/ServerException.php +0 -7
  165. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Exception/StateException.php +0 -4
  166. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Exception/TooManyRedirectsException.php +0 -4
  167. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Exception/TransferException.php +0 -4
  168. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Exception/XmlParseException.php +0 -34
  169. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/HasDataTrait.php +0 -75
  170. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Message/AbstractMessage.php +0 -253
  171. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Message/AppliesHeadersInterface.php +0 -24
  172. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Message/FutureResponse.php +0 -158
  173. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Message/MessageFactory.php +0 -364
  174. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Message/MessageFactoryInterface.php +0 -71
  175. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Message/MessageInterface.php +0 -136
  176. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Message/MessageParser.php +0 -171
  177. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Message/Request.php +0 -195
  178. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Message/RequestInterface.php +0 -136
  179. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Message/Response.php +0 -208
  180. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Message/ResponseInterface.php +0 -111
  181. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Mimetypes.php +0 -963
  182. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Pool.php +0 -333
  183. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Post/MultipartBody.php +0 -109
  184. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Post/PostBody.php +0 -287
  185. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Post/PostBodyInterface.php +0 -109
  186. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Post/PostFile.php +0 -135
  187. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Post/PostFileInterface.php +0 -41
  188. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Query.php +0 -204
  189. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/QueryParser.php +0 -163
  190. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/RequestFsm.php +0 -153
  191. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/RingBridge.php +0 -165
  192. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Subscriber/Cookie.php +0 -58
  193. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Subscriber/History.php +0 -172
  194. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Subscriber/HttpError.php +0 -36
  195. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Subscriber/Mock.php +0 -147
  196. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Subscriber/Prepare.php +0 -130
  197. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Subscriber/Redirect.php +0 -176
  198. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/ToArrayInterface.php +0 -15
  199. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Transaction.php +0 -103
  200. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/UriTemplate.php +0 -241
  201. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Url.php +0 -595
  202. lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Utils.php +0 -211
  203. lib/google-api-php-client/vendor/guzzlehttp/psr7/.gitignore +0 -11
  204. lib/google-api-php-client/vendor/guzzlehttp/psr7/.travis.yml +0 -20
  205. lib/google-api-php-client/vendor/guzzlehttp/psr7/CHANGELOG.md +0 -28
  206. lib/google-api-php-client/vendor/guzzlehttp/psr7/LICENSE +0 -19
  207. lib/google-api-php-client/vendor/guzzlehttp/psr7/Makefile +0 -13
  208. lib/google-api-php-client/vendor/guzzlehttp/psr7/README.md +0 -580
  209. lib/google-api-php-client/vendor/guzzlehttp/psr7/composer.json +0 -35
  210. lib/google-api-php-client/vendor/guzzlehttp/psr7/phpunit.xml.dist +0 -17
  211. lib/google-api-php-client/vendor/guzzlehttp/psr7/src/AppendStream.php +0 -233
  212. lib/google-api-php-client/vendor/guzzlehttp/psr7/src/BufferStream.php +0 -137
  213. lib/google-api-php-client/vendor/guzzlehttp/psr7/src/CachingStream.php +0 -136
  214. lib/google-api-php-client/vendor/guzzlehttp/psr7/src/DroppingStream.php +0 -42
  215. lib/google-api-php-client/vendor/guzzlehttp/psr7/src/FnStream.php +0 -149
  216. lib/google-api-php-client/vendor/guzzlehttp/psr7/src/InflateStream.php +0 -29
  217. lib/google-api-php-client/vendor/guzzlehttp/psr7/src/LazyOpenStream.php +0 -39
  218. lib/google-api-php-client/vendor/guzzlehttp/psr7/src/LimitStream.php +0 -155
  219. lib/google-api-php-client/vendor/guzzlehttp/psr7/src/MessageTrait.php +0 -158
  220. lib/google-api-php-client/vendor/guzzlehttp/psr7/src/MultipartStream.php +0 -153
  221. lib/google-api-php-client/vendor/guzzlehttp/psr7/src/NoSeekStream.php +0 -22
  222. lib/google-api-php-client/vendor/guzzlehttp/psr7/src/PumpStream.php +0 -40
assets/css/gpagespeedi_styles.css CHANGED
@@ -1,6 +1,12 @@
1
  a.button + input[type="submit"] {
2
  margin-left: 10px;
3
  }
 
 
 
 
 
 
4
  .button-gpi {
5
  border: 1px solid #cccccc;
6
  -webkit-border-radius: 3px;
@@ -32,26 +38,6 @@ a.button + input[type="submit"] {
32
  .button-gpi.run:hover {
33
  background-color: #C10100;
34
  }
35
- input#recheck_all_pages {
36
- position: relative;
37
- top: 2px;
38
- margin-right: 0;
39
- }
40
- label[for="recheck_all_pages"] {
41
- position: relative;
42
- top: 1px;
43
- font-size: 13px;
44
- }
45
- span.tooltip {
46
- color: #3366cc;
47
- }
48
- .ui-tooltip {
49
- background: white;
50
- box-shadow: 0 0 5px rgba( 0, 0, 0, 0.5 );
51
- display: inline-block;
52
- padding: 10px;
53
- max-width: 300px;
54
- }
55
  .button-gpi.abort {
56
  background-color: #e14d43;
57
  background-position: -176px -148px;
@@ -79,6 +65,35 @@ span.tooltip {
79
  .button-gpi.recheck:hover {
80
  background-position: -174px -28px;
81
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  .button-gpi.desktop {
83
  background-position: 9px -60px;
84
  }
@@ -107,19 +122,25 @@ input[type="submit"] + input[type="submit"] {
107
  border-bottom: 1px solid lightgreen;
108
  }
109
  .wrap {
110
- min-width: 830px;
111
  position: relative;
112
  }
113
  .controls {
114
- position: absolute;
115
- right: 0px;
116
- top: 12px;
117
  }
118
  .reportmodes {
119
  position: absolute;
120
  right: 0px;
121
  top: 12px;
122
  }
 
 
 
 
 
 
 
123
  .tablenav .actions input[type="text"] {
124
  height: 28px;
125
  margin: 1px 2px 1px 1px;
@@ -136,9 +157,14 @@ input[type="submit"] + input[type="submit"] {
136
  }
137
  .row {
138
  width: 100%;
139
- overflow: auto;
140
  margin: 0 0 20px;
141
  }
 
 
 
 
 
142
  .boxsizing {
143
  -moz-box-sizing: border-box;
144
  -webkit-box-sizing: border-box;
@@ -150,19 +176,39 @@ input[type="submit"] + input[type="submit"] {
150
  .halfwidth {
151
  width: 49%;
152
  }
153
- .left {
 
 
 
 
 
 
 
 
154
  float: left;
155
  max-width: 49%;
156
  }
157
- .right {
158
  float: right;
159
  max-width: 49%;
160
  }
 
 
 
 
 
 
 
 
 
 
 
 
161
  .half {
162
  width: 49%;
163
  }
164
- .left.half .pagespeed_gauge_wrapper, .left.half .pagespeed_avg_sizes_wrapper,
165
- .right.half .pagespeed_gauge_wrapper, .right.half .pagespeed_avg_sizes_wrapper {
166
  width: 100%;
167
  max-width: 100%;
168
  }
@@ -237,6 +283,9 @@ input[type="submit"] + input[type="submit"] {
237
  text-transform: uppercase;
238
  font-weight: bold;
239
  }
 
 
 
240
  .boxheader.large span.left {
241
  font-size: 18px;
242
  line-height: 60px;
@@ -277,6 +326,7 @@ p.checkbx label {
277
  vertical-align: baseline;
278
  }
279
  p.description {
 
280
  font-weight: lighter;
281
  }
282
  input.googleapi.code {
@@ -312,22 +362,102 @@ h3.subTitle {
312
  margin: 19px 0;
313
  }
314
  .top-row {
315
- height: 234px;
316
  float: left;
317
- margin: 5px 1% 0;
318
- text-align: center;
319
- }
320
- .compare-top-row {
321
  text-align: center;
322
  }
323
  .top-row div {
324
  margin: 0px auto;
325
- display: inline-block;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
326
  }
327
  .opportunities {
328
  position: relative;
329
- background: url('../images/table_rows.png') repeat-y;
330
- background-position: top right;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
331
  }
332
  .impact_chart_right {
333
  position: absolute;
@@ -385,8 +515,9 @@ h3.subTitle {
385
  border-collapse: collapse;
386
  color: #454547;
387
  }
388
- .row table.stats, .row .impact_chart_right table {
389
  height: auto;
 
390
  }
391
  .row table th {
392
  text-align: left;
@@ -397,6 +528,44 @@ h3.subTitle {
397
  .row table td {
398
  height: 29px;
399
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
400
  .row table.stats tr {
401
  border-top: 1px solid #e4e5e6;
402
  }
@@ -408,15 +577,8 @@ h3.subTitle {
408
  }
409
  .row table td.leftcol {
410
  text-align: left;
411
- padding: 0 0 0 22px;
412
- }
413
- .row table.stats td.leftcol {
414
  padding: 0 0 0 12px;
415
  }
416
- .row .pagespeed_stats_wrapper td.rightcol {
417
- padding: 0 12px 0 0;
418
- text-align: right;
419
- }
420
  .row.largest_improvement table.stats td.rightcol {
421
  width: 132px;
422
  text-align: center;
@@ -502,6 +664,7 @@ div#no_results {
502
  .score_chart_div {
503
  width: 204px;
504
  height: 204px;
 
505
  background: url('../images/pagespeed_gauge.png');
506
  overflow: hidden;
507
  position: relative;
@@ -518,7 +681,7 @@ div#no_results {
518
  -webkit-border-radius: 6px;
519
  -moz-border-radius: 6px;
520
  border-radius: 6px;
521
- display: none;
522
  }
523
  .impact_rule_report.images {
524
  background: #e2faff;
@@ -592,26 +755,12 @@ div#no_results {
592
  text-transform: uppercase;
593
  line-height: 12px;
594
  }
595
- .pagespeed_gauge_wrapper {
596
- width: 25%;
597
- }
598
- .pagespeed_stats_wrapper {
599
- width: 30%;
600
- }
601
- .pagespeed_sizes_wrapper {
602
- float: right;
603
- width: 40%;
604
- margin-right: 0px;
605
- overflow: hidden;
606
- }
607
- .pagespeed_avg_sizes_wrapper {
608
- float: right;
609
- width: 72%;
610
- margin-right: 0px;
611
- overflow: hidden;
612
  }
613
- .sizes_chart_div, .compare_sizes_chart_div {
614
- display: inline-block;
 
615
  }
616
  table.error_logs p {
617
  margin-bottom: 0;
@@ -682,6 +831,35 @@ table#tblMain span.checkmark {
682
  width: 0px;
683
  }
684
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
685
  @keyframes ellipsis {
686
  to {
687
  width: 1em;
1
  a.button + input[type="submit"] {
2
  margin-left: 10px;
3
  }
4
+ .ui-tooltip.pos-absolute {
5
+ position: absolute;
6
+ }
7
+ .global-actions {
8
+ display: inline-block;
9
+ }
10
  .button-gpi {
11
  border: 1px solid #cccccc;
12
  -webkit-border-radius: 3px;
38
  .button-gpi.run:hover {
39
  background-color: #C10100;
40
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  .button-gpi.abort {
42
  background-color: #e14d43;
43
  background-position: -176px -148px;
65
  .button-gpi.recheck:hover {
66
  background-position: -174px -28px;
67
  }
68
+ @media only screen and (max-width: 600px) {
69
+ .global-actions {
70
+ display: block;
71
+ margin-top: 15px;
72
+ }
73
+ .button-gpi.abort, .button-gpi.run {
74
+ margin-left: 0;
75
+ }
76
+ }
77
+ input#recheck_all_pages {
78
+ position: relative;
79
+ top: 2px;
80
+ margin-right: 0;
81
+ }
82
+ label[for="recheck_all_pages"] {
83
+ position: relative;
84
+ top: 1px;
85
+ font-size: 13px;
86
+ }
87
+ span.tooltip {
88
+ color: #3366cc;
89
+ }
90
+ .ui-tooltip {
91
+ background: white;
92
+ box-shadow: 0 0 5px rgba( 0, 0, 0, 0.5 );
93
+ display: inline-block;
94
+ padding: 10px;
95
+ max-width: 300px;
96
+ }
97
  .button-gpi.desktop {
98
  background-position: 9px -60px;
99
  }
122
  border-bottom: 1px solid lightgreen;
123
  }
124
  .wrap {
 
125
  position: relative;
126
  }
127
  .controls {
128
+ position: absolute;
129
+ right: 0px;
130
+ top: 12px;
131
  }
132
  .reportmodes {
133
  position: absolute;
134
  right: 0px;
135
  top: 12px;
136
  }
137
+ @media only screen and (max-width: 950px) {
138
+ .reportmodes {
139
+ position: relative;
140
+ right: auto;
141
+ top: auto;
142
+ }
143
+ }
144
  .tablenav .actions input[type="text"] {
145
  height: 28px;
146
  margin: 1px 2px 1px 1px;
157
  }
158
  .row {
159
  width: 100%;
160
+ overflow: visible;
161
  margin: 0 0 20px;
162
  }
163
+ .row:after {
164
+ content: '';
165
+ display: table;
166
+ clear: both;
167
+ }
168
  .boxsizing {
169
  -moz-box-sizing: border-box;
170
  -webkit-box-sizing: border-box;
176
  .halfwidth {
177
  width: 49%;
178
  }
179
+ .halfwidth.left {
180
+ float: left;
181
+ max-width: 49%;
182
+ }
183
+ .halfwidth.right {
184
+ float: right;
185
+ max-width: 49%;
186
+ }
187
+ span.left {
188
  float: left;
189
  max-width: 49%;
190
  }
191
+ span.right {
192
  float: right;
193
  max-width: 49%;
194
  }
195
+ @media only screen and (max-width: 1024px) {
196
+ .halfwidth {
197
+ width: 100%;
198
+ }
199
+ .halfwidth.left, .halfwidth.right {
200
+ float: none;
201
+ max-width: 100%;
202
+ }
203
+ .halfwidth.left {
204
+ margin: 0 0 20px;
205
+ }
206
+ }
207
  .half {
208
  width: 49%;
209
  }
210
+ .left.half .pagespeed_gauge_wrapper, .left.half .pagespeed_avg_lab_data_wrapper,
211
+ .right.half .pagespeed_gauge_wrapper, .right.half .pagespeed_avg_lab_data_wrapper {
212
  width: 100%;
213
  max-width: 100%;
214
  }
283
  text-transform: uppercase;
284
  font-weight: bold;
285
  }
286
+ .boxheader span#passed_audits_count {
287
+ padding: 0;
288
+ }
289
  .boxheader.large span.left {
290
  font-size: 18px;
291
  line-height: 60px;
326
  vertical-align: baseline;
327
  }
328
  p.description {
329
+ margin: 0 0 1em;
330
  font-weight: lighter;
331
  }
332
  input.googleapi.code {
362
  margin: 19px 0;
363
  }
364
  .top-row {
365
+ min-height: 255px;
366
  float: left;
367
+ margin: 6px 1% 0;
 
 
 
368
  text-align: center;
369
  }
370
  .top-row div {
371
  margin: 0px auto;
372
+ display: block;
373
+ }
374
+ .top-row table.stats td.rightcol {
375
+ padding-right: 12px;
376
+ text-align: right;
377
+ }
378
+ .pagespeed_avg_lab_data_wrapper {
379
+ float: right;
380
+ width: 72%;
381
+ margin-right: 0px;
382
+ overflow: hidden;
383
+ }
384
+ .pagespeed_gauge_wrapper {
385
+ width: 25%;
386
+ }
387
+ @media only screen and (max-width: 1024px) {
388
+ .top-row {
389
+ width: 100%;
390
+ float: none;
391
+ margin: 0;
392
+ text-align: center;
393
+ }
394
+ .top-row.pagespeed_lab_data_wrapper {
395
+ margin: 0 0 20px;
396
+ }
397
+ .pagespeed_gauge_wrapper {
398
+ width: 100%;
399
+ }
400
+ }
401
+ @media only screen and (min-width: 1025px) {
402
+ .top-row.pagespeed_lab_data_wrapper {
403
+ width: 30%;
404
+ }
405
+ .top-row.pagespeed_field_data_wrapper {
406
+ float: right;
407
+ width: 40%;
408
+ margin-right: 0px;
409
+ overflow: hidden;
410
+ }
411
+ }
412
+ .compare-top-row {
413
+ text-align: center;
414
  }
415
  .opportunities {
416
  position: relative;
417
+ }
418
+ .row.framed .inner > p {
419
+ margin: 1em 10px;
420
+ }
421
+ .row.framed .details {
422
+ padding: 0 10px 10px;
423
+ }
424
+ .row.framed .details p.description {
425
+ font-weight: normal;
426
+ }
427
+ .row.screenshots .details {
428
+ display: flex;
429
+ justify-content: space-between;
430
+ }
431
+ .row.screenshots .details div {
432
+ width: calc( ( 100% - 33px ) / 10 );
433
+ max-width: 120px;
434
+ }
435
+ .row.screenshots .details div img {
436
+ max-width: 100%;
437
+ }
438
+ .row .accordion h3 {
439
+ font-weight: normal;
440
+ cursor: pointer;
441
+ margin: 0;
442
+ padding: 8px 10px;
443
+ font-size: 14px;
444
+ line-height: 22px;
445
+ border-top: 1px solid #CCC;
446
+ outline: none;
447
+ }
448
+ .row .accordion h3:first-of-type {
449
+ border-top: none;
450
+ }
451
+ .row .accordion h3.ui-state-active {
452
+ font-weight: bold;
453
+ }
454
+ @media only screen and (max-width: 500px) {
455
+ .row .accordion h3 span.right {
456
+ display: none;
457
+ }
458
+ .row.lighthouse span.right {
459
+ display: none;
460
+ }
461
  }
462
  .impact_chart_right {
463
  position: absolute;
515
  border-collapse: collapse;
516
  color: #454547;
517
  }
518
+ .row table.stats, .row table.audits, .row .impact_chart_right table {
519
  height: auto;
520
+ width: 100%;
521
  }
522
  .row table th {
523
  text-align: left;
528
  .row table td {
529
  height: 29px;
530
  }
531
+ .row table.audits th {
532
+ background: #ffe4b5;
533
+ text-align: right;
534
+ padding: 0 10px;
535
+ }
536
+ .row table.audits th:first-of-type {
537
+ text-align: center;
538
+ }
539
+ .row table.audits th:not(:first-of-type) {
540
+ padding: 0 20px;
541
+ white-space: nowrap
542
+ }
543
+ .row table.audits tr {
544
+ border-top: 1px solid #e4e5e6;
545
+ }
546
+ .row table.audits tr {
547
+ background: white;
548
+ }
549
+ .row table.audits tr:nth-child(even) {
550
+ background: #fffff0;
551
+ }
552
+ .row table.audits tr:hover {
553
+ background: #add8e6;
554
+ }
555
+ .row table.audits tr:first-child {
556
+ border-top: none;
557
+ }
558
+ .row table.audits td {
559
+ text-align: right;
560
+ padding: 0 10px;
561
+ }
562
+ .row table.audits td:first-of-type {
563
+ text-align: left;
564
+ word-break: break-all;
565
+ }
566
+ .row table.audits td:not(:first-of-type) {
567
+ padding: 0 20px;
568
+ }
569
  .row table.stats tr {
570
  border-top: 1px solid #e4e5e6;
571
  }
577
  }
578
  .row table td.leftcol {
579
  text-align: left;
 
 
 
580
  padding: 0 0 0 12px;
581
  }
 
 
 
 
582
  .row.largest_improvement table.stats td.rightcol {
583
  width: 132px;
584
  text-align: center;
664
  .score_chart_div {
665
  width: 204px;
666
  height: 204px;
667
+ margin-top: 20px !important;
668
  background: url('../images/pagespeed_gauge.png');
669
  overflow: hidden;
670
  position: relative;
681
  -webkit-border-radius: 6px;
682
  -moz-border-radius: 6px;
683
  border-radius: 6px;
684
+ /*display: none;*/
685
  }
686
  .impact_rule_report.images {
687
  background: #e2faff;
755
  text-transform: uppercase;
756
  line-height: 12px;
757
  }
758
+ #FCP, #FID, #avg_lab_data {
759
+ width: 100%;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
760
  }
761
+ .chart_data {
762
+ padding: 0 12px;
763
+ height: 213px;
764
  }
765
  table.error_logs p {
766
  margin-bottom: 0;
831
  width: 0px;
832
  }
833
 
834
+ .crc, .crc ul, .crc li {
835
+ position: relative;
836
+ }
837
+
838
+ .crc ul {
839
+ list-style: none;
840
+ padding-left: 32px;
841
+ }
842
+ .crc li::before, .crc li::after {
843
+ content: "";
844
+ position: absolute;
845
+ left: -12px;
846
+ }
847
+ .crc li::before {
848
+ border-top: 1px solid #000;
849
+ top: 9px;
850
+ width: 8px;
851
+ height: 0;
852
+ }
853
+ .crc li::after {
854
+ border-left: 1px solid #000;
855
+ height: 100%;
856
+ width: 0px;
857
+ top: 2px;
858
+ }
859
+ .crc ul > li:last-child::after {
860
+ height: 8px;
861
+ }
862
+
863
  @keyframes ellipsis {
864
  to {
865
  width: 1em;
assets/js/details.js CHANGED
@@ -23,171 +23,160 @@
23
 
24
  $('#score_text .score').text( GPI_Details.page_stats.score );
25
 
26
- $('#pagespeed_stats_wrapper .last_checked .rightcol').text( GPI_Details.page_stats.last_modified );
27
 
28
  if ( '1.0' != dataVersion ) {
29
  var page_statistics = wp.template( 'statistics' );
30
- $.each( GPI_Details.page_stats.resources, function ( index, value ) {
31
- if ( 'resource_sizes' == index ) {
32
- return;
33
- }
34
  var data = {
35
- label : GPI_Details.strings[ index ],
36
- value : value
 
37
  };
38
 
39
- $('#pagespeed_stats_wrapper .stats').append( page_statistics( data ) );
40
  });
41
  }
42
 
43
- var legend = wp.template( 'legend' );
44
- var color_array = [ '#3366cc', '#dc3912', '#ff9900', '#109618', '#990099', '#0099c6', '#dd4477', '#66aa00', '#b82e2e', '#316395', '#994499', '#22aa99', '#aaaa11', '#6633cc', '#e67300', '#8b0707', '#651067', '#329262', '#5574a6', '#3b3eac', '#b77322', '#16d620', '#b91383', '#f4359e', '#9c5935', '#a9c413', '#2a778d', '#668d1c', '#bea413', '#0c5922', '#743411' ];
45
- $.each( GPI_Details.page_reports, function ( index, values ) {
46
- var data = {
47
- rule_key : values.rule_key,
48
- rule_name : values.rule_name,
49
- color : color_array[ index ],
50
- index : index
51
- };
52
-
53
- $('#impact_chart_legend tbody').append( legend( data ) );
54
- });
55
-
56
- });
57
-
58
- google.charts.load('current', {'packages':['corechart']});
59
- google.charts.setOnLoadCallback(drawCharts);
60
-
61
- function drawCharts() {
62
-
63
- /***********************************************
64
- Create resource size bar chart
65
- ************************************************/
66
-
67
- if ( GPI_Details.page_stats.resources != null && '1.0' != dataVersion ) {
68
- var sizes = new google.visualization.DataTable();
69
- sizes.addColumn('string', 'Resource Type');
70
- sizes.addColumn('number', 'kB');
 
 
 
 
71
 
72
- $.each( GPI_Details.page_stats.resources.resource_sizes, function ( index, value ) {
73
- var data = [ index, Number( value ) ];
74
- sizes.addRow( data );
75
  });
76
 
77
- var sizes_options = {
78
- 'legend' : 'none',
79
- 'backgroundColor' : 'transparent',
80
- 'chartArea' : { top: 10, width: '75%', height: '80%' }
81
- };
82
-
83
- var sizes_chart = new google.visualization.BarChart(document.getElementById('sizes_chart_div'));
84
- sizes_chart.draw(sizes, sizes_options);
85
- }
86
 
87
- /***********************************************
88
- Create impact pie chart
89
- ************************************************/
90
 
91
- var impact = new google.visualization.DataTable();
92
- impact.addColumn( 'string', 'Rule' );
93
- impact.addColumn( 'number', 'Impact' );
94
- $.each( GPI_Details.page_reports, function ( index, values ) {
95
- var data = [ values.rule_name, Number( values.rule_impact ) ];
96
- impact.addRow( data );
97
- });
98
 
99
- var impact_options = {
100
- 'width' : 463,
101
- 'height' : 320,
102
- 'chartArea' : { top: 15, width: '85%', height: '91%' },
103
- 'legend' : 'none',
104
- 'tooltip' : { trigger: 'none' },
105
- 'backgroundColor' :'transparent',
106
- 'colors' : [ '#3366cc', '#dc3912', '#ff9900', '#109618', '#990099', '#0099c6', '#dd4477', '#66aa00', '#b82e2e', '#316395', '#994499', '#22aa99', '#aaaa11', '#6633cc', '#e67300', '#8b0707', '#651067', '#329262', '#5574a6', '#3b3eac', '#b77322', '#16d620', '#b91383', '#f4359e', '#9c5935', '#a9c413', '#2a778d', '#668d1c', '#bea413', '#0c5922', '#743411' ],
107
- 'pieSliceTextStyle' : { color: 'white', fontSize: 14 }
108
- };
109
 
110
- var impact_chart = new google.visualization.PieChart( document.getElementById('impact_chart_div') );
111
- impact_chart.draw( impact, impact_options );
 
112
 
113
- if ( '1.0' != dataVersion ) {
114
- google.visualization.events.addListener( impact_chart, 'select', impactSelectHandler );
115
- google.visualization.events.addListener( impact_chart, 'onmouseover', highlightHover );
116
- google.visualization.events.addListener( impact_chart, 'onmouseout', clearHover );
 
 
117
  }
 
118
 
119
- function impactSelectHandler() {
120
- var selected = impact_chart.getSelection();
121
-
122
- if ( 'undefined' != typeof selected[0] ) {
123
- var ruleindex = selected[0].row;
124
- var rule_object = GPI_Details.page_reports[ ruleindex ];
125
- rule_object.rule_blocks.impact = rule_object.rule_impact;
126
- rule_object.rule_blocks.score_impact_string = GPI_Details.strings.score_impact;
127
-
128
- var rule_blocks = wp.template( 'rule_blocks' );
129
- var block_html = rule_blocks( rule_object.rule_blocks );
130
 
131
- $('.impact_chart_right tr').removeClass('active');
132
- $('#optimize_images').hide();
133
- $('.impact_chart_right tr a[data-pieslice=' + ruleindex + ']').closest('tr').addClass('active');
134
- if ( "OptimizeImages" == $('.impact_chart_right tr a[data-pieslice=' + ruleindex + ']').data('rulekey') ) {
135
- $('#optimize_images').show();
136
- }
137
 
138
- $('#impact_rule_report').css('display', 'block');
139
- $('#impact_rule_report').html( block_html );
140
- clearHover();
141
- } else {
142
- $('#impact_rule_report').css( 'display', 'none' );
143
- $('#impact_rule_report').html('');
144
- $('.impact_chart_right tr').removeClass('active');
145
- $('#optimize_images').hide();
 
 
 
 
 
 
 
 
146
  }
147
- }
148
-
149
- function highlightHover( e ) {
150
- var current = $('.impact_chart_right tr a[data-pieslice=' + e.row + ']');
151
 
152
- $('.impact_chart_right tr').removeClass('hover');
153
-
154
- if ( ! current.closest('tr').hasClass('active') ) {
155
- current.closest('tr').addClass('hover');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  }
157
- }
158
-
159
- function clearHover() {
160
- $('.impact_chart_right tr').removeClass('hover');
161
- }
162
 
163
- $('.legend-item').on( 'click', function() {
164
- var tr = $( this ).closest('tr');
165
-
166
- if ( tr.hasClass('active') ) {
167
- impact_chart.setSelection( false );
168
- $('#optimize_images').hide();
169
- } else {
170
- impact_chart.setSelection( [ { row: $( this ).data('pieslice') } ] );
171
- $('#optimize_images').hide();
172
- if ( "OptimizeImages" == $(this).data('rulekey') ) {
173
- $('#optimize_images').show();
174
- }
175
- }
176
-
177
- impactSelectHandler();
178
  });
179
  }
180
 
181
- $(document).on({
182
- mouseenter: function () {
183
- $( this ).stop().animate({
184
- textIndent: '-' + ( $( this ).width() - $( this ).parent().width() ) + 'px'
185
- }, 1000);
186
- },
187
- mouseleave: function () {
188
- $( this ).stop().animate({
189
- textIndent: '0'
190
- }, 1000); }
191
- }, '.impact_chart_right a');
192
 
193
  })( jQuery );
23
 
24
  $('#score_text .score').text( GPI_Details.page_stats.score );
25
 
26
+ $('#pagespeed_lab_data_wrapper .last_checked .rightcol').text( GPI_Details.page_stats.last_modified );
27
 
28
  if ( '1.0' != dataVersion ) {
29
  var page_statistics = wp.template( 'statistics' );
30
+ $.each( GPI_Details.page_stats.labData, function ( index, stat ) {
 
 
 
31
  var data = {
32
+ label : stat.title,
33
+ value : stat.displayValue,
34
+ description : stat.description
35
  };
36
 
37
+ $('#pagespeed_lab_data_wrapper .stats tbody').append( page_statistics( data ) );
38
  });
39
  }
40
 
41
+ if ( '3.0' < dataVersion ) {
42
+ var passedAudits = 0,
43
+ hasScreenshots = false;
44
+ $.each( GPI_Details.page_reports, function ( index, audit ) {
45
+ var type = audit.rule_blocks.details.type,
46
+ mode = audit.rule_blocks.score_display_mode,
47
+ data = {
48
+ key : audit.rule_key,
49
+ name : audit.rule_name,
50
+ description : audit.rule_blocks.description,
51
+ details : audit.rule_blocks.details,
52
+ displayValue : audit.rule_blocks.display_value,
53
+ type : type,
54
+ strings : GPI_Details.strings,
55
+ publicPath : GPI_Details.public_path
56
+ };
57
+
58
+ var audits = wp.template( 'audits-' + type );
59
+
60
+ if ( 'screenshot-thumbnails' == audit.rule_key ) {
61
+ $('#screenshots').append( audits( data ) );
62
+ hasScreenshots = true;
63
+ } else if ( 'opportunity' == type && 0.9 > audit.rule_score ) {
64
+ $('#opportunities').append( audits( data ) );
65
+ } else if ( 'opportunity' != type && 0.9 > audit.rule_score ) {
66
+ $('#diagnostics').append( audits( data ) );
67
+ } else if ( 'informative' == mode || 'not_applicable' == mode ) {
68
+ $('#diagnostics').append( audits( data ) );
69
+ } else {
70
+ $('#passed_audits').append( audits( data ) );
71
+ passedAudits++;
72
+ }
73
 
 
 
 
74
  });
75
 
76
+ if ( ! $('#opportunities').children().length ) {
77
+ $('.row.opportunities').hide();
78
+ }
 
 
 
 
 
 
79
 
80
+ if ( ! $('#diagnostics').children().length ) {
81
+ $('.row.diagnostics').hide();
82
+ }
83
 
84
+ if ( ! $('#passed_audits').children().length ) {
85
+ $('.row.passed-audits').hide();
86
+ }
 
 
 
 
87
 
88
+ $('#passed_audits_count').text( passedAudits );
 
 
 
 
 
 
 
 
 
89
 
90
+ if ( ! hasScreenshots ) {
91
+ $('.row.screenshots').hide();
92
+ }
93
 
94
+ $('.accordion').accordion({
95
+ 'animate' : 50,
96
+ 'heightStyle' : 'content',
97
+ 'collapsible' : true,
98
+ 'active' : false
99
+ });
100
  }
101
+ });
102
 
103
+ google.charts.load( 'current', {
104
+ packages: ['corechart']
105
+ } );
106
+ if ( 'undefined' !== typeof GPI_Details.page_stats.fieldData.FIRST_CONTENTFUL_PAINT_MS && 'undefined' !== typeof GPI_Details.page_stats.fieldData.FIRST_INPUT_DELAY_MS ) {
107
+ google.charts.setOnLoadCallback( fieldData );
108
+ } else {
109
+ $('#pagespeed_field_data_wrapper .chart_data').html('<p>' + GPI_Details.strings.insufficient_field_data + '</p>');
110
+ }
 
 
 
111
 
112
+ function fieldData() {
113
+ drawBarChart( 'FCP', 'FIRST_CONTENTFUL_PAINT_MS' );
114
+ drawBarChart( 'FID', 'FIRST_INPUT_DELAY_MS' );
115
+ }
 
 
116
 
117
+ function drawBarChart( type, key ) {
118
+ var data = [type];
119
+ $.each( GPI_Details.page_stats.fieldData[ key ].distributions, function( index, array ) {
120
+ var proportion = array['proportion'] * 100,
121
+ proportion = +(proportion.toFixed(2)),
122
+ prettyProportion = proportion + '%',
123
+ min = array['min'] / 1000,
124
+ max = typeof array['max'] != 'undefined' ? array['max'] / 1000 : false,
125
+ minmax_label = false;
126
+
127
+ if ( 0 == index ) {
128
+ minmax_label = ' (< ' + max + ' s) ';
129
+ } else if ( 1 == index ) {
130
+ minmax_label = ' (' + min + ' s ~ ' + max + ' s) ';
131
+ } else if ( 2 == index ) {
132
+ minmax_label = ' (> ' + min + ' s) ';
133
  }
 
 
 
 
134
 
135
+ data.push( array['proportion'] );
136
+ data.push( prettyProportion );
137
+ data.push( prettyProportion + ' ' + GPI_Details.strings.field_data_labels[ index ] + minmax_label + GPI_Details.strings[ type ] + ' ('+ type +')' );
138
+ } );
139
+
140
+ var chartdata = google.visualization.arrayToDataTable([
141
+ [ 'category', 'Fast', { role: 'annotation' }, { type: 'string', role: 'tooltip' }, 'Average', { role: 'annotation' }, { type: 'string', role: 'tooltip' }, 'Slow', { role: 'annotation' }, { type: 'string', role: 'tooltip' } ],
142
+ data
143
+ ]);
144
+
145
+
146
+ var view = new google.visualization.DataView( chartdata );
147
+ var options = {
148
+ title : GPI_Details.strings[ type ] + ' (' + type + ')',
149
+ isStacked : true,
150
+ height : 112.5,
151
+ legend : {position: 'none'},
152
+ colors : ['#178239','#e67700','#c7221f'],
153
+ backgroundColor : 'transparent',
154
+ chartArea : {
155
+ top : 30,
156
+ left : 0,
157
+ width : '100%',
158
+ },
159
+ vAxis : {
160
+ textPosition : 'none'
161
+ },
162
+ hAxis : {
163
+ baselineColor : 'transparent',
164
+ textPosition : 'none'
165
  }
166
+ };
167
+ var chart = new google.visualization.BarChart( document.getElementById( type ) );
168
+ chart.draw( view, options );
 
 
169
 
170
+ $(window).on('resizeEnd', function() {
171
+ chart.draw( view, options );
 
 
 
 
 
 
 
 
 
 
 
 
 
172
  });
173
  }
174
 
175
+ $( window ).resize(function() {
176
+ if ( this.resizeTO ) clearTimeout( this.resizeTO );
177
+ this.resizeTO = setTimeout( function() {
178
+ $(this).trigger('resizeEnd');
179
+ }, 500);
180
+ });
 
 
 
 
 
181
 
182
  })( jQuery );
assets/js/global.js CHANGED
@@ -20,7 +20,32 @@
20
  wp.heartbeat.interval( 'fast' );
21
  }
22
 
23
- $(document).tooltip();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
  $(document).ready( function() {
26
  $('#recheck_all_pages').on( 'change', function() {
@@ -56,6 +81,7 @@
56
  $('#gpi_status_ajax').hide();
57
  $('#gpi_status_abort').show();
58
  } else {
 
59
  $('#gpi_status_ajax').removeClass('ellipsis').html('<div class="loading_bar_shell"><div class="reportscore_outter_bar"><div class="reportscore_inner_bar" style="width:' + status + '%;"></div></div><span>' + status + '%</span></div>');
60
  }
61
  });
20
  wp.heartbeat.interval( 'fast' );
21
  }
22
 
23
+ $(document).tooltip({
24
+ hide : 500,
25
+ show : 200,
26
+ position : { my: "left+20px top", at: "left bottom", collision: "flipfit" },
27
+ tooltipClass : 'pos-absolute',
28
+ content : function () {
29
+ return $(this).prop('title');
30
+ },
31
+ open: function( event, ui ) {
32
+ if ( typeof( event.originalEvent ) === 'undefined') {
33
+ return false;
34
+ }
35
+
36
+ var $id = $(ui.tooltip).attr('id');
37
+ $('div.ui-tooltip').not('#' + $id).remove();
38
+ },
39
+ close: function( event, ui ) {
40
+ ui.tooltip.hover( function() {
41
+ $(this).stop(true).fadeTo(400, 1);
42
+ }, function() {
43
+ $(this).fadeOut('400', function() {
44
+ $(this).remove();
45
+ });
46
+ });
47
+ }
48
+ });
49
 
50
  $(document).ready( function() {
51
  $('#recheck_all_pages').on( 'change', function() {
81
  $('#gpi_status_ajax').hide();
82
  $('#gpi_status_abort').show();
83
  } else {
84
+ $('#gpi_status_ajax').prop( 'title', data['gpi_progress_tooltip'] );
85
  $('#gpi_status_ajax').removeClass('ellipsis').html('<div class="loading_bar_shell"><div class="reportscore_outter_bar"><div class="reportscore_inner_bar" style="width:' + status + '%;"></div></div><span>' + status + '%</span></div>');
86
  }
87
  });
assets/js/summary.js CHANGED
@@ -1,9 +1,9 @@
1
  ( function( $ ) {
2
 
3
- if ( GPI_Summary.snapshot ) {
4
- GPI_Summary.summary_stats = JSON.parse( GPI_Summary.summary_stats );
5
- GPI_Summary.summary_reports = JSON.parse( GPI_Summary.summary_reports );
6
- }
7
 
8
  var no_results = $.isEmptyObject( GPI_Summary.summary_stats );
9
  var dataVersion;
@@ -31,7 +31,7 @@
31
  $.each( GPI_Summary.summary_reports, function ( index, values ) {
32
  var data = {
33
  rule_name : values.rule_name,
34
- avg_impact : values.avg_impact,
35
  occurances : values.occurances
36
  };
37
 
@@ -58,75 +58,6 @@
58
  $('#lowest_scores .stats').append( scores( data ) );
59
  });
60
  });
61
-
62
- google.charts.load('current', {'packages':['corechart']});
63
- google.charts.setOnLoadCallback(drawCharts);
64
-
65
- function drawCharts() {
66
-
67
- /***********************************************
68
- Create resource size bar chart
69
- ************************************************/
70
-
71
- if ( '1.0' != dataVersion ) {
72
- var sizes = new google.visualization.DataTable();
73
- sizes.addColumn('string', GPI_Summary.strings.resource_type);
74
- sizes.addColumn('number', GPI_Summary.strings.high, 'highest');
75
- sizes.addColumn('number', GPI_Summary.strings.average, 'average');
76
- sizes.addColumn('number', GPI_Summary.strings.low, 'lowest');
77
-
78
- $.each( GPI_Summary.summary_stats.resource_sizes, function ( index, values ) {
79
- var data = [ index, Number( values.highest.value ), Number( values.average ), Number( values.lowest.value ) ];
80
- sizes.addRow( data );
81
- });
82
-
83
- var sizes_options = {
84
- legend : 'none',
85
- backgroundColor : 'transparent',
86
- width : 615,
87
- height : 200,
88
- tooltip : { trigger: 'selection' },
89
- chartArea : { top: 10, width: '80%', height: '80%' }
90
- };
91
-
92
- var sizes_chart = new google.visualization.BarChart(document.getElementById('sizes_chart_div'));
93
- sizes_chart.draw(sizes, sizes_options);
94
-
95
- sizes_chart.setAction({
96
- id : 'view_report',
97
- text : GPI_Summary.strings.view_page_report,
98
- action : function() {
99
- selection = sizes_chart.getSelection();
100
- column_id = sizes.getColumnId( selection[0].column );
101
-
102
- if ( 'average' == column_id ) {
103
- return;
104
- }
105
-
106
- index = sizes.getValue( selection[0].row, 0 );
107
- report_url = GPI_Summary.summary_stats.resource_sizes[ index ][ column_id ].url;
108
-
109
- var win = window.open( report_url, '_self' );
110
- win.focus();
111
- },
112
- visible: function () {
113
- selection = sizes_chart.getSelection();
114
-
115
- if ( selection.length < 1 ) {
116
- return false;
117
- }
118
-
119
- column_id = sizes.getColumnId( selection[0].column );
120
-
121
- if ( 'average' == column_id ) {
122
- return false;
123
- } else {
124
- return true;
125
- }
126
- },
127
- });
128
- }
129
- }
130
  } else {
131
  $( document ).ready( function() {
132
  $('#results').hide();
@@ -134,4 +65,142 @@
134
  });
135
  }
136
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
  })( jQuery );
1
  ( function( $ ) {
2
 
3
+ // if ( GPI_Summary.snapshot ) {
4
+ // GPI_Summary.summary_stats = JSON.parse( GPI_Summary.summary_stats );
5
+ // GPI_Summary.summary_reports = JSON.parse( GPI_Summary.summary_reports );
6
+ // }
7
 
8
  var no_results = $.isEmptyObject( GPI_Summary.summary_stats );
9
  var dataVersion;
31
  $.each( GPI_Summary.summary_reports, function ( index, values ) {
32
  var data = {
33
  rule_name : values.rule_name,
34
+ avg_score : Math.round( values.avg_score ),
35
  occurances : values.occurances
36
  };
37
 
58
  $('#lowest_scores .stats').append( scores( data ) );
59
  });
60
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  } else {
62
  $( document ).ready( function() {
63
  $('#results').hide();
65
  });
66
  }
67
 
68
+ google.charts.load( 'current', {
69
+ packages: ['corechart']
70
+ } );
71
+ google.charts.setOnLoadCallback( avgLabData );
72
+
73
+ function avgLabData() {
74
+ var data = new google.visualization.DataTable();
75
+
76
+ data.addColumn({
77
+ type : 'string',
78
+ label : 'Category'
79
+ });
80
+ data.addColumn({
81
+ type : 'number',
82
+ label : GPI_Summary.strings.average_score
83
+ });
84
+ data.addColumn({
85
+ type : 'string',
86
+ role : 'annotation'
87
+ })
88
+
89
+ $.each( GPI_Summary.summary_stats.labData, function( index, array ) {
90
+ var score = array['average'] * 100,
91
+ score = +(score.toFixed(2)),
92
+ prettyScore = score + '%',
93
+ row = [ index, { v: array['average'], f: prettyScore }, prettyScore ];
94
+
95
+ data.addRow( row );
96
+ } );
97
+
98
+ var view = new google.visualization.DataView( data );
99
+
100
+ view.setColumns( [0, 1, 2, {
101
+ calc : function ( dt, row ) {
102
+ if ( ( dt.getValue( row, 1 ) >= 0 ) && ( dt.getValue( row, 1 ) <= 0.49 ) ) {
103
+ return '#c7221f';
104
+ } else if ( ( dt.getValue( row, 1 ) > 0.49 ) && ( dt.getValue( row, 1 ) <= 0.90 ) ) {
105
+ return '#e67700';
106
+ } else {
107
+ return '#178239';
108
+ }
109
+ },
110
+ type : 'string',
111
+ role : 'style'
112
+ }]);
113
+
114
+ var options = {
115
+ legend : { position: 'none' },
116
+ colors : ['#178239','#e67700','#c7221f'],
117
+ backgroundColor : '#f1f1f1',
118
+ height : '223',
119
+ tooltip : { trigger: 'selection' },
120
+ annotations : { alwaysOutside: false },
121
+ chartArea : {
122
+ left : 150,
123
+ top : 0,
124
+ width : '100%',
125
+ height : '100%'
126
+ },
127
+ vAxis : {
128
+ textPosition: 'out',
129
+ textStyle : {
130
+ fontSize : 11
131
+ }
132
+ },
133
+ hAxis : {
134
+ format : 'percent',
135
+ minValue : 0,
136
+ maxValue : 1,
137
+ ticks : [0, .1, .2, .3, .4, .5, .6, .7, .8, .9, 1],
138
+ textPosition : 'none'
139
+ }
140
+ };
141
+ var chart = new google.visualization.BarChart( document.getElementById('avg_lab_data') );
142
+ chart.draw( view, options );
143
+
144
+ chart.setAction({
145
+ id : 'view_highest',
146
+ text : GPI_Summary.strings.best_performing,
147
+ action : function() {
148
+ selection = chart.getSelection();
149
+ index = view.getValue( selection[0].row, 0 );
150
+
151
+ report_url = GPI_Summary.summary_stats.labData[ index ].highest.url;
152
+
153
+ var win = window.open( report_url, '_self' );
154
+ win.focus();
155
+ }
156
+ });
157
+ chart.setAction({
158
+ id : 'view_lowest',
159
+ text : GPI_Summary.strings.worst_performing,
160
+ action : function() {
161
+ selection = chart.getSelection();
162
+ index = view.getValue( selection[0].row, 0 );
163
+
164
+ report_url = GPI_Summary.summary_stats.labData[ index ].lowest.url;
165
+
166
+ var win = window.open( report_url, '_self' );
167
+ win.focus();
168
+ }
169
+ });
170
+
171
+ google.visualization.events.addListener( chart, 'select', annotationSelectHandler );
172
+
173
+ lastSelection = false;
174
+ function annotationSelectHandler() {
175
+ if ( typeof chart.getSelection()[0] != 'undefined' ) {
176
+ var selectedItem = chart.getSelection()[0];
177
+
178
+ if ( 2 == selectedItem.column ) {
179
+ if ( lastSelection && lastSelection.row == selectedItem.row ) {
180
+ chart.setSelection([]);
181
+ lastSelection = false;
182
+ } else {
183
+ chart.setSelection([{row:selectedItem.row, column:1}]);
184
+ lastSelection = selectedItem;
185
+ }
186
+ } else {
187
+ lastSelection = selectedItem;
188
+ }
189
+ } else {
190
+ lastSelection = false;
191
+ }
192
+ }
193
+
194
+ $(window).on('gpiResizeEnd', function() {
195
+ chart.draw( view, options );
196
+ });
197
+ }
198
+
199
+ $( window ).resize(function() {
200
+ if ( this.resizeTO ) clearTimeout( this.resizeTO );
201
+ this.resizeTO = setTimeout( function() {
202
+ $(this).trigger('gpiResizeEnd');
203
+ }, 500);
204
+ });
205
+
206
  })( jQuery );
assets/js/templates/details/audits-criticalrequestchain.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script type="text/html" id="tmpl-audits-criticalrequestchain">
2
+ <h3>{{data.name}} <span class="right">{{data.displayValue}}</span></h3>
3
+ <div class="details">
4
+ <p class="description">
5
+ {{{data.description}}}
6
+ </p>
7
+ <div class="crc">
8
+ <ul>
9
+ <#
10
+ for ( var chain in data.details.chains ) {
11
+ outputChain( data.details.chains[ chain ], false );
12
+ }
13
+
14
+ function outputChain( chain, subchain ) {
15
+ if ( ! subchain ) {
16
+ #>
17
+ <li>
18
+ <span class="url">{{chain.request.url}}</span>
19
+ <span class="size">{{chain.request.transferSize}}</span>
20
+ <#
21
+ if ( 'undefined' != typeof chain.children ) {
22
+ outputChain( chain.children, true );
23
+ }
24
+ #>
25
+ </li>
26
+ <#
27
+ } else {
28
+ for ( var newChain in chain ) {
29
+ #>
30
+ <ul>
31
+ <li>
32
+ <span class="url">{{chain[ newChain ].request.url}}</span>
33
+ <span class="size">{{chain[ newChain ].request.transferSize}}</span>
34
+ <#
35
+ if ( 'undefined' != typeof chain[ newChain ].children ) {
36
+ outputChain( chain[ newChain ].children, true );
37
+ }
38
+ #>
39
+ </li>
40
+ </ul>
41
+ <#
42
+ }
43
+ }
44
+ }
45
+ #>
46
+ </ul>
47
+ </div>
48
+ </div>
49
+ </script>
assets/js/templates/details/audits-filmstrip.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <script type="text/html" id="tmpl-audits-filmstrip">
2
+ <p class="description">{{{data.description}}}</p>
3
+ <div class="details">
4
+ <# for (i = 0; i < data.details.items.length; i++ ) { #>
5
+ <div><img src="data:image/png;base64, {{data.details.items[ i ].data}}" title="{{data.details.items[ i ].timing}} ms" alt="{{data.details.items[ i ].timing}} ms" /></div>
6
+ <# } #>
7
+ </div>
8
+ </script>
assets/js/templates/details/audits-opportunity.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script type="text/html" id="tmpl-audits-opportunity">
2
+ <h3>{{data.name}} <span class="right">{{data.displayValue}}</span></h3>
3
+ <div class="details">
4
+ <p class="description">
5
+ {{{data.description}}}
6
+ </p>
7
+ <# if ( 'uses-optimized-images' == data.key ) { #>
8
+ <div class="impact_rule_report images" id="optimize_images">
9
+ <img class="shortpixel_robot" src="{{data.publicPath}}/assets/images/shortpixel.png" alt="{{data.strings.shortpixel.title}}" />
10
+ <h2>{{data.strings.shortpixel.title}}</h2>
11
+ <p>{{{data.strings.shortpixel.description}}}</p>
12
+ <p>{{{data.strings.shortpixel.signup_desc}}}</p>
13
+ <a class="shortpixel_btn" href="https://shortpixel.com/h/af/PCFTWNN142247" target="_blank">{{data.strings.shortpixel.signup_btn}}</a>
14
+ </div>
15
+ <# } #>
16
+ <table class="audits">
17
+ <thead>
18
+ <tr>
19
+ <# var keys = []; #>
20
+ <# for (i = 0; i < data.details.headings.length; i++ ) { #>
21
+ <# if ( typeof data.details.headings[ i ].label != 'undefined' ) { #>
22
+ <th class="{{data.details.headings[ i ].key}}">{{data.details.headings[ i ].label}}</th>
23
+ <# keys.push( data.details.headings[ i ].key ); #>
24
+ <# } #>
25
+ <# } #>
26
+ </tr>
27
+ </thead>
28
+ <tbody>
29
+ <# for (i = 0; i < data.details.items.length; i++ ) { #>
30
+ <tr>
31
+ <# for (x = 0; x < keys.length; x++ ) {
32
+ if ( 'url' == keys[ x ] ) {
33
+ #>
34
+ <td class="{{keys[ x ]}}">{{{data.details.items[ i ][keys[ x ]]}}}</td>
35
+ <#
36
+ } else {
37
+ #>
38
+ <td class="{{keys[ x ]}}">{{data.details.items[ i ][keys[ x ]]}}</td>
39
+ <#
40
+ }
41
+ } #>
42
+ </tr>
43
+ <# } #>
44
+ </tbody>
45
+ </table>
46
+ </div>
47
+ </script>
assets/js/templates/details/audits-table.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script type="text/html" id="tmpl-audits-table">
2
+ <h3>{{data.name}} <span class="right">{{data.displayValue}}</span></h3>
3
+ <div class="details">
4
+ <p class="description">
5
+ {{{data.description}}}
6
+ </p>
7
+ <table class="audits">
8
+ <thead>
9
+ <tr>
10
+ <# var keys = []; #>
11
+ <# for (i = 0; i < data.details.headings.length; i++ ) { #>
12
+ <# if ( typeof data.details.headings[ i ].text != 'undefined' ) { #>
13
+ <th class="{{data.details.headings[ i ].key}}">{{data.details.headings[ i ].text}}</th>
14
+ <# keys.push( data.details.headings[ i ].key ); #>
15
+ <# } #>
16
+ <# } #>
17
+ </tr>
18
+ </thead>
19
+ <tbody>
20
+ <# for (i = 0; i < data.details.items.length; i++ ) { #>
21
+ <tr>
22
+ <# for (x = 0; x < keys.length; x++ ) {
23
+ if ( 'object' == typeof data.details.items[ i ][keys[ x ]] ) {
24
+ if ( 'url' == keys[ x ] ) {
25
+ #>
26
+ <td class="{{keys[ x ]}}">{{{data.details.items[ i ][keys[ x ]].value}}}</td>
27
+ <#
28
+ } else {
29
+ #>
30
+ <td class="{{keys[ x ]}}">{{data.details.items[ i ][keys[ x ]].value}}</td>
31
+ <#
32
+ }
33
+ } else {
34
+ if ( 'url' == keys[ x ] ) {
35
+ #>
36
+ <td class="{{keys[ x ]}}">{{{data.details.items[ i ][keys[ x ]]}}}</td>
37
+ <#
38
+ } else {
39
+ #>
40
+ <td class="{{keys[ x ]}}">{{data.details.items[ i ][keys[ x ]]}}</td>
41
+ <#
42
+ }
43
+ }
44
+ } #>
45
+ </tr>
46
+ <# } #>
47
+ </tbody>
48
+ </table>
49
+ </div>
50
+ </script>
assets/js/templates/details/rule_blocks.php CHANGED
@@ -1,5 +1,5 @@
1
  <script type="text/html" id="tmpl-rule_blocks">
2
- <h3>{{data.score_impact_string}}: {{data.impact}}</h3>
3
 
4
  <# for (i = 0; i < data.length; i++ ) { #>
5
  <h3>{{{data[ i ].header}}}</h3>
1
  <script type="text/html" id="tmpl-rule_blocks">
2
+ <h3>{{data.score_impact_string}}: {{data.score}}</h3>
3
 
4
  <# for (i = 0; i < data.length; i++ ) { #>
5
  <h3>{{{data[ i ].header}}}</h3>
assets/js/templates/details/statistics.php CHANGED
@@ -1,5 +1,5 @@
1
  <script type="text/html" id="tmpl-statistics">
2
- <tr>
3
  <td class="leftcol">{{data.label}}</td>
4
  <td class="rightcol">
5
  <# if ( data.value ) { #>
1
  <script type="text/html" id="tmpl-statistics">
2
+ <tr title="{{data.description}}">
3
  <td class="leftcol">{{data.label}}</td>
4
  <td class="rightcol">
5
  <# if ( data.value ) { #>
assets/js/templates/summary/areas_of_improvement.php CHANGED
@@ -1,7 +1,7 @@
1
  <script type="text/html" id="tmpl-areas_of_improvement">
2
  <tr>
3
  <td class="leftcol">{{{data.rule_name}}}</td>
4
- <td class="rightcol">{{data.avg_impact}}</td>
5
  <td class="rightcol">{{data.occurances}}</td>
6
  </tr>
7
  </script>
1
  <script type="text/html" id="tmpl-areas_of_improvement">
2
  <tr>
3
  <td class="leftcol">{{{data.rule_name}}}</td>
4
+ <td class="rightcol">{{data.avg_score}}%</td>
5
  <td class="rightcol">{{data.occurances}}</td>
6
  </tr>
7
  </script>
assets/js/view-snapshot.js CHANGED
@@ -8,7 +8,6 @@
8
  GPI_View_Snapshot.compare.summary_reports = JSON.parse( GPI_View_Snapshot.compare.summary_reports );
9
  }
10
 
11
-
12
  $( document ).ready( function() {
13
  if ( GPI_View_Snapshot.comments.snapshot ) {
14
  $('.comment[data-selector="snapshot"]').html( '<strong>' + GPI_View_Snapshot.strings.comment + ':</strong>' + GPI_View_Snapshot.comments.snapshot );
@@ -44,7 +43,7 @@
44
  $.each( GPI_View_Snapshot[ selector ].summary_reports, function ( index, values ) {
45
  var data = {
46
  rule_name : values.rule_name,
47
- avg_impact : values.avg_impact,
48
  occurances : values.occurances
49
  };
50
 
@@ -84,75 +83,235 @@
84
 
85
  });
86
 
87
- google.charts.load('current', {'packages':['corechart']});
88
- google.charts.setOnLoadCallback(drawCharts);
89
-
90
- function drawCharts() {
91
 
92
- /***********************************************
93
- Create resource size bar chart
94
- ************************************************/
 
95
 
96
- $('.sizes_chart_div').each( function() {
97
- var selector = $(this).data('selector');
98
- var sizes = new google.visualization.DataTable();
99
- sizes.addColumn('string', 'Resource Type');
100
- sizes.addColumn('number', 'High', 'highest');
101
- sizes.addColumn('number', 'Average', 'average');
102
- sizes.addColumn('number', 'Low', 'lowest');
103
-
104
- $.each( GPI_View_Snapshot[ selector ].summary_stats.resource_sizes, function ( index, values ) {
105
- var data = [ index, Number( values.highest.value ), Number( values.average ), Number( values.lowest.value ) ];
106
- sizes.addRow( data );
107
  });
108
-
109
- var sizes_options = {
110
- legend : 'none',
111
- backgroundColor : 'transparent',
112
- width : 615,
113
- height : 200,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  tooltip : { trigger: 'selection' },
115
- chartArea : { top: 10, width: '80%', height: '80%' }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  };
 
 
117
 
118
- var sizes_chart = new google.visualization.BarChart( $(this)[0] );
119
- sizes_chart.draw(sizes, sizes_options);
120
-
121
- sizes_chart.setAction({
122
- id : 'view_report',
123
- text : 'View Page Report',
124
  action : function() {
125
- selection = sizes_chart.getSelection();
126
- column_id = sizes.getColumnId( selection[0].column );
127
 
128
- if ( 'average' == column_id ) {
129
- return;
130
- }
131
-
132
- index = sizes.getValue( selection[0].row, 0 );
133
- report_url = GPI_View_Snapshot[ selector ].summary_stats.resource_sizes[ index ][ column_id ].url;
134
 
135
- var win = window.open( report_url, '_blank' );
136
  win.focus();
137
- },
138
- visible: function () {
139
- selection = sizes_chart.getSelection();
 
 
 
 
 
140
 
141
- if ( selection.length < 1 ) {
142
- return false;
143
- }
144
 
145
- column_id = sizes.getColumnId( selection[0].column );
 
 
 
146
 
147
- if ( 'average' == column_id ) {
148
- return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
149
  } else {
150
- return true;
151
  }
152
- },
 
 
 
 
 
 
153
  });
154
  });
155
-
156
  }
157
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
  })( jQuery );
8
  GPI_View_Snapshot.compare.summary_reports = JSON.parse( GPI_View_Snapshot.compare.summary_reports );
9
  }
10
 
 
11
  $( document ).ready( function() {
12
  if ( GPI_View_Snapshot.comments.snapshot ) {
13
  $('.comment[data-selector="snapshot"]').html( '<strong>' + GPI_View_Snapshot.strings.comment + ':</strong>' + GPI_View_Snapshot.comments.snapshot );
43
  $.each( GPI_View_Snapshot[ selector ].summary_reports, function ( index, values ) {
44
  var data = {
45
  rule_name : values.rule_name,
46
+ avg_score : Math.round( values.avg_score ),
47
  occurances : values.occurances
48
  };
49
 
83
 
84
  });
85
 
86
+ google.charts.load( 'current', {
87
+ packages: ['corechart']
88
+ } );
89
+ google.charts.setOnLoadCallback( avgLabData );
90
 
91
+ function avgLabData() {
92
+ $('.avg_lab_data').each( function() {
93
+ var selector = $( this ).data('selector'),
94
+ data = new google.visualization.DataTable();
95
 
96
+ data.addColumn({
97
+ type : 'string',
98
+ label : 'Category'
 
 
 
 
 
 
 
 
99
  });
100
+ data.addColumn({
101
+ type : 'number',
102
+ label : GPI_View_Snapshot.strings.average_score
103
+ });
104
+ data.addColumn({
105
+ type : 'string',
106
+ role : 'annotation'
107
+ })
108
+
109
+ $.each( GPI_View_Snapshot[ selector ].summary_stats.labData, function( index, array ) {
110
+ var score = array['average'] * 100,
111
+ score = +(score.toFixed(2)),
112
+ prettyScore = score + '%',
113
+ row = [ index, { v: array['average'], f: prettyScore }, prettyScore ];
114
+
115
+ data.addRow( row );
116
+ } );
117
+
118
+ var view = new google.visualization.DataView( data );
119
+
120
+ view.setColumns( [0, 1, 2, {
121
+ calc : function ( dt, row ) {
122
+ if ( ( dt.getValue( row, 1 ) >= 0 ) && ( dt.getValue( row, 1 ) <= 0.49 ) ) {
123
+ return '#c7221f';
124
+ } else if ( ( dt.getValue( row, 1 ) > 0.49 ) && ( dt.getValue( row, 1 ) <= 0.90 ) ) {
125
+ return '#e67700';
126
+ } else {
127
+ return '#178239';
128
+ }
129
+ },
130
+ type : 'string',
131
+ role : 'style'
132
+ }]);
133
+
134
+ var options = {
135
+ legend : { position: 'none' },
136
+ colors : ['#178239','#e67700','#c7221f'],
137
+ backgroundColor : '#f1f1f1',
138
+ height : '213',
139
  tooltip : { trigger: 'selection' },
140
+ annotations : { alwaysOutside: false },
141
+ chartArea : {
142
+ left : 150,
143
+ top : 0,
144
+ width : '100%',
145
+ height : '100%'
146
+ },
147
+ vAxis : {
148
+ textPosition: 'out',
149
+ textStyle : {
150
+ fontSize : 11
151
+ }
152
+ },
153
+ hAxis : {
154
+ format : 'percent',
155
+ minValue : 0,
156
+ maxValue : 1,
157
+ ticks : [0, .1, .2, .3, .4, .5, .6, .7, .8, .9, 1],
158
+ textPosition : 'none'
159
+ }
160
  };
161
+ var chart = new google.visualization.BarChart( $(this)[0] );
162
+ chart.draw( view, options );
163
 
164
+ chart.setAction({
165
+ id : 'view_highest',
166
+ text : GPI_View_Snapshot.strings.best_performing,
 
 
 
167
  action : function() {
168
+ selection = chart.getSelection();
169
+ index = view.getValue( selection[0].row, 0 );
170
 
171
+ report_url = GPI_View_Snapshot[ selector ].summary_stats.labData[ index ].highest.url;
 
 
 
 
 
172
 
173
+ var win = window.open( report_url, '_self' );
174
  win.focus();
175
+ }
176
+ });
177
+ chart.setAction({
178
+ id : 'view_lowest',
179
+ text : GPI_View_Snapshot.strings.worst_performing,
180
+ action : function() {
181
+ selection = chart.getSelection();
182
+ index = view.getValue( selection[0].row, 0 );
183
 
184
+ report_url = GPI_View_Snapshot[ selector ].summary_stats.labData[ index ].lowest.url;
 
 
185
 
186
+ var win = window.open( report_url, '_self' );
187
+ win.focus();
188
+ }
189
+ });
190
 
191
+ google.visualization.events.addListener( chart, 'select', annotationSelectHandler );
192
+
193
+ lastSelection = false;
194
+ function annotationSelectHandler() {
195
+ if ( typeof chart.getSelection()[0] != 'undefined' ) {
196
+ var selectedItem = chart.getSelection()[0];
197
+
198
+ if ( 2 == selectedItem.column ) {
199
+ if ( lastSelection && lastSelection.row == selectedItem.row ) {
200
+ chart.setSelection([]);
201
+ lastSelection = false;
202
+ } else {
203
+ chart.setSelection([{row:selectedItem.row, column:1}]);
204
+ lastSelection = selectedItem;
205
+ }
206
  } else {
207
+ lastSelection = selectedItem;
208
  }
209
+ } else {
210
+ lastSelection = false;
211
+ }
212
+ }
213
+
214
+ $(window).on('gpiResizeEnd', function() {
215
+ chart.draw( view, options );
216
  });
217
  });
 
218
  }
219
 
220
+ $( window ).resize(function() {
221
+ if ( this.resizeTO ) clearTimeout( this.resizeTO );
222
+ this.resizeTO = setTimeout( function() {
223
+ $(this).trigger('gpiResizeEnd');
224
+ }, 500);
225
+ });
226
+
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+
235
+
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+
244
+
245
+
246
+ // google.charts.load('current', {'packages':['corechart']});
247
+ // google.charts.setOnLoadCallback(drawCharts);
248
+
249
+ // function drawCharts() {
250
+
251
+ // /***********************************************
252
+ // Create resource size bar chart
253
+ // ************************************************/
254
+
255
+ // $('.avg_lab_data').each( function() {
256
+ // var selector = $(this).data('selector');
257
+ // var sizes = new google.visualization.DataTable();
258
+ // sizes.addColumn('string', 'Resource Type');
259
+ // sizes.addColumn('number', 'High', 'highest');
260
+ // sizes.addColumn('number', 'Average', 'average');
261
+ // sizes.addColumn('number', 'Low', 'lowest');
262
+
263
+ // $.each( GPI_View_Snapshot[ selector ].summary_stats.resource_sizes, function ( index, values ) {
264
+ // var data = [ index, Number( values.highest.value ), Number( values.average ), Number( values.lowest.value ) ];
265
+ // sizes.addRow( data );
266
+ // });
267
+
268
+ // var sizes_options = {
269
+ // legend : 'none',
270
+ // backgroundColor : 'transparent',
271
+ // width : 615,
272
+ // height : 200,
273
+ // tooltip : { trigger: 'selection' },
274
+ // chartArea : { top: 10, width: '80%', height: '80%' }
275
+ // };
276
+
277
+ // var sizes_chart = new google.visualization.BarChart( $(this)[0] );
278
+ // sizes_chart.draw(sizes, sizes_options);
279
+
280
+ // sizes_chart.setAction({
281
+ // id : 'view_report',
282
+ // text : 'View Page Report',
283
+ // action : function() {
284
+ // selection = sizes_chart.getSelection();
285
+ // column_id = sizes.getColumnId( selection[0].column );
286
+
287
+ // if ( 'average' == column_id ) {
288
+ // return;
289
+ // }
290
+
291
+ // index = sizes.getValue( selection[0].row, 0 );
292
+ // report_url = GPI_View_Snapshot[ selector ].summary_stats.resource_sizes[ index ][ column_id ].url;
293
+
294
+ // var win = window.open( report_url, '_blank' );
295
+ // win.focus();
296
+ // },
297
+ // visible: function () {
298
+ // selection = sizes_chart.getSelection();
299
+
300
+ // if ( selection.length < 1 ) {
301
+ // return false;
302
+ // }
303
+
304
+ // column_id = sizes.getColumnId( selection[0].column );
305
+
306
+ // if ( 'average' == column_id ) {
307
+ // return false;
308
+ // } else {
309
+ // return true;
310
+ // }
311
+ // },
312
+ // });
313
+ // });
314
+
315
+ // }
316
+
317
  })( jQuery );
classes/class-GPI-Actions.php CHANGED
@@ -36,7 +36,7 @@ class GPI_Actions
36
  $this->gpi_ui_options = get_option( 'gpagespeedi_ui_options' );
37
  $this->page_id = isset( $_GET['page_id'] ) ? intval( $_GET['page_id'] ) : false;
38
  $this->bulk_pages = isset( $_GET['gpi_page_report'] ) ? array_map( 'intval', $_GET['gpi_page_report'] ) : false;
39
- $this->bulk_pages_count = count( $this->bulk_pages );
40
 
41
  $this->gpi_page_stats = $wpdb->prefix . 'gpi_page_stats';
42
  $this->gpi_page_reports = $wpdb->prefix . 'gpi_page_reports';
@@ -184,6 +184,7 @@ class GPI_Actions
184
  'google_developer_key' => ! empty( $_POST['google_developer_key'] ) ? sanitize_text_field( $_POST['google_developer_key'] ) : $this->gpi_options['google_developer_key'],
185
  'response_language' => ! empty( $_POST['response_language'] ) ? sanitize_text_field( $_POST['response_language'] ) : $this->gpi_options['response_language'],
186
  'strategy' => ! empty( $_POST['strategy'] ) ? sanitize_text_field( $_POST['strategy'] ) : $this->gpi_options['strategy'],
 
187
  'max_execution_time' => ! empty( $_POST['max_execution_time'] ) ? intval( $_POST['max_execution_time'] ) : $this->gpi_options['max_execution_time'],
188
  'max_run_time' => isset( $_POST['max_run_time'] ) ? intval( $_POST['max_run_time'] ) : $this->gpi_options['max_run_time'],
189
  'sleep_time' => isset( $_POST['sleep_time'] ) ? intval( $_POST['sleep_time'] ) : $this->gpi_options['sleep_time'],
@@ -204,6 +205,7 @@ class GPI_Actions
204
  'log_api_errors' => isset( $_POST['log_api_errors'] ) ? true : false,
205
  'new_activation_message' => false,
206
  'heartbeat' => isset( $_POST['heartbeat'] ) ? sanitize_text_field( $_POST['heartbeat'] ) : 'standard',
 
207
  'version' => GPI_VERSION
208
  );
209
  update_option( 'gpagespeedi_options', $gpagespeedi_options );
@@ -272,8 +274,10 @@ class GPI_Actions
272
  if ( $checkstatus ) {
273
  $message = __( 'The API is busy checking other pages, please try again later.', 'gpagespeedi' );
274
  } else {
275
- do_action( 'googlepagespeedinsightsworker', $urls_to_recheck, true );
276
- $message = __( 'Recheck Complete.', 'gpagespeedi' );
 
 
277
  }
278
 
279
  return $message;
36
  $this->gpi_ui_options = get_option( 'gpagespeedi_ui_options' );
37
  $this->page_id = isset( $_GET['page_id'] ) ? intval( $_GET['page_id'] ) : false;
38
  $this->bulk_pages = isset( $_GET['gpi_page_report'] ) ? array_map( 'intval', $_GET['gpi_page_report'] ) : false;
39
+ $this->bulk_pages_count = ! empty( $this->bulk_pages ) ? count( $this->bulk_pages ) : 0;
40
 
41
  $this->gpi_page_stats = $wpdb->prefix . 'gpi_page_stats';
42
  $this->gpi_page_reports = $wpdb->prefix . 'gpi_page_reports';
184
  'google_developer_key' => ! empty( $_POST['google_developer_key'] ) ? sanitize_text_field( $_POST['google_developer_key'] ) : $this->gpi_options['google_developer_key'],
185
  'response_language' => ! empty( $_POST['response_language'] ) ? sanitize_text_field( $_POST['response_language'] ) : $this->gpi_options['response_language'],
186
  'strategy' => ! empty( $_POST['strategy'] ) ? sanitize_text_field( $_POST['strategy'] ) : $this->gpi_options['strategy'],
187
+ 'store_screenshots' => ! empty( $_POST['store_screenshots'] ) ? true : false,
188
  'max_execution_time' => ! empty( $_POST['max_execution_time'] ) ? intval( $_POST['max_execution_time'] ) : $this->gpi_options['max_execution_time'],
189
  'max_run_time' => isset( $_POST['max_run_time'] ) ? intval( $_POST['max_run_time'] ) : $this->gpi_options['max_run_time'],
190
  'sleep_time' => isset( $_POST['sleep_time'] ) ? intval( $_POST['sleep_time'] ) : $this->gpi_options['sleep_time'],
205
  'log_api_errors' => isset( $_POST['log_api_errors'] ) ? true : false,
206
  'new_activation_message' => false,
207
  'heartbeat' => isset( $_POST['heartbeat'] ) ? sanitize_text_field( $_POST['heartbeat'] ) : 'standard',
208
+ 'mutex_id' => $this->gpi_options['mutex_id'],
209
  'version' => GPI_VERSION
210
  );
211
  update_option( 'gpagespeedi_options', $gpagespeedi_options );
274
  if ( $checkstatus ) {
275
  $message = __( 'The API is busy checking other pages, please try again later.', 'gpagespeedi' );
276
  } else {
277
+ update_option( 'gpi_recheck_urls', $urls_to_recheck, false );
278
+ do_action( 'run_gpi', true, false, $urls_to_recheck );
279
+
280
+ $message = __( 'This URL has been scheduled for a recheck.', 'gpagespeedi' );
281
  }
282
 
283
  return $message;
classes/class-GPI-Activation.php CHANGED
@@ -17,17 +17,28 @@ class GPI_Activation
17
 
18
  static function upgrade( $gpagespeedi_options, $gpagespeedi_ui_options, $update_options = true )
19
  {
20
- if ( $update_options ) {
21
-
22
- // In v2.0 data structure for page/summary stats changed dramaticly and needs to be updated to avoid errors
23
- if ( ! isset( $gpagespeedi_options['version'] ) || version_compare( $gpagespeedi_options['version'], '2.0', '<' ) ) {
24
- update_option( 'gpagespeedi_upgrade_recheck_required', true );
25
- }
 
 
 
 
 
 
 
 
 
26
 
 
27
  $update_values = array(
28
  'google_developer_key' => isset( $gpagespeedi_options['google_developer_key'] ) ? $gpagespeedi_options['google_developer_key'] : '',
29
  'response_language' => isset( $gpagespeedi_options['response_language'] ) ? $gpagespeedi_options['response_language'] : 'en_US',
30
  'strategy' => isset( $gpagespeedi_options['strategy'] ) ? $gpagespeedi_options['strategy'] : 'desktop',
 
31
  'max_execution_time' => isset( $gpagespeedi_options['max_execution_time'] ) ? $gpagespeedi_options['max_execution_time'] : 300,
32
  'max_run_time' => isset( $gpagespeedi_options['max_run_time'] ) ? $gpagespeedi_options['max_run_time'] : 0,
33
  'sleep_time' => isset( $gpagespeedi_options['sleep_time'] ) ? $gpagespeedi_options['sleep_time'] : 0,
@@ -48,6 +59,7 @@ class GPI_Activation
48
  'log_api_errors' => isset( $gpagespeedi_options['log_api_errors'] ) ? $gpagespeedi_options['log_api_errors'] : false,
49
  'new_activation_message' => false,
50
  'heartbeat' => isset( $gpagespeedi_options['heartbeat'] ) ? $gpagespeedi_options['heartbeat'] : 'fast',
 
51
  'version' => GPI_VERSION
52
  );
53
  update_option( 'gpagespeedi_options', $update_values );
@@ -65,30 +77,32 @@ class GPI_Activation
65
  static function activation()
66
  {
67
  $default_values = array(
68
- 'google_developer_key' => '', // Google API Developer Key
69
- 'response_language' => 'en_US', // Language for report response
70
- 'strategy' => 'desktop', // Generate reports for Desktop, Mobile, or Both
71
- 'max_execution_time' => 300, // in seconds
72
- 'max_run_time' => 0, // in seconds, 0 = no limit
73
- 'sleep_time' => 0, // in seconds
74
- 'recheck_interval' => 86400, // in seconds
75
- 'use_schedule' => true, // use wordpress wp_schedule_event
76
- 'check_pages' => true, // check pages
77
- 'check_posts' => true, // check the built in posts-type
78
- 'cpt_whitelist' => '', // whitelist of Custom Post Types to check
79
- 'check_categories' => true, // check category indexes
80
- 'check_custom_urls' => true, // check user entered custom URLs
81
- 'first_run_complete' => false, // true if all pages have been checked once
82
- 'last_run_finished' => true, // true if the last check finished before max execution time
83
- 'bad_api_key' => false, // true if API reports the API key is bad
84
- 'pagespeed_disabled' => false, // true if API reports the Pagespeed API not enabled
85
- 'api_restriction' => false, // True if API reports that it cannot check pages from this IP/Hostname
86
- 'new_ignored_items' => false, // true if new pages have been added to 'ignore' due to a bad request
87
- 'backend_error' => false, // true if a 'backendErorr' is returned from the API
88
- 'log_api_errors' => false, // log uncaught API exceptions to txt files in FTP root
89
- 'new_activation_message' => true, // display welcome messsage on first-time activation of plugin
90
- 'heartbeat' => 'standard', // Heartbeat refresh interval: fast, slow, standard, or disabled
91
- 'version' => GPI_VERSION // Internal version number used to trigger DB/Options updates in new releases
 
 
92
  );
93
  add_option( 'gpagespeedi_options', $default_values );
94
 
@@ -122,8 +136,10 @@ class GPI_Activation
122
  response_code int(10) DEFAULT NULL,
123
  desktop_score int(10) DEFAULT NULL,
124
  mobile_score int(10) DEFAULT NULL,
125
- desktop_page_stats longtext,
126
- mobile_page_stats longtext,
 
 
127
  type varchar(200) DEFAULT NULL,
128
  object_id bigint(20) DEFAULT NULL,
129
  term_id bigint(20) DEFAULT NULL,
@@ -143,7 +159,8 @@ class GPI_Activation
143
  strategy varchar(20) NOT NULL,
144
  rule_key varchar(200) NOT NULL,
145
  rule_name varchar(200) DEFAULT NULL,
146
- rule_impact decimal(5,2) DEFAULT NULL,
 
147
  rule_blocks longtext,
148
  PRIMARY KEY (ID),
149
  KEY page_id (page_id)
17
 
18
  static function upgrade( $gpagespeedi_options, $gpagespeedi_ui_options, $update_options = true )
19
  {
20
+ // In v4.0 data structure for page/summary stats changed dramaticly and existing reports/snapshots are now longer compatible and must be removed
21
+ if ( ! isset( $gpagespeedi_options['version'] ) || version_compare( $gpagespeedi_options['version'], '4.0', '<' ) ) {
22
+ global $wpdb;
23
+ $gpi_page_stats_table = $wpdb->prefix . 'gpi_page_stats';
24
+ $gpi_page_reports_table = $wpdb->prefix . 'gpi_page_reports';
25
+ $gpi_summary_snapshots_table = $wpdb->prefix . 'gpi_summary_snapshots';
26
+
27
+ $wpdb->query( "ALTER TABLE $gpi_page_stats_table DROP COLUMN desktop_page_stats" );
28
+ $wpdb->query( "ALTER TABLE $gpi_page_stats_table DROP COLUMN mobile_page_stats" );
29
+ $wpdb->query( "ALTER TABLE $gpi_page_reports_table DROP COLUMN rule_impact" );
30
+
31
+ $wpdb->query( "TRUNCATE TABLE $gpi_page_stats_table" );
32
+ $wpdb->query( "TRUNCATE TABLE $gpi_page_reports_table" );
33
+ $wpdb->query( "TRUNCATE TABLE $gpi_page_reports_table" );
34
+ }
35
 
36
+ if ( $update_options ) {
37
  $update_values = array(
38
  'google_developer_key' => isset( $gpagespeedi_options['google_developer_key'] ) ? $gpagespeedi_options['google_developer_key'] : '',
39
  'response_language' => isset( $gpagespeedi_options['response_language'] ) ? $gpagespeedi_options['response_language'] : 'en_US',
40
  'strategy' => isset( $gpagespeedi_options['strategy'] ) ? $gpagespeedi_options['strategy'] : 'desktop',
41
+ 'store_screenshots' => isset( $gpagespeedi_options['store_screenshots'] ) ? $gpagespeedi_options['store_screenshots'] : 0,
42
  'max_execution_time' => isset( $gpagespeedi_options['max_execution_time'] ) ? $gpagespeedi_options['max_execution_time'] : 300,
43
  'max_run_time' => isset( $gpagespeedi_options['max_run_time'] ) ? $gpagespeedi_options['max_run_time'] : 0,
44
  'sleep_time' => isset( $gpagespeedi_options['sleep_time'] ) ? $gpagespeedi_options['sleep_time'] : 0,
59
  'log_api_errors' => isset( $gpagespeedi_options['log_api_errors'] ) ? $gpagespeedi_options['log_api_errors'] : false,
60
  'new_activation_message' => false,
61
  'heartbeat' => isset( $gpagespeedi_options['heartbeat'] ) ? $gpagespeedi_options['heartbeat'] : 'fast',
62
+ 'mutex_id' => isset( $gpagespeedi_options['mutex_id'] ) ? $gpagespeedi_options['mutex_id'] : time() . rand(),
63
  'version' => GPI_VERSION
64
  );
65
  update_option( 'gpagespeedi_options', $update_values );
77
  static function activation()
78
  {
79
  $default_values = array(
80
+ 'google_developer_key' => '', // Google API Developer Key
81
+ 'response_language' => 'en_US', // Language for report response
82
+ 'strategy' => 'desktop', // Generate reports for Desktop, Mobile, or Both
83
+ 'store_screenshots' => 0, // Store loading screenshots in DB
84
+ 'max_execution_time' => 300, // in seconds
85
+ 'max_run_time' => 0, // in seconds, 0 = no limit
86
+ 'sleep_time' => 0, // in seconds
87
+ 'recheck_interval' => 86400, // in seconds
88
+ 'use_schedule' => true, // use wordpress wp_schedule_event
89
+ 'check_pages' => true, // check pages
90
+ 'check_posts' => true, // check the built in posts-type
91
+ 'cpt_whitelist' => '', // whitelist of Custom Post Types to check
92
+ 'check_categories' => true, // check category indexes
93
+ 'check_custom_urls' => true, // check user entered custom URLs
94
+ 'first_run_complete' => false, // true if all pages have been checked once
95
+ 'last_run_finished' => true, // true if the last check finished before max execution time
96
+ 'bad_api_key' => false, // true if API reports the API key is bad
97
+ 'pagespeed_disabled' => false, // true if API reports the Pagespeed API not enabled
98
+ 'api_restriction' => false, // True if API reports that it cannot check pages from this IP/Hostname
99
+ 'new_ignored_items' => false, // true if new pages have been added to 'ignore' due to a bad request
100
+ 'backend_error' => false, // true if a 'backendErorr' is returned from the API
101
+ 'log_api_errors' => false, // log uncaught API exceptions to txt files in FTP root
102
+ 'new_activation_message' => true, // display welcome messsage on first-time activation of plugin
103
+ 'heartbeat' => 'standard', // Heartbeat refresh interval: fast, slow, standard, or disabled
104
+ 'mutex_id' => time() . rand(), // Unique ID to prevent DB lock collision with other installations on the same MySQL server
105
+ 'version' => GPI_VERSION // Internal version number used to trigger DB/Options updates in new releases
106
  );
107
  add_option( 'gpagespeedi_options', $default_values );
108
 
136
  response_code int(10) DEFAULT NULL,
137
  desktop_score int(10) DEFAULT NULL,
138
  mobile_score int(10) DEFAULT NULL,
139
+ desktop_lab_data longtext,
140
+ mobile_lab_data longtext,
141
+ desktop_field_data longtext,
142
+ mobile_field_data longtext,
143
  type varchar(200) DEFAULT NULL,
144
  object_id bigint(20) DEFAULT NULL,
145
  term_id bigint(20) DEFAULT NULL,
159
  strategy varchar(20) NOT NULL,
160
  rule_key varchar(200) NOT NULL,
161
  rule_name varchar(200) DEFAULT NULL,
162
+ rule_type varchar(200) DEFAULT NULL,
163
+ rule_score decimal(5,2) DEFAULT NULL,
164
  rule_blocks longtext,
165
  PRIMARY KEY (ID),
166
  KEY page_id (page_id)
classes/class-GPI-Admin.php CHANGED
@@ -25,6 +25,7 @@ class GPI_Admin
25
  $this->gpi_ui_options = get_option( 'gpagespeedi_ui_options' );
26
  $this->strategy = ( isset( $_GET['strategy'] ) ) ? sanitize_text_field( $_GET['strategy'] ) : $this->gpi_ui_options['view_preference'];
27
 
 
28
  add_action( 'admin_init', array( $this, 'upgrade_check' ), 10 );
29
  add_action( 'pre_uninstall_plugin', array( $this, 'backup_addon_tables' ), 10, 1 );
30
  add_action( 'deleted_plugin', array( $this, 'restore_addon_tables' ), 10, 2 );
@@ -54,11 +55,22 @@ class GPI_Admin
54
  load_plugin_textdomain( 'gpagespeedi', false, 'google-pagespeed-insights/translations' );
55
  }
56
 
 
 
 
 
 
 
 
 
 
 
 
57
  public function upgrade_check()
58
  {
59
- if ( ! isset( $this->gpi_options['version'] ) || version_compare( $this->gpi_options['version'], GPI_VERSION, '<' ) ) {
60
  GPI_Activation::upgrade( $this->gpi_options, $this->gpi_ui_options );
61
- }
62
 
63
  if ( defined( 'GPIA_PLUGIN_FILE' ) ) {
64
  deactivate_plugins( GPIA_PLUGIN_FILE );
@@ -131,25 +143,27 @@ class GPI_Admin
131
  <div id="icon-gpi" class="icon32"><br/></div>
132
  <h2>
133
  <?php _e( 'Google Pagespeed Insights', 'gpagespeedi' ); ?>
134
- <?php
135
- if ( $worker_status = apply_filters( 'gpi_check_status', false ) ) :
136
- if ( ! get_option( 'gpi_abort_scan' ) ) :
 
 
 
 
 
 
 
 
 
 
137
  ?>
138
- <a href="?page=<?php echo sanitize_text_field( $_REQUEST['page'] ); ?>&amp;render=<?php echo $admin_page; ?>&amp;action=abort-scan" class="button-gpi abort"><?php _e( 'Abort Current Scan', 'gpagespeedi' ); ?></a>
139
- <?php
140
- else :
141
- ?>
142
- <a href="?page=<?php echo sanitize_text_field( $_REQUEST['page'] ); ?>&amp;render=<?php echo $admin_page; ?>" class="button-gpi abort" disabled><?php _e( 'Abort Current Scan', 'gpagespeedi' ); ?></a>
143
  <?php
144
  endif;
145
- elseif ( $this->gpi_options['google_developer_key'] ) :
146
- ?>
147
- <a id="start_scan" href="?page=<?php echo sanitize_text_field( $_REQUEST['page'] ); ?>&amp;render=<?php echo $admin_page; ?>&amp;action=start-scan" class="button-gpi run"><?php _e( 'Start Reporting', 'gpagespeedi' ); ?></a>
148
- <input type="checkbox" name="recheck_all_pages" id="recheck_all_pages" />
149
- <label for="recheck_all_pages"><?php _e( 'Recheck All', 'gpagespeedi' ); ?> <span class="tooltip" title="<?php _e( 'Ignore last checked date to generate new reports for all pages', 'gpagespeedi' ); ?>">(?)</span></label>
150
- <?php
151
- endif;
152
- ?>
153
  </h2>
154
 
155
  <?php include GPI_DIRECTORY . '/templates/parts/modes.php'; ?>
@@ -191,7 +205,7 @@ class GPI_Admin
191
  return;
192
  }
193
 
194
- wp_enqueue_style( 'gpagespeedi_css', plugins_url( '/assets/css/gpagespeedi_styles.css', GPI_PLUGIN_FILE ), false, '3.0.0' );
195
 
196
  wp_register_script( 'gpagespeedi_google_charts', 'https://www.gstatic.com/charts/loader.js' );
197
  }
@@ -208,19 +222,28 @@ class GPI_Admin
208
 
209
  $recheck_url = admin_url( '/tools.php?page=google-pagespeed-insights&render=details&page_id=' . intval( $_GET['page_id'] ) . '&action=single-recheck' );
210
 
211
- wp_enqueue_script( 'gpagespeedi_details_js', plugins_url( '/assets/js/details.js', GPI_PLUGIN_FILE ), array( 'jquery', 'gpagespeedi_google_charts', 'wp-util' ), '2.0.2' );
212
  wp_localize_script( 'gpagespeedi_details_js', 'GPI_Details', array(
213
  'page_stats' => $this->get_page_stats( intval( $_GET['page_id'] ) ),
214
  'page_reports' => $this->get_page_reports( intval( $_GET['page_id'] ) ),
215
  'recheck_url' => wp_nonce_url( $recheck_url, 'gpi-single-recheck' ),
 
216
  'strings' => array(
217
- 'hosts' => __( 'Number of Hosts', 'gpagespeedi' ),
218
- 'total_bytes' => __( 'Total Request Bytes', 'gpagespeedi' ),
219
- 'total_resources' => __( 'Total Resources', 'gpagespeedi' ),
220
- 'js_resources' => __( 'JavaScript Resources', 'gpagespeedi' ),
221
- 'css_resources' => __( 'CSS Resources', 'gpagespeedi' ),
222
- 'score_impact' => __( 'Score Impact', 'gpagespeedi' ),
223
- 'old_format_notice' => __( 'Google Pagespeed Insights for WordPress has detected an outdated format in this report due to an update in version 2.0 of this plugin. Some report features are unavailable. Please recheck results to resolve this problem.', 'gpagespeedi' )
 
 
 
 
 
 
 
 
224
  )
225
  )
226
  );
@@ -236,16 +259,14 @@ class GPI_Admin
236
  return;
237
  }
238
 
239
- wp_enqueue_script( 'gpagespeedi_summary_js', plugins_url( '/assets/js/summary.js', GPI_PLUGIN_FILE ), array( 'jquery', 'gpagespeedi_google_charts', 'wp-util' ), '2.0.2' );
240
  wp_localize_script( 'gpagespeedi_summary_js', 'GPI_Summary', array(
241
  'summary_stats' => $this->get_summary_stats(),
242
  'summary_reports' => $this->get_summary_reports(),
243
  'strings' => array(
244
- 'resource_type' => __( 'Resource Type', 'gpagespeedi' ),
245
- 'high' => __( 'High', 'gpagespeedi' ),
246
- 'average' => __( 'Average', 'gpagespeedi' ),
247
- 'low' => __( 'Low', 'gpagespeedi' ),
248
- 'view_page_report' => __( 'View Page Report', 'gpagespeedi' ),
249
  'old_format_notice' => __( 'Google Pagespeed Insights for WordPress has detected an outdated format in one or more reports due to an update in version 2.0 of this plugin. Some report features are unavailable. Please force recheck all reports from the options page to resolve this problem.', 'gpagespeedi' )
250
  )
251
  )
@@ -265,7 +286,10 @@ class GPI_Admin
265
  $snapshot_data = $this->get_snapshot_data();
266
  $strings = array(
267
  'strings' => array(
268
- 'comment' => __('Comment', 'gpagespeedi')
 
 
 
269
  ),
270
  'comments' => array(
271
  'snapshot' => isset( $snapshot_data['snapshot']['comment'] ) ? sanitize_text_field( $snapshot_data['snapshot']['comment'] ) : false,
@@ -275,7 +299,7 @@ class GPI_Admin
275
 
276
  $localize_data = array_merge( $snapshot_data, $strings );
277
 
278
- wp_enqueue_script( 'gpagespeedi_view_snapshot_js', plugins_url( '/assets/js/view-snapshot.js', GPI_PLUGIN_FILE ), array( 'jquery', 'gpagespeedi_google_charts', 'wp-util' ), '3.0.0' );
279
  wp_localize_script( 'gpagespeedi_view_snapshot_js', 'GPI_View_Snapshot', $localize_data );
280
  }
281
 
@@ -285,7 +309,7 @@ class GPI_Admin
285
  return;
286
  }
287
 
288
- wp_enqueue_script( 'gpagespeedi_global_js', plugins_url( '/assets/js/global.js', GPI_PLUGIN_FILE ), array( 'jquery', 'heartbeat', 'jquery-ui-tooltip' ), '2.0.2' );
289
  wp_localize_script( 'gpagespeedi_global_js', 'GPI_Global', array(
290
  'heartbeat' => $this->gpi_options['heartbeat'],
291
  'progress' => get_option( 'gpi_progress' )
@@ -309,7 +333,10 @@ class GPI_Admin
309
  case 'details':
310
  include_once GPI_DIRECTORY . '/assets/js/templates/details/statistics.php';
311
  include_once GPI_DIRECTORY . '/assets/js/templates/details/legend.php';
312
- include_once GPI_DIRECTORY . '/assets/js/templates/details/rule_blocks.php';
 
 
 
313
  break;
314
 
315
  case 'summary':
@@ -529,16 +556,20 @@ class GPI_Admin
529
  $filter = apply_filters( 'gpi_custom_url_labels', false );
530
  }
531
 
532
- $all_page_stats = $wpdb->get_results( $wpdb->prepare(
533
- "
534
- SELECT ID, URL, {$this->strategy}_score as score, {$this->strategy}_page_stats as resources
535
- FROM $gpi_page_stats
536
- WHERE type REGEXP %s
537
- AND {$this->strategy}_score IS NOT NULL
538
- ORDER BY score DESC
539
- ",
540
- $filter
541
- ), ARRAY_A );
 
 
 
 
542
 
543
  if ( ! $all_page_stats ) {
544
  return array();
@@ -547,15 +578,15 @@ class GPI_Admin
547
  $pages = count( $all_page_stats );
548
  $score = 0;
549
 
550
- $keys = array( 'lowest' => array( 'value' => false, 'url' => false ), 'average' => false, 'highest' => array( 'value' => false, 'url' => false ) );
551
- $resource_sizes = array( 'HTML' => $keys, 'CSS' => $keys, 'IMAGES' => $keys, 'JS' => $keys, 'OTHER' => $keys );
552
  $page_scores = array();
553
  $old_format_detected = false;
554
 
 
 
555
  foreach ( $all_page_stats as $page_stats ) {
556
- $score += $page_stats['score'];
557
- $resources = unserialize( $page_stats['resources'] );
558
- $report_url = admin_url( '/tools.php?page=google-pagespeed-insights&render=details&page_id=' . $page_stats['ID'] );
559
 
560
  $page_scores[] = array(
561
  'score' => $page_stats['score'],
@@ -568,20 +599,24 @@ class GPI_Admin
568
  $old_format_detected = true;
569
  }
570
 
571
- if ( isset( $resources['resource_sizes'] ) ) {
572
- foreach ( $resources['resource_sizes'] as $type => $value ) {
573
- $resource_sizes[ $type ]['average'] += $value;
 
 
 
 
574
 
575
- if ( false === $resource_sizes[ $type ]['highest']['value'] || $value > $resource_sizes[ $type ]['highest']['value'] ) {
576
- $resource_sizes[ $type ]['highest'] = array(
577
- 'value' => $value,
578
  'url' => $report_url
579
  );
580
  }
581
 
582
- if ( false === $resource_sizes[ $type ]['lowest']['value'] || $value < $resource_sizes[ $type ]['lowest']['value'] ) {
583
- $resource_sizes[ $type ]['lowest'] = array(
584
- 'value' => $value,
585
  'url' => $report_url
586
  );
587
  }
@@ -589,13 +624,13 @@ class GPI_Admin
589
  }
590
  }
591
 
592
- foreach ( $resource_sizes as &$values ) {
593
- $values['average'] = $values['average'] / $pages;
594
  }
595
 
596
  $score = round( $score / $pages );
597
 
598
- $high_scores = $this->sort_array( $page_scores, 'score' );
599
  $low_scores = array_reverse( $high_scores );
600
 
601
  return array(
@@ -603,7 +638,7 @@ class GPI_Admin
603
  'highest' => array_slice( $high_scores, 0, 5 ),
604
  'lowest' => array_slice( $low_scores, 0, 5 )
605
  ),
606
- 'resource_sizes' => $resource_sizes,
607
  'score' => $score,
608
  'odometer_rotation' => ( ( 3.38 * $score ) + 11 ) . 'deg',
609
  'data_format' => ( $old_format_detected ) ? '1.0' : GPI_VERSION
@@ -625,20 +660,27 @@ class GPI_Admin
625
  $filter = apply_filters( 'gpi_custom_url_labels', false );
626
  }
627
 
628
- $all_page_reports = $wpdb->get_results( $wpdb->prepare(
629
- "
630
- SELECT r.rule_key, r.rule_name, r.rule_impact
631
- FROM $gpi_page_stats as s
632
- INNER JOIN $gpi_page_reports as r
633
- ON r.page_id = s.ID
634
- AND r.strategy = %s
635
- WHERE type REGEXP %s
636
- AND {$this->strategy}_score IS NOT NULL
637
- ORDER BY r.rule_impact DESC
638
- ",
639
- $this->strategy,
640
- $filter
641
- ), ARRAY_A );
 
 
 
 
 
 
 
642
 
643
  if ( ! $all_page_reports ) {
644
  return array();
@@ -646,22 +688,23 @@ class GPI_Admin
646
 
647
  foreach ( $all_page_reports as $page_report ) {
648
  if ( isset( $summary_reports[ $page_report['rule_key'] ] ) ) {
649
- $summary_reports[ $page_report['rule_key'] ]['avg_impact'] += $page_report['rule_impact'];
650
  $summary_reports[ $page_report['rule_key'] ]['occurances']++;
651
  } else {
652
  $summary_reports[ $page_report['rule_key'] ] = array(
653
- 'rule_name' => ( 'OptimizeImages' != $page_report['rule_key'] ) ? $page_report['rule_name'] : $page_report['rule_name'] . '<span class="shortpixel_blurb"> &ndash; <a href="https://shortpixel.com/h/af/PCFTWNN142247" target="_blank">' . __( 'Auto-Optimize images with ShortPixel. Sign up for 150 free credits!', 'gpagespeedi') . '</a></span>',
654
- 'avg_impact' => $page_report['rule_impact'],
655
  'occurances' => 1
656
  );
657
  }
658
  }
659
 
660
  foreach ( $summary_reports as &$summary_report ) {
661
- $summary_report['avg_impact'] = round( $summary_report['avg_impact'] / $summary_report['occurances'], 2 );
 
662
  }
663
 
664
- $summary_reports = $this->sort_array( $summary_reports, 'avg_impact' );
665
 
666
  return array_slice( $summary_reports, 0, 5 );
667
  }
@@ -682,8 +725,10 @@ class GPI_Admin
682
  $progress = get_option( 'gpi_progress' );
683
 
684
  if ( 'abort' == $progress ) {
 
685
  $response['gpi_progress'] = 'abort';
686
  } else if ( $progress != null ) {
 
687
  $split_status = explode( ' / ', $progress );
688
 
689
  $percent_complete = $split_status[0] / $split_status[1];
@@ -691,6 +736,7 @@ class GPI_Admin
691
 
692
  $response['gpi_progress'] = $percent_complete;
693
  } else {
 
694
  $response['gpi_progress'] = 'done';
695
  }
696
 
@@ -722,7 +768,7 @@ class GPI_Admin
722
 
723
  $page_stats = $wpdb->get_row( $wpdb->prepare(
724
  "
725
- SELECT URL, {$this->strategy}_page_stats as resources, {$this->strategy}_score as score, {$this->strategy}_last_modified as last_modified
726
  FROM $gpi_page_stats
727
  WHERE ID = %d
728
  ",
@@ -734,7 +780,7 @@ class GPI_Admin
734
  }
735
 
736
  // flag if pre 2.0 data structure is detected
737
- if ( strpos( $page_stats['resources'], 'numberHosts' ) !== false ) {
738
  $page_stats['data_format'] = '1.0';
739
  } else {
740
  $page_stats['data_format'] = GPI_VERSION;
@@ -765,11 +811,11 @@ class GPI_Admin
765
 
766
  $page_reports = $wpdb->get_results( $wpdb->prepare(
767
  "
768
- SELECT rule_key, rule_name, rule_impact, rule_blocks
769
  FROM $gpi_page_reports
770
  WHERE page_id = %d
771
  AND strategy = %s
772
- ORDER BY rule_impact DESC
773
  ",
774
  $page_id,
775
  $this->strategy
@@ -779,7 +825,7 @@ class GPI_Admin
779
  foreach ( $page_reports as &$page_report ) {
780
  $page_report['rule_blocks'] = unserialize( $page_report['rule_blocks'] );
781
 
782
- if ( 'OptimizeImages' == $page_report['rule_key'] ) {
783
  $page_report['rule_blocks'] = $this->shortpixel_image_rule_blocks( $page_report['rule_blocks'] );
784
  }
785
  }
@@ -859,16 +905,16 @@ class GPI_Admin
859
 
860
  private function shortpixel_image_rule_blocks( $rule_blocks )
861
  {
862
- if ( ! isset( $rule_blocks[0]['urls'] ) ) {
863
  return $rule_blocks;
864
  }
865
 
866
- foreach ( $rule_blocks as $index => $rule_block ) {
867
- foreach ( $rule_block['urls'] as $key => $rule ) {
868
- $rule_blocks[ $index ]['urls'][ $key ] = preg_replace(
869
  '/(?:href=")(.*?)(?:")/',
870
  'href="https://shortpixel.com/gpi/af/PCFTWNN142247?site-url=$1"',
871
- $rule
872
  );
873
  }
874
  }
@@ -876,15 +922,15 @@ class GPI_Admin
876
  return $rule_blocks;
877
  }
878
 
879
- private function sort_array( $array, $key )
880
  {
881
- usort( $array, function( $a, $b ) use ( $key ) {
882
  if ( abs( $a[ $key ] - $b[ $key ] ) < 0.00000001 ) {
883
  return 0; // almost equal
884
  } else if ( ( $a[ $key ] - $b[ $key ] ) < 0 ) {
885
- return 1;
886
  } else {
887
- return -1;
888
  }
889
  });
890
 
25
  $this->gpi_ui_options = get_option( 'gpagespeedi_ui_options' );
26
  $this->strategy = ( isset( $_GET['strategy'] ) ) ? sanitize_text_field( $_GET['strategy'] ) : $this->gpi_ui_options['view_preference'];
27
 
28
+ add_filter( 'plugin_action_links', array( $this, 'add_settings_link' ), 10, 2 );
29
  add_action( 'admin_init', array( $this, 'upgrade_check' ), 10 );
30
  add_action( 'pre_uninstall_plugin', array( $this, 'backup_addon_tables' ), 10, 1 );
31
  add_action( 'deleted_plugin', array( $this, 'restore_addon_tables' ), 10, 2 );
55
  load_plugin_textdomain( 'gpagespeedi', false, 'google-pagespeed-insights/translations' );
56
  }
57
 
58
+ public function add_settings_link( $links, $file )
59
+ {
60
+ if ( $file != GPI_BASENAME ) {
61
+ return $links;
62
+ }
63
+
64
+ array_unshift( $links, '<a href="' . esc_url( admin_url( '/tools.php?page=google-pagespeed-insights&render=options' ) ) . '">' . esc_html__( 'Settings', 'acf-font-awesome' ) . '</a>' );
65
+
66
+ return $links;
67
+ }
68
+
69
  public function upgrade_check()
70
  {
71
+ // if ( ! isset( $this->gpi_options['version'] ) || version_compare( $this->gpi_options['version'], GPI_VERSION, '<' ) ) {
72
  GPI_Activation::upgrade( $this->gpi_options, $this->gpi_ui_options );
73
+ // }
74
 
75
  if ( defined( 'GPIA_PLUGIN_FILE' ) ) {
76
  deactivate_plugins( GPIA_PLUGIN_FILE );
143
  <div id="icon-gpi" class="icon32"><br/></div>
144
  <h2>
145
  <?php _e( 'Google Pagespeed Insights', 'gpagespeedi' ); ?>
146
+ <div class="global-actions">
147
+ <?php
148
+ if ( $worker_status = apply_filters( 'gpi_check_status', false ) ) :
149
+ if ( ! get_option( 'gpi_abort_scan' ) ) :
150
+ ?>
151
+ <a href="?page=<?php echo sanitize_text_field( $_REQUEST['page'] ); ?>&amp;render=<?php echo $admin_page; ?>&amp;action=abort-scan" class="button-gpi abort"><?php _e( 'Abort Current Scan', 'gpagespeedi' ); ?></a>
152
+ <?php
153
+ else :
154
+ ?>
155
+ <a href="?page=<?php echo sanitize_text_field( $_REQUEST['page'] ); ?>&amp;render=<?php echo $admin_page; ?>" class="button-gpi abort" disabled><?php _e( 'Abort Current Scan', 'gpagespeedi' ); ?></a>
156
+ <?php
157
+ endif;
158
+ elseif ( $this->gpi_options['google_developer_key'] ) :
159
  ?>
160
+ <a id="start_scan" href="?page=<?php echo sanitize_text_field( $_REQUEST['page'] ); ?>&amp;render=<?php echo $admin_page; ?>&amp;action=start-scan" class="button-gpi run"><?php _e( 'Start Reporting', 'gpagespeedi' ); ?></a>
161
+ <input type="checkbox" name="recheck_all_pages" id="recheck_all_pages" />
162
+ <label for="recheck_all_pages"><?php _e( 'Recheck All', 'gpagespeedi' ); ?> <span class="tooltip" title="<?php _e( 'Ignore last checked date to generate new reports for all pages', 'gpagespeedi' ); ?>">(?)</span></label>
 
 
163
  <?php
164
  endif;
165
+ ?>
166
+ </div>
 
 
 
 
 
 
167
  </h2>
168
 
169
  <?php include GPI_DIRECTORY . '/templates/parts/modes.php'; ?>
205
  return;
206
  }
207
 
208
+ wp_enqueue_style( 'gpagespeedi_css', plugins_url( '/assets/css/gpagespeedi_styles.css', GPI_PLUGIN_FILE ), false, GPI_VERSION );
209
 
210
  wp_register_script( 'gpagespeedi_google_charts', 'https://www.gstatic.com/charts/loader.js' );
211
  }
222
 
223
  $recheck_url = admin_url( '/tools.php?page=google-pagespeed-insights&render=details&page_id=' . intval( $_GET['page_id'] ) . '&action=single-recheck' );
224
 
225
+ wp_enqueue_script( 'gpagespeedi_details_js', plugins_url( '/assets/js/details.js', GPI_PLUGIN_FILE ), array( 'jquery', 'jquery-ui-accordion', 'gpagespeedi_google_charts', 'wp-util' ), GPI_VERSION, true );
226
  wp_localize_script( 'gpagespeedi_details_js', 'GPI_Details', array(
227
  'page_stats' => $this->get_page_stats( intval( $_GET['page_id'] ) ),
228
  'page_reports' => $this->get_page_reports( intval( $_GET['page_id'] ) ),
229
  'recheck_url' => wp_nonce_url( $recheck_url, 'gpi-single-recheck' ),
230
+ 'public_path' => GPI_PUBLIC_PATH,
231
  'strings' => array(
232
+ 'old_format_notice' => sprintf( __( 'Google Pagespeed Insights for WordPress has detected an outdated format in this report due to an update in version %s of this plugin. Some report features are unavailable. Please recheck results to resolve this problem.', 'gpagespeedi' ), '4.0' ),
233
+ 'insufficient_field_data' => __( 'The Chrome User Experience Report <a href="https://developers.google.com/speed/docs/insights/about#faq" target="_blank">does not have sufficient real-world speed data</a> for this page.', 'gpagespeedi' ),
234
+ 'FCP' => __( 'First Contentful Paint', 'gpagespeedi' ),
235
+ 'FID' => __( 'First Input Delay', 'gpagespeedi' ),
236
+ 'field_data_labels' => array(
237
+ __( 'of loads for this page have a fast', 'gpagespeedi' ),
238
+ __( 'of loads for this page have an average', 'gpagespeedi' ),
239
+ __( 'of loads for this page have a slow', 'gpagespeedi' )
240
+ ),
241
+ 'shortpixel' => array(
242
+ 'title' => __( 'Auto-Optimize Images', 'gpagespeedi' ),
243
+ 'description' => __( 'Unoptimized images are often one of the <strong>biggest</strong> negative factors in pagespeed scores. Google Pagespeed Insights for WordPress has partnered with ShortPixel to provide an easy and affordable solution to <em>automatically</em> optimize all images.', 'gpagespeedi' ),
244
+ 'signup_desc' => __( 'Sign up using the button below and receive <strong>150 free image optimization credits</strong>.', 'gpagespeedi' ),
245
+ 'signup_btn' => __( 'Free Sign Up', 'gpagespeedi' )
246
+ )
247
  )
248
  )
249
  );
259
  return;
260
  }
261
 
262
+ wp_enqueue_script( 'gpagespeedi_summary_js', plugins_url( '/assets/js/summary.js', GPI_PLUGIN_FILE ), array( 'jquery', 'gpagespeedi_google_charts', 'wp-util' ), GPI_VERSION );
263
  wp_localize_script( 'gpagespeedi_summary_js', 'GPI_Summary', array(
264
  'summary_stats' => $this->get_summary_stats(),
265
  'summary_reports' => $this->get_summary_reports(),
266
  'strings' => array(
267
+ 'average_score' => __( 'Average Score', 'gpagespeedi' ),
268
+ 'best_performing' => __( 'View Best Performing', 'gpagespeedi' ),
269
+ 'worst_performing' => __( 'View Worst Performing', 'gpagespeedi' ),
 
 
270
  'old_format_notice' => __( 'Google Pagespeed Insights for WordPress has detected an outdated format in one or more reports due to an update in version 2.0 of this plugin. Some report features are unavailable. Please force recheck all reports from the options page to resolve this problem.', 'gpagespeedi' )
271
  )
272
  )
286
  $snapshot_data = $this->get_snapshot_data();
287
  $strings = array(
288
  'strings' => array(
289
+ 'comment' => __( 'Comment', 'gpagespeedi' ),
290
+ 'average_score' => __( 'Average Score', 'gpagespeedi' ),
291
+ 'best_performing' => __( 'View Best Performing', 'gpagespeedi' ),
292
+ 'worst_performing' => __( 'View Worst Performing', 'gpagespeedi' )
293
  ),
294
  'comments' => array(
295
  'snapshot' => isset( $snapshot_data['snapshot']['comment'] ) ? sanitize_text_field( $snapshot_data['snapshot']['comment'] ) : false,
299
 
300
  $localize_data = array_merge( $snapshot_data, $strings );
301
 
302
+ wp_enqueue_script( 'gpagespeedi_view_snapshot_js', plugins_url( '/assets/js/view-snapshot.js', GPI_PLUGIN_FILE ), array( 'jquery', 'gpagespeedi_google_charts', 'wp-util' ), GPI_VERSION );
303
  wp_localize_script( 'gpagespeedi_view_snapshot_js', 'GPI_View_Snapshot', $localize_data );
304
  }
305
 
309
  return;
310
  }
311
 
312
+ wp_enqueue_script( 'gpagespeedi_global_js', plugins_url( '/assets/js/global.js', GPI_PLUGIN_FILE ), array( 'jquery', 'heartbeat', 'jquery-ui-tooltip' ), GPI_VERSION );
313
  wp_localize_script( 'gpagespeedi_global_js', 'GPI_Global', array(
314
  'heartbeat' => $this->gpi_options['heartbeat'],
315
  'progress' => get_option( 'gpi_progress' )
333
  case 'details':
334
  include_once GPI_DIRECTORY . '/assets/js/templates/details/statistics.php';
335
  include_once GPI_DIRECTORY . '/assets/js/templates/details/legend.php';
336
+ include_once GPI_DIRECTORY . '/assets/js/templates/details/audits-opportunity.php';
337
+ include_once GPI_DIRECTORY . '/assets/js/templates/details/audits-table.php';
338
+ include_once GPI_DIRECTORY . '/assets/js/templates/details/audits-criticalrequestchain.php';
339
+ include_once GPI_DIRECTORY . '/assets/js/templates/details/audits-filmstrip.php';
340
  break;
341
 
342
  case 'summary':
556
  $filter = apply_filters( 'gpi_custom_url_labels', false );
557
  }
558
 
559
+ $all_page_stats = array();
560
+
561
+ if ( $filter ) {
562
+ $all_page_stats = $wpdb->get_results( $wpdb->prepare(
563
+ "
564
+ SELECT ID, URL, {$this->strategy}_score as score, {$this->strategy}_lab_data as labData
565
+ FROM $gpi_page_stats
566
+ WHERE type REGEXP %s
567
+ AND {$this->strategy}_score IS NOT NULL
568
+ ORDER BY score DESC
569
+ ",
570
+ $filter
571
+ ), ARRAY_A );
572
+ }
573
 
574
  if ( ! $all_page_stats ) {
575
  return array();
578
  $pages = count( $all_page_stats );
579
  $score = 0;
580
 
 
 
581
  $page_scores = array();
582
  $old_format_detected = false;
583
 
584
+ $avg_lab_data = array();
585
+
586
  foreach ( $all_page_stats as $page_stats ) {
587
+ $score += $page_stats['score'];
588
+ $lab_data = unserialize( $page_stats['labData'] );
589
+ $report_url = admin_url( '/tools.php?page=google-pagespeed-insights&render=details&page_id=' . $page_stats['ID'] );
590
 
591
  $page_scores[] = array(
592
  'score' => $page_stats['score'],
599
  $old_format_detected = true;
600
  }
601
 
602
+ if ( ! empty( $lab_data ) ) {
603
+ foreach ( $lab_data as $index => $data ) {
604
+ if ( ! isset( $avg_lab_data[ $data['title'] ] ) ) {
605
+ $avg_lab_data[ $data['title'] ] = array( 'lowest' => array( 'value' => false, 'url' => false ), 'average' => false, 'highest' => array( 'value' => false, 'url' => false ) );
606
+ }
607
+
608
+ $avg_lab_data[ $data['title'] ]['average'] += $data['score'];
609
 
610
+ if ( false === $avg_lab_data[ $data['title'] ]['highest']['value'] || $data['score'] > $avg_lab_data[ $data['title'] ]['highest']['value'] ) {
611
+ $avg_lab_data[ $data['title'] ]['highest'] = array(
612
+ 'value' => $data['displayValue'],
613
  'url' => $report_url
614
  );
615
  }
616
 
617
+ if ( false === $avg_lab_data[ $data['title'] ]['lowest']['value'] || $data['score'] < $avg_lab_data[ $data['title'] ]['lowest']['value'] ) {
618
+ $avg_lab_data[ $data['title'] ]['lowest'] = array(
619
+ 'value' => $data['displayValue'],
620
  'url' => $report_url
621
  );
622
  }
624
  }
625
  }
626
 
627
+ foreach ( $avg_lab_data as &$data ) {
628
+ $data['average'] = $data['average'] / $pages;
629
  }
630
 
631
  $score = round( $score / $pages );
632
 
633
+ $high_scores = $this->sort_array( $page_scores, 'score', 'desc' );
634
  $low_scores = array_reverse( $high_scores );
635
 
636
  return array(
638
  'highest' => array_slice( $high_scores, 0, 5 ),
639
  'lowest' => array_slice( $low_scores, 0, 5 )
640
  ),
641
+ 'labData' => $avg_lab_data,
642
  'score' => $score,
643
  'odometer_rotation' => ( ( 3.38 * $score ) + 11 ) . 'deg',
644
  'data_format' => ( $old_format_detected ) ? '1.0' : GPI_VERSION
660
  $filter = apply_filters( 'gpi_custom_url_labels', false );
661
  }
662
 
663
+ $all_page_reports = array();
664
+
665
+ if ( $filter ) {
666
+ $all_page_reports = $wpdb->get_results( $wpdb->prepare(
667
+ "
668
+ SELECT r.rule_key, r.rule_name, r.rule_score
669
+ FROM $gpi_page_stats as s
670
+ INNER JOIN $gpi_page_reports as r
671
+ ON r.page_id = s.ID
672
+ AND r.strategy = %s
673
+ AND r.rule_type = %s
674
+ AND r.rule_score < .9
675
+ WHERE type REGEXP %s
676
+ AND s.{$this->strategy}_score IS NOT NULL
677
+ ORDER BY r.rule_score DESC
678
+ ",
679
+ $this->strategy,
680
+ 'opportunity',
681
+ $filter
682
+ ), ARRAY_A );
683
+ }
684
 
685
  if ( ! $all_page_reports ) {
686
  return array();
688
 
689
  foreach ( $all_page_reports as $page_report ) {
690
  if ( isset( $summary_reports[ $page_report['rule_key'] ] ) ) {
691
+ $summary_reports[ $page_report['rule_key'] ]['avg_score'] += $page_report['rule_score'];
692
  $summary_reports[ $page_report['rule_key'] ]['occurances']++;
693
  } else {
694
  $summary_reports[ $page_report['rule_key'] ] = array(
695
+ 'rule_name' => ( 'uses-optimized-images' != $page_report['rule_key'] ) ? $page_report['rule_name'] : $page_report['rule_name'] . '<span class="shortpixel_blurb"> &ndash; <a href="https://shortpixel.com/h/af/PCFTWNN142247" target="_blank">' . __( 'Auto-Optimize images with ShortPixel. Sign up for 150 free credits!', 'gpagespeedi') . '</a></span>',
696
+ 'avg_score' => $page_report['rule_score'],
697
  'occurances' => 1
698
  );
699
  }
700
  }
701
 
702
  foreach ( $summary_reports as &$summary_report ) {
703
+ $summary_report['avg_score'] = round( $summary_report['avg_score'] / $summary_report['occurances'], 2 );
704
+ $summary_report['avg_score'] = $summary_report['avg_score'] * 100;
705
  }
706
 
707
+ $summary_reports = $this->sort_array( $summary_reports, 'avg_score' );
708
 
709
  return array_slice( $summary_reports, 0, 5 );
710
  }
725
  $progress = get_option( 'gpi_progress' );
726
 
727
  if ( 'abort' == $progress ) {
728
+ $response['gpi_progress_tooltip'] = '';
729
  $response['gpi_progress'] = 'abort';
730
  } else if ( $progress != null ) {
731
+ $response['gpi_progress_tooltip'] = $progress;
732
  $split_status = explode( ' / ', $progress );
733
 
734
  $percent_complete = $split_status[0] / $split_status[1];
736
 
737
  $response['gpi_progress'] = $percent_complete;
738
  } else {
739
+ $response['gpi_progress_tooltip'] = '';
740
  $response['gpi_progress'] = 'done';
741
  }
742
 
768
 
769
  $page_stats = $wpdb->get_row( $wpdb->prepare(
770
  "
771
+ SELECT URL, {$this->strategy}_lab_data as labData, {$this->strategy}_field_data as fieldData, {$this->strategy}_score as score, {$this->strategy}_last_modified as last_modified
772
  FROM $gpi_page_stats
773
  WHERE ID = %d
774
  ",
780
  }
781
 
782
  // flag if pre 2.0 data structure is detected
783
+ if ( strpos( $page_stats['labData'], 'numberHosts' ) !== false ) {
784
  $page_stats['data_format'] = '1.0';
785
  } else {
786
  $page_stats['data_format'] = GPI_VERSION;
811
 
812
  $page_reports = $wpdb->get_results( $wpdb->prepare(
813
  "
814
+ SELECT rule_key, rule_name, rule_score, rule_blocks
815
  FROM $gpi_page_reports
816
  WHERE page_id = %d
817
  AND strategy = %s
818
+ ORDER BY rule_score ASC
819
  ",
820
  $page_id,
821
  $this->strategy
825
  foreach ( $page_reports as &$page_report ) {
826
  $page_report['rule_blocks'] = unserialize( $page_report['rule_blocks'] );
827
 
828
+ if ( 'uses-optimized-images' == $page_report['rule_key'] ) {
829
  $page_report['rule_blocks'] = $this->shortpixel_image_rule_blocks( $page_report['rule_blocks'] );
830
  }
831
  }
905
 
906
  private function shortpixel_image_rule_blocks( $rule_blocks )
907
  {
908
+ if ( ! isset( $rule_blocks['details']->items ) || empty( $rule_blocks['details']->items ) ) {
909
  return $rule_blocks;
910
  }
911
 
912
+ foreach ( $rule_blocks['details']->items as $index => $item ) {
913
+ if ( isset( $item->url ) ) {
914
+ $rule_blocks['details']->items[ $index ]->url = preg_replace(
915
  '/(?:href=")(.*?)(?:")/',
916
  'href="https://shortpixel.com/gpi/af/PCFTWNN142247?site-url=$1"',
917
+ $item->url
918
  );
919
  }
920
  }
922
  return $rule_blocks;
923
  }
924
 
925
+ private function sort_array( $array, $key, $direction = 'asc' )
926
  {
927
+ usort( $array, function( $a, $b ) use ( $key, $direction ) {
928
  if ( abs( $a[ $key ] - $b[ $key ] ) < 0.00000001 ) {
929
  return 0; // almost equal
930
  } else if ( ( $a[ $key ] - $b[ $key ] ) < 0 ) {
931
+ return $direction == 'asc' ? -1 : 1;
932
  } else {
933
+ return $direction == 'asc' ? 1 : -1;
934
  }
935
  });
936
 
classes/class-GPI-Core.php CHANGED
@@ -35,7 +35,7 @@ class GPI_Core
35
  add_action( 'googlepagespeedinsightsworker', array( $this, 'googlepagespeedinsightsworker'), 10, 2 );
36
  add_action( 'gpi_update_option', array( $this, 'update_option' ), 10, 3 );
37
  add_filter( 'gpi_check_status', array( $this, 'check_status' ), 10, 1 );
38
- add_action( 'run_gpi', array( $this, 'run_gpi' ), 10, 2 );
39
 
40
  if ( ! wp_next_scheduled( 'gpi_prune_logs' ) ) {
41
  wp_schedule_event( time(), 'daily', 'gpi_prune_logs' );
@@ -56,8 +56,15 @@ class GPI_Core
56
 
57
  $force_recheck_all_urls = isset( $_GET['recheck'] ) ? true : false;
58
  $timeout_respawn = isset( $_GET['timeout'] ) ? true : false;
 
59
 
60
- $this->googlepagespeedinsightsworker( array(), $force_recheck_all_urls, $timeout_respawn );
 
 
 
 
 
 
61
  }
62
 
63
  public function cron_schedules( $schedules )
@@ -92,7 +99,7 @@ class GPI_Core
92
  {
93
  global $wpdb;
94
 
95
- $lock = $wpdb->get_var( $wpdb->prepare( 'SELECT GET_LOCK(%s, %d)', 'gpi_lock_a1b2c3', 0 ) );
96
 
97
  return $lock == 1;
98
  }
@@ -101,7 +108,7 @@ class GPI_Core
101
  {
102
  global $wpdb;
103
 
104
- $wpdb->get_var( $wpdb->prepare( 'SELECT RELEASE_LOCK(%s)', 'gpi_lock_a1b2c3' ) );
105
  }
106
 
107
  public function check_status( $busy )
@@ -117,16 +124,24 @@ class GPI_Core
117
  return $busy;
118
  }
119
 
120
- public function run_gpi( $recheck = false, $timeout = false )
121
  {
122
  add_option( 'gpi_check_now', true );
123
 
124
- if ( ! $timeout ) {
125
- $cron_url = $recheck ? site_url( '?gpi_check_now&recheck' ) : site_url( '?gpi_check_now' );
126
- } else {
127
- $cron_url = $recheck ? site_url( '?gpi_check_now&recheck&timeout' ) : site_url( '?gpi_check_now&timeout' );
 
 
 
 
 
 
128
  }
129
 
 
 
130
  wp_remote_post( $cron_url, array( 'timeout' => 0.01, 'blocking' => false, 'sslverify' => apply_filters( 'https_local_ssl_verify', true ) ) );
131
  }
132
 
@@ -156,15 +171,13 @@ class GPI_Core
156
  $start_runtime = time();
157
  }
158
 
159
- // Include Google API + Start new Instance. Check first to make sure they arent already included by another plugin!
160
- if ( ! class_exists('Google_Client') ) {
161
- require_once GPI_DIRECTORY . '/lib/google-api-php-client/vendor/autoload.php';
162
  }
163
 
164
- $client = new Google_Client();
165
- $client->setApplicationName('Google_Pagespeed_Insights');
166
- $client->setDeveloperKey( $this->gpi_options['google_developer_key'] );
167
- $service = new Google_Service_Pagespeedonline( $client );
168
 
169
  $recheck_interval = $this->gpi_options['recheck_interval'];
170
 
@@ -209,7 +222,7 @@ class GPI_Core
209
 
210
  if ( 'both' == $strategy ) {
211
  foreach ( array( 'desktop', 'mobile' ) as $new_strategy ) {
212
- $result = $this->get_result( $service, $new_strategy, $group_type, $item, $recheck_interval, $force_recheck_all_urls );
213
 
214
  if ( ! $result ) {
215
  break 3;
@@ -226,7 +239,7 @@ class GPI_Core
226
  }
227
  }
228
  } else {
229
- $result = $this->get_result( $service, $strategy, $group_type, $item, $recheck_interval, $force_recheck_all_urls );
230
 
231
  if ( ! $result ) {
232
  break 2;
@@ -282,13 +295,13 @@ class GPI_Core
282
  {
283
  // If scan took longer than Maximum Script Run Time or Maximum Execution Time, start new scan.
284
  if ( ! self::$last_scan_finished && self::$exceeded_runtime ) {
285
- do_action( 'run_gpi', self::$force_recheck_urls, true );
286
  } else if ( ! self::$last_scan_finished ) {
287
- do_action( 'run_gpi', false, true ); // If scan failed due to Maximum Execution Time, avoid trying again with force_recheck as it could cause infinite loop.
288
  }
289
  }
290
 
291
- private function get_result( $service, $strategy, $group_type, $item, $recheck_interval, $force_recheck_all_urls, $continue = true )
292
  {
293
  global $wpdb;
294
 
@@ -323,24 +336,19 @@ class GPI_Core
323
 
324
  self::$skipped_all = false;
325
 
326
- try {
327
- $result = $service->pagespeedapi->runpagespeed( $object_url, array( 'locale' => $this->gpi_options['response_language'], 'strategy' => $strategy ) );
328
- if ( ! empty( $result ) ) {
329
- if ( isset( $result['responseCode'] ) && $result['responseCode'] == 404 ) {
330
- $this->save_bad_request( $group_type, $where_column, $object_id, $object_url );
331
- } else {
332
- $result['type'] = $group_type;
333
- $result[ $where_column ] = $object_id;
334
- $result['last_modified'] = $time;
335
- $this->save_values( $result, $where_column, $object_id, $object_url, $update, $strategy );
 
336
  }
337
  }
338
- } catch ( Exception $e ) {
339
- $exception_type = $this->exception_handler( $e, $strategy, $update, $group_type, $where_column, $object_id, $object_url );
340
-
341
- if ( 'fatal' == $exception_type ) {
342
- $continue = false;
343
- }
344
  }
345
 
346
  // Some web servers seem to have a difficult time responding to the constant requests from the Google API, sleeping inbetween each URL helps
@@ -554,30 +562,24 @@ class GPI_Core
554
  return $urls_to_check;
555
  }
556
 
557
- public function save_values( $result, $where_column, $object_id, $object_url, $update, $strategy )
558
  {
559
  global $wpdb;
560
  $gpi_page_stats = $wpdb->prefix . 'gpi_page_stats';
561
  $gpi_page_stats_values = array();
562
 
 
 
563
  // Store identifying information
564
  $gpi_page_stats_values['URL'] = $object_url;
565
  $gpi_page_stats_values['type'] = $result['type'];
566
  $gpi_page_stats_values[ $where_column ] = $result[ $where_column ];
567
  $gpi_page_stats_values[ $strategy . '_last_modified' ] = $result['last_modified'];
568
  $gpi_page_stats_values['force_recheck'] = 0;
569
- $gpi_page_stats_values['response_code'] = $result->getResponseCode();
570
- $gpi_page_stats_values[ $strategy . '_page_stats' ] = $this->get_page_stats( $result->getPageStats() );
571
-
572
- foreach ( $result->getRuleGroups() as $group_type => $group ) {
573
- if ( 'SPEED' != $group_type ) {
574
- continue;
575
- }
576
-
577
- $score_type = $strategy . '_score';
578
-
579
- $gpi_page_stats_values[ $score_type ] = $group->getScore();
580
- }
581
 
582
  if ( $update ) {
583
  $wpdb->update( $gpi_page_stats, $gpi_page_stats_values, array( $where_column => $object_id ) );
@@ -593,117 +595,15 @@ class GPI_Core
593
  $wpdb->query( $sql );
594
  }
595
 
596
- $page_reports = $this->get_page_reports( $result->getFormattedResults(), $last_updated_id, $strategy );
597
  if ( ! empty( $page_reports ) ) {
598
  foreach ( $page_reports as $page_report ) {
599
- if ( 0 == $page_report['rule_impact'] && empty( $page_report['rule_blocks'] ) ) {
600
- continue;
601
- }
602
-
603
  $wpdb->insert( $gpi_page_reports, $page_report );
604
  }
605
  }
606
 
607
  }
608
 
609
- private function get_page_stats( $page_stats_obj )
610
- {
611
- $page_stats = array(
612
- 'resource_sizes' => array(
613
- 'HTML' => number_format( $page_stats_obj->getHtmlResponseBytes() / 1000, 2, '.', '' ),
614
- 'CSS' => number_format( $page_stats_obj->getCssResponseBytes() / 1000, 2, '.', '' ),
615
- 'IMAGES' => number_format( $page_stats_obj->getImageResponseBytes() / 1000, 2, '.', '' ),
616
- 'JS' => number_format( $page_stats_obj->getJavascriptResponseBytes() / 1000, 2, '.', '' ),
617
- 'OTHER' => number_format( $page_stats_obj->getOtherResponseBytes() / 1000, 2, '.', '' )
618
- ),
619
- 'total_bytes' => $page_stats_obj->getTotalRequestBytes(),
620
- 'js_resources' => $page_stats_obj->getNumberJsResources(),
621
- 'css_resources' => $page_stats_obj->getNumberCssResources(),
622
- 'total_resources' => $page_stats_obj->getNumberResources(),
623
- 'hosts' => $page_stats_obj->getNumberHosts()
624
- );
625
-
626
- return serialize( $page_stats );
627
- }
628
-
629
- private function get_page_reports( $formatted_results, $page_id, $strategy, $page_reports = array() )
630
- {
631
- $rule_results = $formatted_results->getRuleResults();
632
-
633
- if ( ! empty( $rule_results ) ) {
634
- foreach ( $rule_results as $rulename => $results_obj ) {
635
- if ( ! in_array( 'SPEED', $results_obj->getGroups() ) ) {
636
- continue;
637
- }
638
-
639
- $page_reports[] = array(
640
- 'page_id' => $page_id,
641
- 'strategy' => $strategy,
642
- 'rule_key' => $rulename,
643
- 'rule_name' => $results_obj->localizedRuleName,
644
- 'rule_impact' => $results_obj->ruleImpact,
645
- 'rule_blocks' => $this->get_rule_blocks( $results_obj->getUrlBlocks() )
646
- );
647
- }
648
- }
649
-
650
- return $page_reports;
651
- }
652
-
653
- private function get_rule_blocks( $url_blocks_arr, $formatted_url_blocks = array() )
654
- {
655
- if ( ! empty( $url_blocks_arr ) ) {
656
- foreach ( $url_blocks_arr as $url_block_obj ) {
657
- $header = $this->format_string( $url_block_obj->getHeader() );
658
- $urls_obj = $url_block_obj->getUrls();
659
- $urls = array();
660
-
661
- foreach ( $urls_obj as $url_obj ) {
662
- $urls[] = $this->format_string( $url_obj->getResult() );
663
- }
664
-
665
- $formatted_url_blocks[] = array(
666
- 'header' => $header,
667
- 'urls' => $urls
668
- );
669
- }
670
- }
671
-
672
- if ( empty( $formatted_url_blocks ) ) {
673
- return false;
674
- } else {
675
- return serialize( $formatted_url_blocks );
676
- }
677
- }
678
-
679
- private function format_string( $string_obj )
680
- {
681
- $format = $string_obj->getFormat();
682
- $args = $string_obj->getArgs();
683
-
684
- foreach( $args as $arg ) {
685
- $key = $arg->getKey();
686
- $value = $arg->getValue();
687
- $type = $arg->getType();
688
-
689
- switch ( $type ) {
690
- case 'HYPERLINK':
691
- $format = str_replace( '{{BEGIN_LINK}}', '<a href="' . $value . '" target="_blank">', $format );
692
- $format = str_replace( '{{END_LINK}}', '</a>', $format );
693
- break;
694
-
695
- case 'URL':
696
- $format = str_replace( '{{URL}}', '<a href="' . $value . '" target="_blank">' . $value . '</a>', $format );
697
-
698
- default:
699
- $format = str_replace( '{{' . $key . '}}', $value, $format );
700
- break;
701
- }
702
- }
703
-
704
- return $format;
705
- }
706
-
707
  public function save_bad_request( $type, $where_column, $object_id, $object_url, $message = true )
708
  {
709
  global $wpdb;
@@ -736,35 +636,35 @@ class GPI_Core
736
  }
737
  }
738
 
739
- public function exception_handler( $e, $strategy, $update, $url_group_type, $where_column, $object_id, $object_url, $error_type = 'non_fatal' )
740
  {
741
- $errors = $e->getErrors();
742
 
743
- if ( isset( $errors[0]['reason'] ) && $errors[0]['reason'] == 'keyInvalid' ) {
744
 
745
  $this->update_option( 'bad_api_key', true, 'gpagespeedi_options' );
746
  $error_type = 'fatal';
747
 
748
- } else if ( isset( $errors[0]['reason'] ) && $errors[0]['reason'] == 'accessNotConfigured' ) {
749
 
750
  $this->update_option( 'pagespeed_disabled', true, 'gpagespeedi_options' );
751
  $error_type = 'fatal';
752
 
753
- } else if ( isset( $errors[0]['reason'] ) && $errors[0]['reason'] == 'ipRefererBlocked' ) {
754
 
755
  $this->update_option( 'api_restriction', true, 'gpagespeedi_options' );
756
  $error_type = 'fatal';
757
 
758
- } else if ( isset( $errors[0]['reason'] ) && $errors[0]['reason'] == 'backendError' ) {
759
 
760
  $this->save_bad_request( $url_group_type, $where_column, $object_id, $object_url, false );
761
  $this->update_option( 'backend_error', true, 'gpagespeedi_options' );
762
 
763
- } else if ( isset( $errors[0]['reason'] ) && $errors[0]['reason'] == 'mainResourceRequestFailed' ) {
764
 
765
  $this->save_bad_request( $url_group_type, $where_column, $object_id, $object_url );
766
 
767
- } else if ( $e->getCode() == '500' ) {
768
 
769
  $this->save_bad_request( $url_group_type, $where_column, $object_id, $object_url );
770
 
35
  add_action( 'googlepagespeedinsightsworker', array( $this, 'googlepagespeedinsightsworker'), 10, 2 );
36
  add_action( 'gpi_update_option', array( $this, 'update_option' ), 10, 3 );
37
  add_filter( 'gpi_check_status', array( $this, 'check_status' ), 10, 1 );
38
+ add_action( 'run_gpi', array( $this, 'run_gpi' ), 10, 3 );
39
 
40
  if ( ! wp_next_scheduled( 'gpi_prune_logs' ) ) {
41
  wp_schedule_event( time(), 'daily', 'gpi_prune_logs' );
56
 
57
  $force_recheck_all_urls = isset( $_GET['recheck'] ) ? true : false;
58
  $timeout_respawn = isset( $_GET['timeout'] ) ? true : false;
59
+ $urls_provided = isset( $_GET['urls_provided'] ) ? true : false;
60
 
61
+ if ( $urls_provided ) {
62
+ $urls_to_check = get_option( 'gpi_recheck_urls', array() );
63
+ } else {
64
+ $urls_to_check = array();
65
+ }
66
+
67
+ $this->googlepagespeedinsightsworker( $urls_to_check, $force_recheck_all_urls, $timeout_respawn );
68
  }
69
 
70
  public function cron_schedules( $schedules )
99
  {
100
  global $wpdb;
101
 
102
+ $lock = $wpdb->get_var( $wpdb->prepare( 'SELECT GET_LOCK(%s, %d)', 'gpi_lock_' . $this->gpi_options['mutex_id'], 0 ) );
103
 
104
  return $lock == 1;
105
  }
108
  {
109
  global $wpdb;
110
 
111
+ $wpdb->get_var( $wpdb->prepare( 'SELECT RELEASE_LOCK(%s)', 'gpi_lock_' . $this->gpi_options['mutex_id'] ) );
112
  }
113
 
114
  public function check_status( $busy )
124
  return $busy;
125
  }
126
 
127
+ public function run_gpi( $recheck = false, $timeout = false, $urls_provided = false )
128
  {
129
  add_option( 'gpi_check_now', true );
130
 
131
+ $query_args = array( 'gpi_check_now' => true );
132
+
133
+ if ( $recheck ) {
134
+ $query_args['recheck'] = true;
135
+ }
136
+ if ( $timeout ) {
137
+ $query_args['timeout'] = true;
138
+ }
139
+ if ( $urls_provided ) {
140
+ $query_args['urls_provided'] = true;
141
  }
142
 
143
+ $cron_url = add_query_arg( $query_args, site_url() );
144
+
145
  wp_remote_post( $cron_url, array( 'timeout' => 0.01, 'blocking' => false, 'sslverify' => apply_filters( 'https_local_ssl_verify', true ) ) );
146
  }
147
 
171
  $start_runtime = time();
172
  }
173
 
174
+ // Include our Google API
175
+ if ( ! class_exists('GPI_Pagespeed_API') ) {
176
+ require_once GPI_DIRECTORY . '/classes/class-GPI-Pagespeed-API.php';
177
  }
178
 
179
+ $developer_key = $this->gpi_options['google_developer_key'];
180
+ $Pagespeed_API = new GPI_Pagespeed_API( $developer_key );
 
 
181
 
182
  $recheck_interval = $this->gpi_options['recheck_interval'];
183
 
222
 
223
  if ( 'both' == $strategy ) {
224
  foreach ( array( 'desktop', 'mobile' ) as $new_strategy ) {
225
+ $result = $this->get_result( $Pagespeed_API, $new_strategy, $group_type, $item, $recheck_interval, $force_recheck_all_urls );
226
 
227
  if ( ! $result ) {
228
  break 3;
239
  }
240
  }
241
  } else {
242
+ $result = $this->get_result( $Pagespeed_API, $strategy, $group_type, $item, $recheck_interval, $force_recheck_all_urls );
243
 
244
  if ( ! $result ) {
245
  break 2;
295
  {
296
  // If scan took longer than Maximum Script Run Time or Maximum Execution Time, start new scan.
297
  if ( ! self::$last_scan_finished && self::$exceeded_runtime ) {
298
+ do_action( 'run_gpi', self::$force_recheck_urls, true, false );
299
  } else if ( ! self::$last_scan_finished ) {
300
+ do_action( 'run_gpi', false, true, false ); // If scan failed due to Maximum Execution Time, avoid trying again with force_recheck as it could cause infinite loop.
301
  }
302
  }
303
 
304
+ private function get_result( $Pagespeed_API, $strategy, $group_type, $item, $recheck_interval, $force_recheck_all_urls, $continue = true )
305
  {
306
  global $wpdb;
307
 
336
 
337
  self::$skipped_all = false;
338
 
339
+ $result = $Pagespeed_API->run_pagespeed( $object_url, array( 'locale' => $this->gpi_options['response_language'], 'strategy' => $strategy ) );
340
+ if ( ! empty( $result ) ) {
341
+ if ( isset( $result['responseCode'] ) && $result['responseCode'] >= 200 && $result['responseCode'] < 300 ) {
342
+ $result['type'] = $group_type;
343
+ $result[ $where_column ] = $object_id;
344
+ $result['last_modified'] = $time;
345
+ $this->save_values( $Pagespeed_API, $result, $where_column, $object_id, $object_url, $update, $strategy );
346
+ } else {
347
+ $exception_type = $this->exception_handler( $result, $strategy, $update, $group_type, $where_column, $object_id, $object_url );
348
+ if ( 'fatal' == $exception_type ) {
349
+ $continue = false;
350
  }
351
  }
 
 
 
 
 
 
352
  }
353
 
354
  // Some web servers seem to have a difficult time responding to the constant requests from the Google API, sleeping inbetween each URL helps
562
  return $urls_to_check;
563
  }
564
 
565
+ public function save_values( $Pagespeed_API, $result, $where_column, $object_id, $object_url, $update, $strategy )
566
  {
567
  global $wpdb;
568
  $gpi_page_stats = $wpdb->prefix . 'gpi_page_stats';
569
  $gpi_page_stats_values = array();
570
 
571
+ $score = $result['data']->lighthouseResult->categories->performance->score;
572
+
573
  // Store identifying information
574
  $gpi_page_stats_values['URL'] = $object_url;
575
  $gpi_page_stats_values['type'] = $result['type'];
576
  $gpi_page_stats_values[ $where_column ] = $result[ $where_column ];
577
  $gpi_page_stats_values[ $strategy . '_last_modified' ] = $result['last_modified'];
578
  $gpi_page_stats_values['force_recheck'] = 0;
579
+ $gpi_page_stats_values['response_code'] = $result['responseCode'];
580
+ $gpi_page_stats_values[ $strategy . '_lab_data' ] = $Pagespeed_API->get_lab_data( $result['data'] );
581
+ $gpi_page_stats_values[ $strategy . '_field_data' ] = $Pagespeed_API->get_field_data( $result['data'] );
582
+ $gpi_page_stats_values[ $strategy . '_score' ] = $score * 100;
 
 
 
 
 
 
 
 
583
 
584
  if ( $update ) {
585
  $wpdb->update( $gpi_page_stats, $gpi_page_stats_values, array( $where_column => $object_id ) );
595
  $wpdb->query( $sql );
596
  }
597
 
598
+ $page_reports = $Pagespeed_API->get_page_reports( $result['data'], $last_updated_id, $strategy, $this->gpi_options );
599
  if ( ! empty( $page_reports ) ) {
600
  foreach ( $page_reports as $page_report ) {
 
 
 
 
601
  $wpdb->insert( $gpi_page_reports, $page_report );
602
  }
603
  }
604
 
605
  }
606
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
607
  public function save_bad_request( $type, $where_column, $object_id, $object_url, $message = true )
608
  {
609
  global $wpdb;
636
  }
637
  }
638
 
639
+ public function exception_handler( $result, $strategy, $update, $url_group_type, $where_column, $object_id, $object_url, $error_type = 'non_fatal' )
640
  {
641
+ $errors = isset( $result['data']->error->errors ) ? $result['data']->error->errors : false;
642
 
643
+ if ( isset( $errors[0]->reason ) && $errors[0]->reason == 'keyInvalid' ) {
644
 
645
  $this->update_option( 'bad_api_key', true, 'gpagespeedi_options' );
646
  $error_type = 'fatal';
647
 
648
+ } else if ( isset( $errors[0]->reason ) && $errors[0]->reason == 'accessNotConfigured' ) {
649
 
650
  $this->update_option( 'pagespeed_disabled', true, 'gpagespeedi_options' );
651
  $error_type = 'fatal';
652
 
653
+ } else if ( isset( $errors[0]->reason ) && $errors[0]->reason == 'ipRefererBlocked' ) {
654
 
655
  $this->update_option( 'api_restriction', true, 'gpagespeedi_options' );
656
  $error_type = 'fatal';
657
 
658
+ } else if ( isset( $errors[0]->reason ) && $errors[0]->reason == 'backendError' ) {
659
 
660
  $this->save_bad_request( $url_group_type, $where_column, $object_id, $object_url, false );
661
  $this->update_option( 'backend_error', true, 'gpagespeedi_options' );
662
 
663
+ } else if ( isset( $errors[0]->reason ) && $errors[0]->reason == 'mainResourceRequestFailed' ) {
664
 
665
  $this->save_bad_request( $url_group_type, $where_column, $object_id, $object_url );
666
 
667
+ } else if ( $result['responseCode'] == '500' ) {
668
 
669
  $this->save_bad_request( $url_group_type, $where_column, $object_id, $object_url );
670
 
classes/class-GPI-List-Table.php CHANGED
@@ -179,7 +179,7 @@ class GPI_List_Table extends WP_List_Table
179
  ?>
180
  <ol class="no-items">
181
  <li><?php _e( 'Make sure that you have entered your Google API key on the ', 'gpagespeedi' );?><a href="?page=<?php echo sanitize_text_field( $_REQUEST['page'] ); ?>&amp;render=options"><?php _e( 'Options', 'gpagespeedi' ); ?></a> <?php _e( 'page', 'gpagespeedi' ); ?>.</li>
182
- <li><?php _e( 'Make sure that you have enabled "PageSpeed Insights API" from the Services page of the ', 'gpagespeedi' );?><a href="https://code.google.com/apis/console/">Google Console</a>.</li>
183
  <li><?php _e( 'Make sure that your URLs are publicly accessible', 'gpagespeedi' ); ?>.</li>
184
  </ol>
185
  <?php
@@ -611,20 +611,24 @@ class GPI_List_Table extends WP_List_Table
611
 
612
  $all_types = apply_filters( 'gpi_filter_options', array(), true );
613
 
 
 
614
  if ( 'default' == $this->type ) {
615
  $filter = isset( $_GET['filter'] ) ? sanitize_text_field( $_GET['filter'] ) : 'all';
616
  $filter = 'all' != $filter ? $filter : implode( '|', $all_types );
617
  $filter = 'gpi_custom_urls' != $filter ? $filter : apply_filters( 'gpi_custom_url_labels', $filter );
618
 
619
- $data = $wpdb->get_results( $wpdb->prepare(
620
- "
621
- SELECT $db_columns
622
- FROM $this->table
623
- WHERE type REGEXP %s
624
- ORDER BY $orderby $order
625
- ",
626
- $filter
627
- ), ARRAY_A );
 
 
628
  } else {
629
  $data = $wpdb->get_results(
630
  "
179
  ?>
180
  <ol class="no-items">
181
  <li><?php _e( 'Make sure that you have entered your Google API key on the ', 'gpagespeedi' );?><a href="?page=<?php echo sanitize_text_field( $_REQUEST['page'] ); ?>&amp;render=options"><?php _e( 'Options', 'gpagespeedi' ); ?></a> <?php _e( 'page', 'gpagespeedi' ); ?>.</li>
182
+ <li><?php _e( 'Make sure that you have enabled "PageSpeed Insights API" from the Services page of the ', 'gpagespeedi' );?><a href="https://code.google.com/apis/console/"> <?php _e( 'Google Console', 'gpagespeedi' ); ?></a>.</li>
183
  <li><?php _e( 'Make sure that your URLs are publicly accessible', 'gpagespeedi' ); ?>.</li>
184
  </ol>
185
  <?php
611
 
612
  $all_types = apply_filters( 'gpi_filter_options', array(), true );
613
 
614
+ $data = array();
615
+
616
  if ( 'default' == $this->type ) {
617
  $filter = isset( $_GET['filter'] ) ? sanitize_text_field( $_GET['filter'] ) : 'all';
618
  $filter = 'all' != $filter ? $filter : implode( '|', $all_types );
619
  $filter = 'gpi_custom_urls' != $filter ? $filter : apply_filters( 'gpi_custom_url_labels', $filter );
620
 
621
+ if ( $filter ) {
622
+ $data = $wpdb->get_results( $wpdb->prepare(
623
+ "
624
+ SELECT $db_columns
625
+ FROM $this->table
626
+ WHERE type REGEXP %s
627
+ ORDER BY $orderby $order
628
+ ",
629
+ $filter
630
+ ), ARRAY_A );
631
+ }
632
  } else {
633
  $data = $wpdb->get_results(
634
  "
classes/class-GPI-Pagespeed-API.php ADDED
@@ -0,0 +1,227 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * =======================================
4
+ * Google Pagespeed Insights API
5
+ * =======================================
6
+ *
7
+ *
8
+ * @author Matt Keys <https://profiles.wordpress.org/mattkeys>
9
+ */
10
+
11
+ if ( ! defined( 'GPI_PLUGIN_FILE' ) ) {
12
+ die();
13
+ }
14
+
15
+ class GPI_Pagespeed_API
16
+ {
17
+
18
+ private $api_baseurl = 'https://www.googleapis.com/pagespeedonline/v5/runPagespeed';
19
+ private $developer_key;
20
+ private $lab_data_indexes;
21
+ private $audits_to_skip;
22
+
23
+ public function __construct( $developer_key )
24
+ {
25
+ $this->developer_key = $developer_key;
26
+ $this->lab_data_indexes = apply_filters( 'GPI_lab_data_indexes', array(
27
+ 'first-contentful-paint',
28
+ 'first-meaningful-paint',
29
+ 'speed-index',
30
+ 'interactive',
31
+ 'first-cpu-idle',
32
+ 'estimated-input-latency'
33
+ ) );
34
+ $this->audits_to_skip = apply_filters( 'GPI_audits_to_skip', array(
35
+ 'final-screenshot',
36
+ 'metrics',
37
+ 'network-requests'
38
+ ) );
39
+ }
40
+
41
+ public function run_pagespeed( $object_url, $options )
42
+ {
43
+ $query_args = array(
44
+ 'url' => $object_url,
45
+ 'key' => $this->developer_key,
46
+ 'locale' => isset( $options['locale'] ) ? $options['locale'] : 'en_US',
47
+ 'strategy' => isset( $options['strategy'] ) ? $options['strategy'] : 'desktop'
48
+ );
49
+
50
+ $api_url = add_query_arg( $query_args, $this->api_baseurl );
51
+
52
+ $api_request = wp_remote_get( $api_url, array(
53
+ 'timeout' => apply_filters( 'GPI_remote_get_timeout', 300 )
54
+ ) );
55
+
56
+ $api_response_code = wp_remote_retrieve_response_code( $api_request );
57
+ $api_response_body = json_decode( wp_remote_retrieve_body( $api_request ) );
58
+
59
+ return array(
60
+ 'responseCode' => $api_response_code,
61
+ 'data' => $api_response_body
62
+ );
63
+ }
64
+
65
+ public function get_lab_data( $result, $lab_data = array() )
66
+ {
67
+ foreach ( $this->lab_data_indexes as $index ) {
68
+ if ( ! isset( $result->lighthouseResult->audits->$index ) ) {
69
+ continue;
70
+ }
71
+
72
+ $lab_data[] = array(
73
+ 'title' => $result->lighthouseResult->audits->$index->title,
74
+ 'description' => $this->parse_markdown_style_links( $result->lighthouseResult->audits->$index->description ),
75
+ 'score' => $result->lighthouseResult->audits->$index->score,
76
+ 'displayValue' => $result->lighthouseResult->audits->$index->displayValue
77
+ );
78
+ }
79
+
80
+ return serialize( $lab_data );
81
+ }
82
+
83
+ public function get_field_data( $result, $field_data = array() )
84
+ {
85
+ if ( ! isset( $result->loadingExperience->metrics ) ) {
86
+ return $field_data;
87
+ }
88
+
89
+ return serialize( $result->loadingExperience->metrics );
90
+ }
91
+
92
+ public function get_page_reports( $result, $page_id, $strategy, $options, $page_reports = array() )
93
+ {
94
+ $rule_results = $result->lighthouseResult->audits;
95
+
96
+ if ( ! empty( $rule_results ) ) {
97
+ foreach ( $rule_results as $rulename => $results_obj ) {
98
+
99
+ if ( in_array( $rulename, $this->lab_data_indexes ) ) {
100
+ continue;
101
+ }
102
+
103
+ if ( in_array( $rulename, $this->audits_to_skip ) ) {
104
+ continue;
105
+ }
106
+
107
+ if ( 'screenshot-thumbnails' == $rulename && ! $options['store_screenshots'] ) {
108
+ continue;
109
+ }
110
+
111
+ $page_reports[] = array(
112
+ 'page_id' => $page_id,
113
+ 'strategy' => $strategy,
114
+ 'rule_key' => $rulename,
115
+ 'rule_name' => $results_obj->title,
116
+ 'rule_score' => $results_obj->score,
117
+ 'rule_type' => isset( $results_obj->details->type ) ? $results_obj->details->type : 'n/a',
118
+ 'rule_blocks' => $this->get_rule_blocks( $results_obj )
119
+ );
120
+ }
121
+ }
122
+
123
+ return $page_reports;
124
+ }
125
+
126
+ private function get_rule_blocks( $results_obj, $rule_blocks = array() )
127
+ {
128
+ if ( isset( $results_obj->description ) ) {
129
+ $rule_blocks['description'] = $this->parse_markdown_style_links( $results_obj->description );
130
+ }
131
+
132
+ if ( isset( $results_obj->scoreDisplayMode ) ) {
133
+ $rule_blocks['score_display_mode'] = $results_obj->scoreDisplayMode;
134
+ }
135
+
136
+ if ( isset( $results_obj->displayValue ) ) {
137
+ $rule_blocks['display_value'] = $results_obj->displayValue;
138
+ } else {
139
+ $rule_blocks['display_value'] = '';
140
+ }
141
+
142
+ $keys_to_number_format = array(
143
+ 'url',
144
+ 'wastedMs',
145
+ 'scriptParseCompile',
146
+ 'total',
147
+ 'scripting',
148
+ 'duration',
149
+ 'totalBytes',
150
+ 'wastedBytes',
151
+ 'cacheLifetimeMs'
152
+ );
153
+
154
+ if ( isset( $results_obj->details->items ) ) {
155
+ foreach ( $results_obj->details->items as $index => $data ) {
156
+ foreach ( $data as $key => $value ) {
157
+ if ( ! in_array( $key, $keys_to_number_format ) ) {
158
+ continue;
159
+ }
160
+
161
+ if ( 'url' == $key ) {
162
+ $value = $this->link_urls( $value );
163
+ } else if ( 'cacheLifetimeMs' == $key ) {
164
+ $value = $this->human_readable_timing( $value );
165
+ } else {
166
+ $value = number_format( $value );
167
+ }
168
+
169
+ $results_obj->details->items[ $index ]->$key = $value;
170
+ }
171
+ }
172
+ }
173
+
174
+ if ( isset( $results_obj->details ) ) {
175
+ $rule_blocks['details'] = $results_obj->details;
176
+ }
177
+
178
+ return serialize( $rule_blocks );
179
+ }
180
+
181
+ private function human_readable_timing( $value )
182
+ {
183
+ if ( empty( $value ) ) {
184
+ return $value;
185
+ }
186
+
187
+ $time = $value / 1000;
188
+
189
+ $tokens = array (
190
+ 31536000 => __( 'year', 'gpagespeedi' ),
191
+ 2592000 => __( 'month', 'gpagespeedi' ),
192
+ 604800 => __( 'week', 'gpagespeedi' ),
193
+ 86400 => __( 'day', 'gpagespeedi' ),
194
+ 3600 => __( 'hour', 'gpagespeedi' ),
195
+ 60 => __( 'minute', 'gpagespeedi' ),
196
+ 1 => __( 'second', 'gpagespeedi' )
197
+ );
198
+
199
+ foreach ( $tokens as $unit => $text ) {
200
+ if ( $time < $unit ) {
201
+ continue;
202
+ }
203
+ $number_of_units = floor( $time / $unit );
204
+
205
+ return $number_of_units . ' ' . $text . ( ( $number_of_units > 1 ) ? _x( 's', 'make preceeding time unit plural', 'gpagespeedi' ) : '' );
206
+ }
207
+ }
208
+
209
+ private function link_urls( $value )
210
+ {
211
+ $url = esc_url( $value );
212
+
213
+ if ( ! $url ) {
214
+ return $value;
215
+ }
216
+
217
+ return '<a href="' . $url . '" target="_blank">' . $value . '</a>';
218
+ }
219
+
220
+ private function parse_markdown_style_links( $string )
221
+ {
222
+ $replace = '<a href="${2}" target="_blank">${1}</a>';
223
+
224
+ return preg_replace('/\[(.*?)\]\((.*?)\)/', $replace, $string );
225
+ }
226
+
227
+ }
classes/class-GPI-Uninstall.php CHANGED
@@ -37,6 +37,11 @@ class GPI_Uninstall
37
  delete_option('gpagespeedi_ui_options');
38
  delete_option('gpagespeedi_upgrade_recheck_required');
39
  delete_option('gpi_progress');
 
 
 
 
 
40
 
41
  wp_clear_scheduled_hook( 'gpi_prune_logs' );
42
  wp_clear_scheduled_hook( 'googlepagespeedinsightsworker' );
37
  delete_option('gpagespeedi_ui_options');
38
  delete_option('gpagespeedi_upgrade_recheck_required');
39
  delete_option('gpi_progress');
40
+ delete_option('gpi_recheck_urls');
41
+ delete_option('gpi_missed_url_groups');
42
+ delete_option('gpi_error_message');
43
+ delete_option('gpi_abort_scan');
44
+ delete_option('gpi_check_now');
45
 
46
  wp_clear_scheduled_hook( 'gpi_prune_logs' );
47
  wp_clear_scheduled_hook( 'googlepagespeedinsightsworker' );
google-pagespeed-insights.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Google Pagespeed Insights
4
  Plugin URI: http://mattkeys.me
5
  Description: Google Pagespeed Insights
6
  Author: Matt Keys
7
- Version: 3.0.4
8
  Author URI: http://mattkeys.me
9
  */
10
 
@@ -38,9 +38,14 @@ if ( ! defined( 'GPI_PUBLIC_PATH' ) ) {
38
  define( 'GPI_PUBLIC_PATH', plugin_dir_url( __FILE__ ) );
39
  }
40
 
 
 
 
 
 
41
  // Internal version number
42
  if ( ! defined( 'GPI_VERSION' ) ) {
43
- define( 'GPI_VERSION', '3.0.0' );
44
  }
45
 
46
  if ( is_admin() ) {
@@ -55,4 +60,4 @@ if ( is_admin() ) {
55
  }
56
  }
57
 
58
- require 'classes/class-GPI-Core.php';
4
  Plugin URI: http://mattkeys.me
5
  Description: Google Pagespeed Insights
6
  Author: Matt Keys
7
+ Version: 4.0.0
8
  Author URI: http://mattkeys.me
9
  */
10
 
38
  define( 'GPI_PUBLIC_PATH', plugin_dir_url( __FILE__ ) );
39
  }
40
 
41
+ // Plugin basename
42
+ if ( ! defined( 'GPI_BASENAME' ) ) {
43
+ define( 'GPI_BASENAME', plugin_basename( __FILE__ ) );
44
+ }
45
+
46
  // Internal version number
47
  if ( ! defined( 'GPI_VERSION' ) ) {
48
+ define( 'GPI_VERSION', '4.0.0' );
49
  }
50
 
51
  if ( is_admin() ) {
60
  }
61
  }
62
 
63
+ require 'classes/class-GPI-Core.php';
lib/google-api-php-client/LICENSE DELETED
@@ -1,203 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
179
-
180
- To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "[]"
182
- replaced with your own identifying information. (Don't include
183
- the brackets!) The text should be enclosed in the appropriate
184
- comment syntax for the file format. We also recommend that a
185
- file or class name and description of purpose be included on the
186
- same "printed page" as the copyright notice for easier
187
- identification within third-party archives.
188
-
189
- Copyright [yyyy] [name of copyright owner]
190
-
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
194
-
195
- http://www.apache.org/licenses/LICENSE-2.0
196
-
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.
202
-
203
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/README.md DELETED
@@ -1,368 +0,0 @@
1
- [![Build Status](https://travis-ci.org/google/google-api-php-client.svg?branch=master)](https://travis-ci.org/google/google-api-php-client)
2
-
3
- # Google APIs Client Library for PHP #
4
-
5
- ## Library maintenance
6
- This client library is supported but in maintenance mode only. We are fixing necessary bugs and adding essential features to ensure this library continues to meet your needs for accessing Google APIs. Non-critical issues will be closed. Any issue may be reopened if it is causing ongoing problems.
7
-
8
- ## Description ##
9
- The Google API Client Library enables you to work with Google APIs such as Google+, Drive, or YouTube on your server.
10
-
11
- ## Beta ##
12
- This library is in Beta. We're comfortable enough with the stability and features of the library that we want you to build real production applications on it. We will make an effort to support the public and protected surface of the library and maintain backwards compatibility in the future. While we are still in Beta, we reserve the right to make incompatible changes.
13
-
14
- ## Requirements ##
15
- * [PHP 5.4.0 or higher](http://www.php.net/)
16
-
17
- ## Google Cloud Platform APIs
18
- If you're looking to call the **Google Cloud Platform** APIs, you will want to use the [Google Cloud PHP](https://github.com/googlecloudplatform/google-cloud-php) library instead of this one.
19
-
20
- ## Developer Documentation ##
21
- http://developers.google.com/api-client-library/php
22
-
23
- ## Installation ##
24
-
25
- You can use **Composer** or simply **Download the Release**
26
-
27
- ### Composer
28
-
29
- The preferred method is via [composer](https://getcomposer.org). Follow the
30
- [installation instructions](https://getcomposer.org/doc/00-intro.md) if you do not already have
31
- composer installed.
32
-
33
- Once composer is installed, execute the following command in your project root to install this library:
34
-
35
- ```sh
36
- composer require google/apiclient:^2.0
37
- ```
38
-
39
- Finally, be sure to include the autoloader:
40
-
41
- ```php
42
- require_once '/path/to/your-project/vendor/autoload.php';
43
- ```
44
-
45
- ### Download the Release
46
-
47
- If you abhor using composer, you can download the package in its entirety. The [Releases](https://github.com/google/google-api-php-client/releases) page lists all stable versions. Download any file
48
- with the name `google-api-php-client-[RELEASE_NAME].zip` for a package including this library and its dependencies.
49
-
50
- Uncompress the zip file you download, and include the autoloader in your project:
51
-
52
- ```php
53
- require_once '/path/to/google-api-php-client/vendor/autoload.php';
54
- ```
55
-
56
- For additional installation and setup instructions, see [the documentation](https://developers.google.com/api-client-library/php/start/installation).
57
-
58
- ## Examples ##
59
- See the [`examples/`](examples) directory for examples of the key client features. You can
60
- view them in your browser by running the php built-in web server.
61
-
62
- ```
63
- $ php -S localhost:8000 -t examples/
64
- ```
65
-
66
- And then browsing to the host and port you specified
67
- (in the above example, `http://localhost:8000`).
68
-
69
- ### Basic Example ###
70
-
71
- ```php
72
- // include your composer dependencies
73
- require_once 'vendor/autoload.php';
74
-
75
- $client = new Google_Client();
76
- $client->setApplicationName("Client_Library_Examples");
77
- $client->setDeveloperKey("YOUR_APP_KEY");
78
-
79
- $service = new Google_Service_Books($client);
80
- $optParams = array('filter' => 'free-ebooks');
81
- $results = $service->volumes->listVolumes('Henry David Thoreau', $optParams);
82
-
83
- foreach ($results as $item) {
84
- echo $item['volumeInfo']['title'], "<br /> \n";
85
- }
86
- ```
87
-
88
- ### Authentication with OAuth ###
89
-
90
- > An example of this can be seen in [`examples/simple-file-upload.php`](examples/simple-file-upload.php).
91
-
92
- 1. Follow the instructions to [Create Web Application Credentials](https://developers.google.com/api-client-library/php/auth/web-app#creatingcred)
93
- 1. Download the JSON credentials
94
- 1. Set the path to these credentials using `Google_Client::setAuthConfig`:
95
-
96
- ```php
97
- $client = new Google_Client();
98
- $client->setAuthConfig('/path/to/client_credentials.json');
99
- ```
100
-
101
- 1. Set the scopes required for the API you are going to call
102
-
103
- ```php
104
- $client->addScope(Google_Service_Drive::DRIVE);
105
- ```
106
-
107
- 1. Set your application's redirect URI
108
-
109
- ```php
110
- // Your redirect URI can be any registered URI, but in this example
111
- // we redirect back to this same page
112
- $redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
113
- $client->setRedirectUri($redirect_uri);
114
- ```
115
-
116
- 1. In the script handling the redirect URI, exchange the authorization code for an access token:
117
-
118
- ```php
119
- if (isset($_GET['code'])) {
120
- $token = $client->fetchAccessTokenWithAuthCode($_GET['code']);
121
- }
122
- ```
123
-
124
- ### Authentication with Service Accounts ###
125
-
126
- > An example of this can be seen in [`examples/service-account.php`](examples/service-account.php).
127
-
128
- 1. Follow the instructions to [Create a Service Account](https://developers.google.com/api-client-library/php/auth/service-accounts#creatinganaccount)
129
- 1. Download the JSON credentials
130
- 1. Set the path to these credentials using the `GOOGLE_APPLICATION_CREDENTIALS` environment variable:
131
-
132
- ```php
133
- putenv('GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json');
134
- ```
135
-
136
- 1. Tell the Google client to use your service account credentials to authenticate:
137
-
138
- ```php
139
- $client = new Google_Client();
140
- $client->useApplicationDefaultCredentials();
141
- ```
142
-
143
- 1. Set the scopes required for the API you are going to call
144
-
145
- ```php
146
- $client->addScope(Google_Service_Drive::DRIVE);
147
- ```
148
-
149
- 1. If you have delegated domain-wide access to the service account and you want to impersonate a user account, specify the email address of the user account using the method setSubject:
150
-
151
- ```php
152
- $client->setSubject($user_to_impersonate);
153
- ```
154
-
155
- ### Making Requests ###
156
-
157
- The classes used to call the API in [google-api-php-client-services](https://github.com/Google/google-api-php-client-services) are autogenerated. They map directly to the JSON requests and responses found in the [APIs Explorer](https://developers.google.com/apis-explorer/#p/).
158
-
159
- A JSON request to the [Datastore API](https://developers.google.com/apis-explorer/#p/datastore/v1beta3/datastore.projects.runQuery) would look like this:
160
-
161
- ```json
162
- POST https://datastore.googleapis.com/v1beta3/projects/YOUR_PROJECT_ID:runQuery?key=YOUR_API_KEY
163
-
164
- {
165
- "query": {
166
- "kind": [{
167
- "name": "Book"
168
- }],
169
- "order": [{
170
- "property": {
171
- "name": "title"
172
- },
173
- "direction": "descending"
174
- }],
175
- "limit": 10
176
- }
177
- }
178
- ```
179
-
180
- Using this library, the same call would look something like this:
181
-
182
- ```php
183
- // create the datastore service class
184
- $datastore = new Google_Service_Datastore($client);
185
-
186
- // build the query - this maps directly to the JSON
187
- $query = new Google_Service_Datastore_Query([
188
- 'kind' => [
189
- [
190
- 'name' => 'Book',
191
- ],
192
- ],
193
- 'order' => [
194
- 'property' => [
195
- 'name' => 'title',
196
- ],
197
- 'direction' => 'descending',
198
- ],
199
- 'limit' => 10,
200
- ]);
201
-
202
- // build the request and response
203
- $request = new Google_Service_Datastore_RunQueryRequest(['query' => $query]);
204
- $response = $datastore->projects->runQuery('YOUR_DATASET_ID', $request);
205
- ```
206
-
207
- However, as each property of the JSON API has a corresponding generated class, the above code could also be written like this:
208
-
209
- ```php
210
- // create the datastore service class
211
- $datastore = new Google_Service_Datastore($client);
212
-
213
- // build the query
214
- $request = new Google_Service_Datastore_RunQueryRequest();
215
- $query = new Google_Service_Datastore_Query();
216
- // - set the order
217
- $order = new Google_Service_Datastore_PropertyOrder();
218
- $order->setDirection('descending');
219
- $property = new Google_Service_Datastore_PropertyReference();
220
- $property->setName('title');
221
- $order->setProperty($property);
222
- $query->setOrder([$order]);
223
- // - set the kinds
224
- $kind = new Google_Service_Datastore_KindExpression();
225
- $kind->setName('Book');
226
- $query->setKinds([$kind]);
227
- // - set the limit
228
- $query->setLimit(10);
229
-
230
- // add the query to the request and make the request
231
- $request->setQuery($query);
232
- $response = $datastore->projects->runQuery('YOUR_DATASET_ID', $request);
233
- ```
234
-
235
- The method used is a matter of preference, but *it will be very difficult to use this library without first understanding the JSON syntax for the API*, so it is recommended to look at the [APIs Explorer](https://developers.google.com/apis-explorer/#p/) before using any of the services here.
236
-
237
- ### Making HTTP Requests Directly ###
238
-
239
- If Google Authentication is desired for external applications, or a Google API is not available yet in this library, HTTP requests can be made directly.
240
-
241
- The `authorize` method returns an authorized [Guzzle Client](http://docs.guzzlephp.org/), so any request made using the client will contain the corresponding authorization.
242
-
243
- ```php
244
- // create the Google client
245
- $client = new Google_Client();
246
-
247
- /**
248
- * Set your method for authentication. Depending on the API, This could be
249
- * directly with an access token, API key, or (recommended) using
250
- * Application Default Credentials.
251
- */
252
- $client->useApplicationDefaultCredentials();
253
- $client->addScope(Google_Service_Plus::PLUS_ME);
254
-
255
- // returns a Guzzle HTTP Client
256
- $httpClient = $client->authorize();
257
-
258
- // make an HTTP request
259
- $response = $httpClient->get('https://www.googleapis.com/plus/v1/people/me');
260
- ```
261
-
262
- ### Caching ###
263
-
264
- It is recommended to use another caching library to improve performance. This can be done by passing a [PSR-6](http://www.php-fig.org/psr/psr-6/) compatible library to the client:
265
-
266
- ```php
267
- $cache = new Stash\Pool(new Stash\Driver\FileSystem);
268
- $client->setCache($cache);
269
- ```
270
-
271
- In this example we use [StashPHP](http://www.stashphp.com/). Add this to your project with composer:
272
-
273
- ```
274
- composer require tedivm/stash
275
- ```
276
-
277
- ### Updating Tokens ###
278
-
279
- When using [Refresh Tokens](https://developers.google.com/identity/protocols/OAuth2InstalledApp#refresh) or [Service Account Credentials](https://developers.google.com/identity/protocols/OAuth2ServiceAccount#overview), it may be useful to perform some action when a new access token is granted. To do this, pass a callable to the `setTokenCallback` method on the client:
280
-
281
- ```php
282
- $logger = new Monolog\Logger;
283
- $tokenCallback = function ($cacheKey, $accessToken) use ($logger) {
284
- $logger->debug(sprintf('new access token received at cache key %s', $cacheKey));
285
- };
286
- $client->setTokenCallback($tokenCallback);
287
- ```
288
-
289
- ### Debugging Your HTTP Request using Charles ###
290
-
291
- It is often very useful to debug your API calls by viewing the raw HTTP request. This library supports the use of [Charles Web Proxy](https://www.charlesproxy.com/documentation/getting-started/). Download and run Charles, and then capture all HTTP traffic through Charles with the following code:
292
-
293
- ```php
294
- // FOR DEBUGGING ONLY
295
- $httpClient = new GuzzleHttp\Client([
296
- 'proxy' => 'localhost:8888', // by default, Charles runs on localhost port 8888
297
- 'verify' => false, // otherwise HTTPS requests will fail.
298
- ]);
299
-
300
- $client = new Google_Client();
301
- $client->setHttpClient($httpClient);
302
- ```
303
-
304
- Now all calls made by this library will appear in the Charles UI.
305
-
306
- One additional step is required in Charles to view SSL requests. Go to **Charles > Proxy > SSL Proxying Settings** and add the domain you'd like captured. In the case of the Google APIs, this is usually `*.googleapis.com`.
307
-
308
- ### Service Specific Examples ###
309
-
310
- YouTube: https://github.com/youtube/api-samples/tree/master/php
311
-
312
- ## How Do I Contribute? ##
313
-
314
- Please see the [contributing](CONTRIBUTING.md) page for more information. In particular, we love pull requests - but please make sure to sign the [contributor license agreement](https://developers.google.com/api-client-library/php/contribute).
315
-
316
- ## Frequently Asked Questions ##
317
-
318
- ### What do I do if something isn't working? ###
319
-
320
- For support with the library the best place to ask is via the google-api-php-client tag on StackOverflow: http://stackoverflow.com/questions/tagged/google-api-php-client
321
-
322
- If there is a specific bug with the library, please [file a issue](https://github.com/google/google-api-php-client/issues) in the Github issues tracker, including an example of the failing code and any specific errors retrieved. Feature requests can also be filed, as long as they are core library requests, and not-API specific: for those, refer to the documentation for the individual APIs for the best place to file requests. Please try to provide a clear statement of the problem that the feature would address.
323
-
324
- ### I want an example of X! ###
325
-
326
- If X is a feature of the library, file away! If X is an example of using a specific service, the best place to go is to the teams for those specific APIs - our preference is to link to their examples rather than add them to the library, as they can then pin to specific versions of the library. If you have any examples for other APIs, let us know and we will happily add a link to the README above!
327
-
328
- ### Why do you still support 5.2? ###
329
-
330
- When we started working on the 1.0.0 branch we knew there were several fundamental issues to fix with the 0.6 releases of the library. At that time we looked at the usage of the library, and other related projects, and determined that there was still a large and active base of PHP 5.2 installs. You can see this in statistics such as the PHP versions chart in the WordPress stats: http://wordpress.org/about/stats/. We will keep looking at the types of usage we see, and try to take advantage of newer PHP features where possible.
331
-
332
- ### Why does Google_..._Service have weird names? ###
333
-
334
- The _Service classes are generally automatically generated from the API discovery documents: https://developers.google.com/discovery/. Sometimes new features are added to APIs with unusual names, which can cause some unexpected or non-standard style naming in the PHP classes.
335
-
336
- ### How do I deal with non-JSON response types? ###
337
-
338
- Some services return XML or similar by default, rather than JSON, which is what the library supports. You can request a JSON response by adding an 'alt' argument to optional params that is normally the last argument to a method call:
339
-
340
- ```
341
- $opt_params = array(
342
- 'alt' => "json"
343
- );
344
- ```
345
-
346
- ### How do I set a field to null? ###
347
-
348
- The library strips out nulls from the objects sent to the Google APIs as its the default value of all of the uninitialized properties. To work around this, set the field you want to null to `Google_Model::NULL_VALUE`. This is a placeholder that will be replaced with a true null when sent over the wire.
349
-
350
- ## Code Quality ##
351
-
352
- Run the PHPUnit tests with PHPUnit. You can configure an API key and token in BaseTest.php to run all calls, but this will require some setup on the Google Developer Console.
353
-
354
- phpunit tests/
355
-
356
- ### Coding Style
357
-
358
- To check for coding style violations, run
359
-
360
- ```
361
- vendor/bin/phpcs src --standard=style/ruleset.xml -np
362
- ```
363
-
364
- To automatically fix (fixable) coding style violations, run
365
-
366
- ```
367
- vendor/bin/phpcbf src --standard=style/ruleset.xml
368
- ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/src/Google/AccessToken/Revoke.php DELETED
@@ -1,78 +0,0 @@
1
- <?php
2
-
3
- /*
4
- * Copyright 2008 Google Inc.
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- */
18
-
19
- use Google\Auth\HttpHandler\HttpHandlerFactory;
20
- use GuzzleHttp\ClientInterface;
21
- use GuzzleHttp\Psr7;
22
- use GuzzleHttp\Psr7\Request;
23
-
24
- /**
25
- * Wrapper around Google Access Tokens which provides convenience functions
26
- *
27
- */
28
- class Google_AccessToken_Revoke
29
- {
30
- /**
31
- * @var GuzzleHttp\ClientInterface The http client
32
- */
33
- private $http;
34
-
35
- /**
36
- * Instantiates the class, but does not initiate the login flow, leaving it
37
- * to the discretion of the caller.
38
- */
39
- public function __construct(ClientInterface $http = null)
40
- {
41
- $this->http = $http;
42
- }
43
-
44
- /**
45
- * Revoke an OAuth2 access token or refresh token. This method will revoke the current access
46
- * token, if a token isn't provided.
47
- *
48
- * @param string|array $token The token (access token or a refresh token) that should be revoked.
49
- * @return boolean Returns True if the revocation was successful, otherwise False.
50
- */
51
- public function revokeToken($token)
52
- {
53
- if (is_array($token)) {
54
- if (isset($token['refresh_token'])) {
55
- $token = $token['refresh_token'];
56
- } else {
57
- $token = $token['access_token'];
58
- }
59
- }
60
-
61
- $body = Psr7\stream_for(http_build_query(array('token' => $token)));
62
- $request = new Request(
63
- 'POST',
64
- Google_Client::OAUTH2_REVOKE_URI,
65
- [
66
- 'Cache-Control' => 'no-store',
67
- 'Content-Type' => 'application/x-www-form-urlencoded',
68
- ],
69
- $body
70
- );
71
-
72
- $httpHandler = HttpHandlerFactory::build($this->http);
73
-
74
- $response = $httpHandler($request);
75
-
76
- return $response->getStatusCode() == 200;
77
- }
78
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/src/Google/AccessToken/Verify.php DELETED
@@ -1,269 +0,0 @@
1
- <?php
2
-
3
- /*
4
- * Copyright 2008 Google Inc.
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- */
18
-
19
- use Firebase\JWT\ExpiredException as ExpiredExceptionV3;
20
- use GuzzleHttp\Client;
21
- use GuzzleHttp\ClientInterface;
22
- use Psr\Cache\CacheItemPoolInterface;
23
- use Google\Auth\Cache\MemoryCacheItemPool;
24
- use Stash\Driver\FileSystem;
25
- use Stash\Pool;
26
-
27
- /**
28
- * Wrapper around Google Access Tokens which provides convenience functions
29
- *
30
- */
31
- class Google_AccessToken_Verify
32
- {
33
- const FEDERATED_SIGNON_CERT_URL = 'https://www.googleapis.com/oauth2/v3/certs';
34
- const OAUTH2_ISSUER = 'accounts.google.com';
35
- const OAUTH2_ISSUER_HTTPS = 'https://accounts.google.com';
36
-
37
- /**
38
- * @var GuzzleHttp\ClientInterface The http client
39
- */
40
- private $http;
41
-
42
- /**
43
- * @var Psr\Cache\CacheItemPoolInterface cache class
44
- */
45
- private $cache;
46
-
47
- /**
48
- * Instantiates the class, but does not initiate the login flow, leaving it
49
- * to the discretion of the caller.
50
- */
51
- public function __construct(
52
- ClientInterface $http = null,
53
- CacheItemPoolInterface $cache = null,
54
- $jwt = null
55
- ) {
56
- if (null === $http) {
57
- $http = new Client();
58
- }
59
-
60
- if (null === $cache) {
61
- $cache = new MemoryCacheItemPool;
62
- }
63
-
64
- $this->http = $http;
65
- $this->cache = $cache;
66
- $this->jwt = $jwt ?: $this->getJwtService();
67
- }
68
-
69
- /**
70
- * Verifies an id token and returns the authenticated apiLoginTicket.
71
- * Throws an exception if the id token is not valid.
72
- * The audience parameter can be used to control which id tokens are
73
- * accepted. By default, the id token must have been issued to this OAuth2 client.
74
- *
75
- * @param $audience
76
- * @return array the token payload, if successful
77
- */
78
- public function verifyIdToken($idToken, $audience = null)
79
- {
80
- if (empty($idToken)) {
81
- throw new LogicException('id_token cannot be null');
82
- }
83
-
84
- // set phpseclib constants if applicable
85
- $this->setPhpsecConstants();
86
-
87
- // Check signature
88
- $certs = $this->getFederatedSignOnCerts();
89
- foreach ($certs as $cert) {
90
- $bigIntClass = $this->getBigIntClass();
91
- $rsaClass = $this->getRsaClass();
92
- $modulus = new $bigIntClass($this->jwt->urlsafeB64Decode($cert['n']), 256);
93
- $exponent = new $bigIntClass($this->jwt->urlsafeB64Decode($cert['e']), 256);
94
-
95
- $rsa = new $rsaClass();
96
- $rsa->loadKey(array('n' => $modulus, 'e' => $exponent));
97
-
98
- try {
99
- $payload = $this->jwt->decode(
100
- $idToken,
101
- $rsa->getPublicKey(),
102
- array('RS256')
103
- );
104
-
105
- if (property_exists($payload, 'aud')) {
106
- if ($audience && $payload->aud != $audience) {
107
- return false;
108
- }
109
- }
110
-
111
- // support HTTP and HTTPS issuers
112
- // @see https://developers.google.com/identity/sign-in/web/backend-auth
113
- $issuers = array(self::OAUTH2_ISSUER, self::OAUTH2_ISSUER_HTTPS);
114
- if (!isset($payload->iss) || !in_array($payload->iss, $issuers)) {
115
- return false;
116
- }
117
-
118
- return (array) $payload;
119
- } catch (ExpiredException $e) {
120
- return false;
121
- } catch (ExpiredExceptionV3 $e) {
122
- return false;
123
- } catch (DomainException $e) {
124
- // continue
125
- }
126
- }
127
-
128
- return false;
129
- }
130
-
131
- private function getCache()
132
- {
133
- return $this->cache;
134
- }
135
-
136
- /**
137
- * Retrieve and cache a certificates file.
138
- *
139
- * @param $url string location
140
- * @throws Google_Exception
141
- * @return array certificates
142
- */
143
- private function retrieveCertsFromLocation($url)
144
- {
145
- // If we're retrieving a local file, just grab it.
146
- if (0 !== strpos($url, 'http')) {
147
- if (!$file = file_get_contents($url)) {
148
- throw new Google_Exception(
149
- "Failed to retrieve verification certificates: '" .
150
- $url . "'."
151
- );
152
- }
153
-
154
- return json_decode($file, true);
155
- }
156
-
157
- $response = $this->http->get($url);
158
-
159
- if ($response->getStatusCode() == 200) {
160
- return json_decode((string) $response->getBody(), true);
161
- }
162
- throw new Google_Exception(
163
- sprintf(
164
- 'Failed to retrieve verification certificates: "%s".',
165
- $response->getBody()->getContents()
166
- ),
167
- $response->getStatusCode()
168
- );
169
- }
170
-
171
- // Gets federated sign-on certificates to use for verifying identity tokens.
172
- // Returns certs as array structure, where keys are key ids, and values
173
- // are PEM encoded certificates.
174
- private function getFederatedSignOnCerts()
175
- {
176
- $certs = null;
177
- if ($cache = $this->getCache()) {
178
- $cacheItem = $cache->getItem('federated_signon_certs_v3', 3600);
179
- $certs = $cacheItem->get();
180
- }
181
-
182
-
183
- if (!$certs) {
184
- $certs = $this->retrieveCertsFromLocation(
185
- self::FEDERATED_SIGNON_CERT_URL
186
- );
187
-
188
- if ($cache) {
189
- $cacheItem->set($certs);
190
- $cache->save($cacheItem);
191
- }
192
- }
193
-
194
- if (!isset($certs['keys'])) {
195
- throw new InvalidArgumentException(
196
- 'federated sign-on certs expects "keys" to be set'
197
- );
198
- }
199
-
200
- return $certs['keys'];
201
- }
202
-
203
- private function getJwtService()
204
- {
205
- $jwtClass = 'JWT';
206
- if (class_exists('\Firebase\JWT\JWT')) {
207
- $jwtClass = 'Firebase\JWT\JWT';
208
- }
209
-
210
- if (property_exists($jwtClass, 'leeway')) {
211
- // adds 1 second to JWT leeway
212
- // @see https://github.com/google/google-api-php-client/issues/827
213
- $jwtClass::$leeway = 1;
214
- }
215
-
216
- return new $jwtClass;
217
- }
218
-
219
- private function getRsaClass()
220
- {
221
- if (class_exists('phpseclib\Crypt\RSA')) {
222
- return 'phpseclib\Crypt\RSA';
223
- }
224
-
225
- return 'Crypt_RSA';
226
- }
227
-
228
- private function getBigIntClass()
229
- {
230
- if (class_exists('phpseclib\Math\BigInteger')) {
231
- return 'phpseclib\Math\BigInteger';
232
- }
233
-
234
- return 'Math_BigInteger';
235
- }
236
-
237
- private function getOpenSslConstant()
238
- {
239
- if (class_exists('phpseclib\Crypt\RSA')) {
240
- return 'phpseclib\Crypt\RSA::MODE_OPENSSL';
241
- }
242
-
243
- if (class_exists('Crypt_RSA')) {
244
- return 'CRYPT_RSA_MODE_OPENSSL';
245
- }
246
-
247
- throw new \Exception('Cannot find RSA class');
248
- }
249
-
250
- /**
251
- * phpseclib calls "phpinfo" by default, which requires special
252
- * whitelisting in the AppEngine VM environment. This function
253
- * sets constants to bypass the need for phpseclib to check phpinfo
254
- *
255
- * @see phpseclib/Math/BigInteger
256
- * @see https://github.com/GoogleCloudPlatform/getting-started-php/issues/85
257
- */
258
- private function setPhpsecConstants()
259
- {
260
- if (filter_var(getenv('GAE_VM'), FILTER_VALIDATE_BOOLEAN)) {
261
- if (!defined('MATH_BIGINTEGER_OPENSSL_ENABLED')) {
262
- define('MATH_BIGINTEGER_OPENSSL_ENABLED', true);
263
- }
264
- if (!defined('CRYPT_RSA_MODE')) {
265
- define('CRYPT_RSA_MODE', constant($this->getOpenSslConstant()));
266
- }
267
- }
268
- }
269
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/src/Google/AuthHandler/AuthHandlerFactory.php DELETED
@@ -1,42 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright 2015 Google Inc. All Rights Reserved.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- use GuzzleHttp\Client;
19
- use GuzzleHttp\ClientInterface;
20
-
21
- class Google_AuthHandler_AuthHandlerFactory
22
- {
23
- /**
24
- * Builds out a default http handler for the installed version of guzzle.
25
- *
26
- * @return Google_AuthHandler_Guzzle5AuthHandler|Google_AuthHandler_Guzzle6AuthHandler
27
- * @throws Exception
28
- */
29
- public static function build($cache = null, array $cacheConfig = [])
30
- {
31
- $version = ClientInterface::VERSION;
32
-
33
- switch ($version[0]) {
34
- case '5':
35
- return new Google_AuthHandler_Guzzle5AuthHandler($cache, $cacheConfig);
36
- case '6':
37
- return new Google_AuthHandler_Guzzle6AuthHandler($cache, $cacheConfig);
38
- default:
39
- throw new Exception('Version not supported');
40
- }
41
- }
42
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/src/Google/AuthHandler/Guzzle5AuthHandler.php DELETED
@@ -1,99 +0,0 @@
1
- <?php
2
-
3
- use Google\Auth\CredentialsLoader;
4
- use Google\Auth\HttpHandler\HttpHandlerFactory;
5
- use Google\Auth\FetchAuthTokenCache;
6
- use Google\Auth\Subscriber\AuthTokenSubscriber;
7
- use Google\Auth\Subscriber\ScopedAccessTokenSubscriber;
8
- use Google\Auth\Subscriber\SimpleSubscriber;
9
- use GuzzleHttp\Client;
10
- use GuzzleHttp\ClientInterface;
11
- use Psr\Cache\CacheItemPoolInterface;
12
-
13
- /**
14
- *
15
- */
16
- class Google_AuthHandler_Guzzle5AuthHandler
17
- {
18
- protected $cache;
19
- protected $cacheConfig;
20
-
21
- public function __construct(CacheItemPoolInterface $cache = null, array $cacheConfig = [])
22
- {
23
- $this->cache = $cache;
24
- $this->cacheConfig = $cacheConfig;
25
- }
26
-
27
- public function attachCredentials(
28
- ClientInterface $http,
29
- CredentialsLoader $credentials,
30
- callable $tokenCallback = null
31
- ) {
32
- // use the provided cache
33
- if ($this->cache) {
34
- $credentials = new FetchAuthTokenCache(
35
- $credentials,
36
- $this->cacheConfig,
37
- $this->cache
38
- );
39
- }
40
- // if we end up needing to make an HTTP request to retrieve credentials, we
41
- // can use our existing one, but we need to throw exceptions so the error
42
- // bubbles up.
43
- $authHttp = $this->createAuthHttp($http);
44
- $authHttpHandler = HttpHandlerFactory::build($authHttp);
45
- $subscriber = new AuthTokenSubscriber(
46
- $credentials,
47
- $authHttpHandler,
48
- $tokenCallback
49
- );
50
-
51
- $http->setDefaultOption('auth', 'google_auth');
52
- $http->getEmitter()->attach($subscriber);
53
-
54
- return $http;
55
- }
56
-
57
- public function attachToken(ClientInterface $http, array $token, array $scopes)
58
- {
59
- $tokenFunc = function ($scopes) use ($token) {
60
- return $token['access_token'];
61
- };
62
-
63
- $subscriber = new ScopedAccessTokenSubscriber(
64
- $tokenFunc,
65
- $scopes,
66
- $this->cacheConfig,
67
- $this->cache
68
- );
69
-
70
- $http->setDefaultOption('auth', 'scoped');
71
- $http->getEmitter()->attach($subscriber);
72
-
73
- return $http;
74
- }
75
-
76
- public function attachKey(ClientInterface $http, $key)
77
- {
78
- $subscriber = new SimpleSubscriber(['key' => $key]);
79
-
80
- $http->setDefaultOption('auth', 'simple');
81
- $http->getEmitter()->attach($subscriber);
82
-
83
- return $http;
84
- }
85
-
86
- private function createAuthHttp(ClientInterface $http)
87
- {
88
- return new Client(
89
- [
90
- 'base_url' => $http->getBaseUrl(),
91
- 'defaults' => [
92
- 'exceptions' => true,
93
- 'verify' => $http->getDefaultOption('verify'),
94
- 'proxy' => $http->getDefaultOption('proxy'),
95
- ]
96
- ]
97
- );
98
- }
99
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/src/Google/AuthHandler/Guzzle6AuthHandler.php DELETED
@@ -1,106 +0,0 @@
1
- <?php
2
-
3
- use Google\Auth\CredentialsLoader;
4
- use Google\Auth\HttpHandler\HttpHandlerFactory;
5
- use Google\Auth\FetchAuthTokenCache;
6
- use Google\Auth\Middleware\AuthTokenMiddleware;
7
- use Google\Auth\Middleware\ScopedAccessTokenMiddleware;
8
- use Google\Auth\Middleware\SimpleMiddleware;
9
- use GuzzleHttp\Client;
10
- use GuzzleHttp\ClientInterface;
11
- use Psr\Cache\CacheItemPoolInterface;
12
-
13
- /**
14
- *
15
- */
16
- class Google_AuthHandler_Guzzle6AuthHandler
17
- {
18
- protected $cache;
19
- protected $cacheConfig;
20
-
21
- public function __construct(CacheItemPoolInterface $cache = null, array $cacheConfig = [])
22
- {
23
- $this->cache = $cache;
24
- $this->cacheConfig = $cacheConfig;
25
- }
26
-
27
- public function attachCredentials(
28
- ClientInterface $http,
29
- CredentialsLoader $credentials,
30
- callable $tokenCallback = null
31
- ) {
32
- // use the provided cache
33
- if ($this->cache) {
34
- $credentials = new FetchAuthTokenCache(
35
- $credentials,
36
- $this->cacheConfig,
37
- $this->cache
38
- );
39
- }
40
- // if we end up needing to make an HTTP request to retrieve credentials, we
41
- // can use our existing one, but we need to throw exceptions so the error
42
- // bubbles up.
43
- $authHttp = $this->createAuthHttp($http);
44
- $authHttpHandler = HttpHandlerFactory::build($authHttp);
45
- $middleware = new AuthTokenMiddleware(
46
- $credentials,
47
- $authHttpHandler,
48
- $tokenCallback
49
- );
50
-
51
- $config = $http->getConfig();
52
- $config['handler']->remove('google_auth');
53
- $config['handler']->push($middleware, 'google_auth');
54
- $config['auth'] = 'google_auth';
55
- $http = new Client($config);
56
-
57
- return $http;
58
- }
59
-
60
- public function attachToken(ClientInterface $http, array $token, array $scopes)
61
- {
62
- $tokenFunc = function ($scopes) use ($token) {
63
- return $token['access_token'];
64
- };
65
-
66
- $middleware = new ScopedAccessTokenMiddleware(
67
- $tokenFunc,
68
- $scopes,
69
- $this->cacheConfig,
70
- $this->cache
71
- );
72
-
73
- $config = $http->getConfig();
74
- $config['handler']->remove('google_auth');
75
- $config['handler']->push($middleware, 'google_auth');
76
- $config['auth'] = 'scoped';
77
- $http = new Client($config);
78
-
79
- return $http;
80
- }
81
-
82
- public function attachKey(ClientInterface $http, $key)
83
- {
84
- $middleware = new SimpleMiddleware(['key' => $key]);
85
-
86
- $config = $http->getConfig();
87
- $config['handler']->remove('google_auth');
88
- $config['handler']->push($middleware, 'google_auth');
89
- $config['auth'] = 'simple';
90
- $http = new Client($config);
91
-
92
- return $http;
93
- }
94
-
95
- private function createAuthHttp(ClientInterface $http)
96
- {
97
- return new Client(
98
- [
99
- 'base_uri' => $http->getConfig('base_uri'),
100
- 'exceptions' => true,
101
- 'verify' => $http->getConfig('verify'),
102
- 'proxy' => $http->getConfig('proxy'),
103
- ]
104
- );
105
- }
106
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/src/Google/Client.php DELETED
@@ -1,1118 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2010 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- use Google\Auth\ApplicationDefaultCredentials;
19
- use Google\Auth\Cache\MemoryCacheItemPool;
20
- use Google\Auth\CredentialsLoader;
21
- use Google\Auth\HttpHandler\HttpHandlerFactory;
22
- use Google\Auth\OAuth2;
23
- use Google\Auth\Credentials\ServiceAccountCredentials;
24
- use Google\Auth\Credentials\UserRefreshCredentials;
25
- use GuzzleHttp\Client;
26
- use GuzzleHttp\ClientInterface;
27
- use GuzzleHttp\Ring\Client\StreamHandler;
28
- use GuzzleHttp\Psr7;
29
- use Psr\Cache\CacheItemPoolInterface;
30
- use Psr\Http\Message\RequestInterface;
31
- use Psr\Log\LoggerInterface;
32
- use Monolog\Logger;
33
- use Monolog\Handler\StreamHandler as MonologStreamHandler;
34
- use Monolog\Handler\SyslogHandler as MonologSyslogHandler;
35
-
36
- /**
37
- * The Google API Client
38
- * https://github.com/google/google-api-php-client
39
- */
40
- class Google_Client
41
- {
42
- const LIBVER = "2.2.0";
43
- const USER_AGENT_SUFFIX = "google-api-php-client/";
44
- const OAUTH2_REVOKE_URI = 'https://accounts.google.com/o/oauth2/revoke';
45
- const OAUTH2_TOKEN_URI = 'https://www.googleapis.com/oauth2/v4/token';
46
- const OAUTH2_AUTH_URL = 'https://accounts.google.com/o/oauth2/auth';
47
- const API_BASE_PATH = 'https://www.googleapis.com';
48
-
49
- /**
50
- * @var Google\Auth\OAuth2 $auth
51
- */
52
- private $auth;
53
-
54
- /**
55
- * @var GuzzleHttp\ClientInterface $http
56
- */
57
- private $http;
58
-
59
- /**
60
- * @var Psr\Cache\CacheItemPoolInterface $cache
61
- */
62
- private $cache;
63
-
64
- /**
65
- * @var array access token
66
- */
67
- private $token;
68
-
69
- /**
70
- * @var array $config
71
- */
72
- private $config;
73
-
74
- /**
75
- * @var Psr\Log\LoggerInterface $logger
76
- */
77
- private $logger;
78
-
79
- /**
80
- * @var boolean $deferExecution
81
- */
82
- private $deferExecution = false;
83
-
84
- /** @var array $scopes */
85
- // Scopes requested by the client
86
- protected $requestedScopes = [];
87
-
88
- /**
89
- * Construct the Google Client.
90
- *
91
- * @param array $config
92
- */
93
- public function __construct(array $config = array())
94
- {
95
- $this->config = array_merge(
96
- [
97
- 'application_name' => '',
98
-
99
- // Don't change these unless you're working against a special development
100
- // or testing environment.
101
- 'base_path' => self::API_BASE_PATH,
102
-
103
- // https://developers.google.com/console
104
- 'client_id' => '',
105
- 'client_secret' => '',
106
- 'redirect_uri' => null,
107
- 'state' => null,
108
-
109
- // Simple API access key, also from the API console. Ensure you get
110
- // a Server key, and not a Browser key.
111
- 'developer_key' => '',
112
-
113
- // For use with Google Cloud Platform
114
- // fetch the ApplicationDefaultCredentials, if applicable
115
- // @see https://developers.google.com/identity/protocols/application-default-credentials
116
- 'use_application_default_credentials' => false,
117
- 'signing_key' => null,
118
- 'signing_algorithm' => null,
119
- 'subject' => null,
120
-
121
- // Other OAuth2 parameters.
122
- 'hd' => '',
123
- 'prompt' => '',
124
- 'openid.realm' => '',
125
- 'include_granted_scopes' => null,
126
- 'login_hint' => '',
127
- 'request_visible_actions' => '',
128
- 'access_type' => 'online',
129
- 'approval_prompt' => 'auto',
130
-
131
- // Task Runner retry configuration
132
- // @see Google_Task_Runner
133
- 'retry' => array(),
134
-
135
- // cache config for downstream auth caching
136
- 'cache_config' => [],
137
-
138
- // function to be called when an access token is fetched
139
- // follows the signature function ($cacheKey, $accessToken)
140
- 'token_callback' => null,
141
-
142
- // Service class used in Google_Client::verifyIdToken.
143
- // Explicitly pass this in to avoid setting JWT::$leeway
144
- 'jwt' => null,
145
- ],
146
- $config
147
- );
148
- }
149
-
150
- /**
151
- * Get a string containing the version of the library.
152
- *
153
- * @return string
154
- */
155
- public function getLibraryVersion()
156
- {
157
- return self::LIBVER;
158
- }
159
-
160
- /**
161
- * For backwards compatibility
162
- * alias for fetchAccessTokenWithAuthCode
163
- *
164
- * @param $code string code from accounts.google.com
165
- * @return array access token
166
- * @deprecated
167
- */
168
- public function authenticate($code)
169
- {
170
- return $this->fetchAccessTokenWithAuthCode($code);
171
- }
172
-
173
- /**
174
- * Attempt to exchange a code for an valid authentication token.
175
- * Helper wrapped around the OAuth 2.0 implementation.
176
- *
177
- * @param $code string code from accounts.google.com
178
- * @return array access token
179
- */
180
- public function fetchAccessTokenWithAuthCode($code)
181
- {
182
- if (strlen($code) == 0) {
183
- throw new InvalidArgumentException("Invalid code");
184
- }
185
-
186
- $auth = $this->getOAuth2Service();
187
- $auth->setCode($code);
188
- $auth->setRedirectUri($this->getRedirectUri());
189
-
190
- $httpHandler = HttpHandlerFactory::build($this->getHttpClient());
191
- $creds = $auth->fetchAuthToken($httpHandler);
192
- if ($creds && isset($creds['access_token'])) {
193
- $creds['created'] = time();
194
- $this->setAccessToken($creds);
195
- }
196
-
197
- return $creds;
198
- }
199
-
200
- /**
201
- * For backwards compatibility
202
- * alias for fetchAccessTokenWithAssertion
203
- *
204
- * @return array access token
205
- * @deprecated
206
- */
207
- public function refreshTokenWithAssertion()
208
- {
209
- return $this->fetchAccessTokenWithAssertion();
210
- }
211
-
212
- /**
213
- * Fetches a fresh access token with a given assertion token.
214
- * @param $assertionCredentials optional.
215
- * @return array access token
216
- */
217
- public function fetchAccessTokenWithAssertion(ClientInterface $authHttp = null)
218
- {
219
- if (!$this->isUsingApplicationDefaultCredentials()) {
220
- throw new DomainException(
221
- 'set the JSON service account credentials using'
222
- . ' Google_Client::setAuthConfig or set the path to your JSON file'
223
- . ' with the "GOOGLE_APPLICATION_CREDENTIALS" environment variable'
224
- . ' and call Google_Client::useApplicationDefaultCredentials to'
225
- . ' refresh a token with assertion.'
226
- );
227
- }
228
-
229
- $this->getLogger()->log(
230
- 'info',
231
- 'OAuth2 access token refresh with Signed JWT assertion grants.'
232
- );
233
-
234
- $credentials = $this->createApplicationDefaultCredentials();
235
-
236
- $httpHandler = HttpHandlerFactory::build($authHttp);
237
- $creds = $credentials->fetchAuthToken($httpHandler);
238
- if ($creds && isset($creds['access_token'])) {
239
- $creds['created'] = time();
240
- $this->setAccessToken($creds);
241
- }
242
-
243
- return $creds;
244
- }
245
-
246
- /**
247
- * For backwards compatibility
248
- * alias for fetchAccessTokenWithRefreshToken
249
- *
250
- * @param string $refreshToken
251
- * @return array access token
252
- */
253
- public function refreshToken($refreshToken)
254
- {
255
- return $this->fetchAccessTokenWithRefreshToken($refreshToken);
256
- }
257
-
258
- /**
259
- * Fetches a fresh OAuth 2.0 access token with the given refresh token.
260
- * @param string $refreshToken
261
- * @return array access token
262
- */
263
- public function fetchAccessTokenWithRefreshToken($refreshToken = null)
264
- {
265
- if (null === $refreshToken) {
266
- if (!isset($this->token['refresh_token'])) {
267
- throw new LogicException(
268
- 'refresh token must be passed in or set as part of setAccessToken'
269
- );
270
- }
271
- $refreshToken = $this->token['refresh_token'];
272
- }
273
- $this->getLogger()->info('OAuth2 access token refresh');
274
- $auth = $this->getOAuth2Service();
275
- $auth->setRefreshToken($refreshToken);
276
-
277
- $httpHandler = HttpHandlerFactory::build($this->getHttpClient());
278
- $creds = $auth->fetchAuthToken($httpHandler);
279
- if ($creds && isset($creds['access_token'])) {
280
- $creds['created'] = time();
281
- if (!isset($creds['refresh_token'])) {
282
- $creds['refresh_token'] = $refreshToken;
283
- }
284
- $this->setAccessToken($creds);
285
- }
286
-
287
- return $creds;
288
- }
289
-
290
- /**
291
- * Create a URL to obtain user authorization.
292
- * The authorization endpoint allows the user to first
293
- * authenticate, and then grant/deny the access request.
294
- * @param string|array $scope The scope is expressed as an array or list of space-delimited strings.
295
- * @return string
296
- */
297
- public function createAuthUrl($scope = null)
298
- {
299
- if (empty($scope)) {
300
- $scope = $this->prepareScopes();
301
- }
302
- if (is_array($scope)) {
303
- $scope = implode(' ', $scope);
304
- }
305
-
306
- // only accept one of prompt or approval_prompt
307
- $approvalPrompt = $this->config['prompt']
308
- ? null
309
- : $this->config['approval_prompt'];
310
-
311
- // include_granted_scopes should be string "true", string "false", or null
312
- $includeGrantedScopes = $this->config['include_granted_scopes'] === null
313
- ? null
314
- : var_export($this->config['include_granted_scopes'], true);
315
-
316
- $params = array_filter(
317
- [
318
- 'access_type' => $this->config['access_type'],
319
- 'approval_prompt' => $approvalPrompt,
320
- 'hd' => $this->config['hd'],
321
- 'include_granted_scopes' => $includeGrantedScopes,
322
- 'login_hint' => $this->config['login_hint'],
323
- 'openid.realm' => $this->config['openid.realm'],
324
- 'prompt' => $this->config['prompt'],
325
- 'response_type' => 'code',
326
- 'scope' => $scope,
327
- 'state' => $this->config['state'],
328
- ]
329
- );
330
-
331
- // If the list of scopes contains plus.login, add request_visible_actions
332
- // to auth URL.
333
- $rva = $this->config['request_visible_actions'];
334
- if (strlen($rva) > 0 && false !== strpos($scope, 'plus.login')) {
335
- $params['request_visible_actions'] = $rva;
336
- }
337
-
338
- $auth = $this->getOAuth2Service();
339
-
340
- return (string) $auth->buildFullAuthorizationUri($params);
341
- }
342
-
343
- /**
344
- * Adds auth listeners to the HTTP client based on the credentials
345
- * set in the Google API Client object
346
- *
347
- * @param GuzzleHttp\ClientInterface $http the http client object.
348
- * @return GuzzleHttp\ClientInterface the http client object
349
- */
350
- public function authorize(ClientInterface $http = null)
351
- {
352
- $credentials = null;
353
- $token = null;
354
- $scopes = null;
355
- if (null === $http) {
356
- $http = $this->getHttpClient();
357
- }
358
-
359
- // These conditionals represent the decision tree for authentication
360
- // 1. Check for Application Default Credentials
361
- // 2. Check for API Key
362
- // 3a. Check for an Access Token
363
- // 3b. If access token exists but is expired, try to refresh it
364
- if ($this->isUsingApplicationDefaultCredentials()) {
365
- $credentials = $this->createApplicationDefaultCredentials();
366
- } elseif ($token = $this->getAccessToken()) {
367
- $scopes = $this->prepareScopes();
368
- // add refresh subscriber to request a new token
369
- if (isset($token['refresh_token']) && $this->isAccessTokenExpired()) {
370
- $credentials = $this->createUserRefreshCredentials(
371
- $scopes,
372
- $token['refresh_token']
373
- );
374
- }
375
- }
376
-
377
- $authHandler = $this->getAuthHandler();
378
-
379
- if ($credentials) {
380
- $callback = $this->config['token_callback'];
381
- $http = $authHandler->attachCredentials($http, $credentials, $callback);
382
- } elseif ($token) {
383
- $http = $authHandler->attachToken($http, $token, (array) $scopes);
384
- } elseif ($key = $this->config['developer_key']) {
385
- $http = $authHandler->attachKey($http, $key);
386
- }
387
-
388
- return $http;
389
- }
390
-
391
- /**
392
- * Set the configuration to use application default credentials for
393
- * authentication
394
- *
395
- * @see https://developers.google.com/identity/protocols/application-default-credentials
396
- * @param boolean $useAppCreds
397
- */
398
- public function useApplicationDefaultCredentials($useAppCreds = true)
399
- {
400
- $this->config['use_application_default_credentials'] = $useAppCreds;
401
- }
402
-
403
- /**
404
- * To prevent useApplicationDefaultCredentials from inappropriately being
405
- * called in a conditional
406
- *
407
- * @see https://developers.google.com/identity/protocols/application-default-credentials
408
- */
409
- public function isUsingApplicationDefaultCredentials()
410
- {
411
- return $this->config['use_application_default_credentials'];
412
- }
413
-
414
- /**
415
- * @param string|array $token
416
- * @throws InvalidArgumentException
417
- */
418
- public function setAccessToken($token)
419
- {
420
- if (is_string($token)) {
421
- if ($json = json_decode($token, true)) {
422
- $token = $json;
423
- } else {
424
- // assume $token is just the token string
425
- $token = array(
426
- 'access_token' => $token,
427
- );
428
- }
429
- }
430
- if ($token == null) {
431
- throw new InvalidArgumentException('invalid json token');
432
- }
433
- if (!isset($token['access_token'])) {
434
- throw new InvalidArgumentException("Invalid token format");
435
- }
436
- $this->token = $token;
437
- }
438
-
439
- public function getAccessToken()
440
- {
441
- return $this->token;
442
- }
443
-
444
- public function getRefreshToken()
445
- {
446
- if (isset($this->token['refresh_token'])) {
447
- return $this->token['refresh_token'];
448
- }
449
- }
450
-
451
- /**
452
- * Returns if the access_token is expired.
453
- * @return bool Returns True if the access_token is expired.
454
- */
455
- public function isAccessTokenExpired()
456
- {
457
- if (!$this->token) {
458
- return true;
459
- }
460
-
461
- $created = 0;
462
- if (isset($this->token['created'])) {
463
- $created = $this->token['created'];
464
- } elseif (isset($this->token['id_token'])) {
465
- // check the ID token for "iat"
466
- // signature verification is not required here, as we are just
467
- // using this for convenience to save a round trip request
468
- // to the Google API server
469
- $idToken = $this->token['id_token'];
470
- if (substr_count($idToken, '.') == 2) {
471
- $parts = explode('.', $idToken);
472
- $payload = json_decode(base64_decode($parts[1]), true);
473
- if ($payload && isset($payload['iat'])) {
474
- $created = $payload['iat'];
475
- }
476
- }
477
- }
478
-
479
- // If the token is set to expire in the next 30 seconds.
480
- return ($created + ($this->token['expires_in'] - 30)) < time();
481
- }
482
-
483
- public function getAuth()
484
- {
485
- throw new BadMethodCallException(
486
- 'This function no longer exists. See UPGRADING.md for more information'
487
- );
488
- }
489
-
490
- public function setAuth($auth)
491
- {
492
- throw new BadMethodCallException(
493
- 'This function no longer exists. See UPGRADING.md for more information'
494
- );
495
- }
496
-
497
- /**
498
- * Set the OAuth 2.0 Client ID.
499
- * @param string $clientId
500
- */
501
- public function setClientId($clientId)
502
- {
503
- $this->config['client_id'] = $clientId;
504
- }
505
-
506
- public function getClientId()
507
- {
508
- return $this->config['client_id'];
509
- }
510
-
511
- /**
512
- * Set the OAuth 2.0 Client Secret.
513
- * @param string $clientSecret
514
- */
515
- public function setClientSecret($clientSecret)
516
- {
517
- $this->config['client_secret'] = $clientSecret;
518
- }
519
-
520
- public function getClientSecret()
521
- {
522
- return $this->config['client_secret'];
523
- }
524
-
525
- /**
526
- * Set the OAuth 2.0 Redirect URI.
527
- * @param string $redirectUri
528
- */
529
- public function setRedirectUri($redirectUri)
530
- {
531
- $this->config['redirect_uri'] = $redirectUri;
532
- }
533
-
534
- public function getRedirectUri()
535
- {
536
- return $this->config['redirect_uri'];
537
- }
538
-
539
- /**
540
- * Set OAuth 2.0 "state" parameter to achieve per-request customization.
541
- * @see http://tools.ietf.org/html/draft-ietf-oauth-v2-22#section-3.1.2.2
542
- * @param string $state
543
- */
544
- public function setState($state)
545
- {
546
- $this->config['state'] = $state;
547
- }
548
-
549
- /**
550
- * @param string $accessType Possible values for access_type include:
551
- * {@code "offline"} to request offline access from the user.
552
- * {@code "online"} to request online access from the user.
553
- */
554
- public function setAccessType($accessType)
555
- {
556
- $this->config['access_type'] = $accessType;
557
- }
558
-
559
- /**
560
- * @param string $approvalPrompt Possible values for approval_prompt include:
561
- * {@code "force"} to force the approval UI to appear.
562
- * {@code "auto"} to request auto-approval when possible. (This is the default value)
563
- */
564
- public function setApprovalPrompt($approvalPrompt)
565
- {
566
- $this->config['approval_prompt'] = $approvalPrompt;
567
- }
568
-
569
- /**
570
- * Set the login hint, email address or sub id.
571
- * @param string $loginHint
572
- */
573
- public function setLoginHint($loginHint)
574
- {
575
- $this->config['login_hint'] = $loginHint;
576
- }
577
-
578
- /**
579
- * Set the application name, this is included in the User-Agent HTTP header.
580
- * @param string $applicationName
581
- */
582
- public function setApplicationName($applicationName)
583
- {
584
- $this->config['application_name'] = $applicationName;
585
- }
586
-
587
- /**
588
- * If 'plus.login' is included in the list of requested scopes, you can use
589
- * this method to define types of app activities that your app will write.
590
- * You can find a list of available types here:
591
- * @link https://developers.google.com/+/api/moment-types
592
- *
593
- * @param array $requestVisibleActions Array of app activity types
594
- */
595
- public function setRequestVisibleActions($requestVisibleActions)
596
- {
597
- if (is_array($requestVisibleActions)) {
598
- $requestVisibleActions = implode(" ", $requestVisibleActions);
599
- }
600
- $this->config['request_visible_actions'] = $requestVisibleActions;
601
- }
602
-
603
- /**
604
- * Set the developer key to use, these are obtained through the API Console.
605
- * @see http://code.google.com/apis/console-help/#generatingdevkeys
606
- * @param string $developerKey
607
- */
608
- public function setDeveloperKey($developerKey)
609
- {
610
- $this->config['developer_key'] = $developerKey;
611
- }
612
-
613
- /**
614
- * Set the hd (hosted domain) parameter streamlines the login process for
615
- * Google Apps hosted accounts. By including the domain of the user, you
616
- * restrict sign-in to accounts at that domain.
617
- * @param $hd string - the domain to use.
618
- */
619
- public function setHostedDomain($hd)
620
- {
621
- $this->config['hd'] = $hd;
622
- }
623
-
624
- /**
625
- * Set the prompt hint. Valid values are none, consent and select_account.
626
- * If no value is specified and the user has not previously authorized
627
- * access, then the user is shown a consent screen.
628
- * @param $prompt string
629
- */
630
- public function setPrompt($prompt)
631
- {
632
- $this->config['prompt'] = $prompt;
633
- }
634
-
635
- /**
636
- * openid.realm is a parameter from the OpenID 2.0 protocol, not from OAuth
637
- * 2.0. It is used in OpenID 2.0 requests to signify the URL-space for which
638
- * an authentication request is valid.
639
- * @param $realm string - the URL-space to use.
640
- */
641
- public function setOpenidRealm($realm)
642
- {
643
- $this->config['openid.realm'] = $realm;
644
- }
645
-
646
- /**
647
- * If this is provided with the value true, and the authorization request is
648
- * granted, the authorization will include any previous authorizations
649
- * granted to this user/application combination for other scopes.
650
- * @param $include boolean - the URL-space to use.
651
- */
652
- public function setIncludeGrantedScopes($include)
653
- {
654
- $this->config['include_granted_scopes'] = $include;
655
- }
656
-
657
- /**
658
- * sets function to be called when an access token is fetched
659
- * @param callable $tokenCallback - function ($cacheKey, $accessToken)
660
- */
661
- public function setTokenCallback(callable $tokenCallback)
662
- {
663
- $this->config['token_callback'] = $tokenCallback;
664
- }
665
-
666
- /**
667
- * Revoke an OAuth2 access token or refresh token. This method will revoke the current access
668
- * token, if a token isn't provided.
669
- *
670
- * @param string|null $token The token (access token or a refresh token) that should be revoked.
671
- * @return boolean Returns True if the revocation was successful, otherwise False.
672
- */
673
- public function revokeToken($token = null)
674
- {
675
- $tokenRevoker = new Google_AccessToken_Revoke(
676
- $this->getHttpClient()
677
- );
678
-
679
- return $tokenRevoker->revokeToken($token ?: $this->getAccessToken());
680
- }
681
-
682
- /**
683
- * Verify an id_token. This method will verify the current id_token, if one
684
- * isn't provided.
685
- *
686
- * @throws LogicException
687
- * @param string|null $idToken The token (id_token) that should be verified.
688
- * @return array|false Returns the token payload as an array if the verification was
689
- * successful, false otherwise.
690
- */
691
- public function verifyIdToken($idToken = null)
692
- {
693
- $tokenVerifier = new Google_AccessToken_Verify(
694
- $this->getHttpClient(),
695
- $this->getCache(),
696
- $this->config['jwt']
697
- );
698
-
699
- if (null === $idToken) {
700
- $token = $this->getAccessToken();
701
- if (!isset($token['id_token'])) {
702
- throw new LogicException(
703
- 'id_token must be passed in or set as part of setAccessToken'
704
- );
705
- }
706
- $idToken = $token['id_token'];
707
- }
708
-
709
- return $tokenVerifier->verifyIdToken(
710
- $idToken,
711
- $this->getClientId()
712
- );
713
- }
714
-
715
- /**
716
- * Set the scopes to be requested. Must be called before createAuthUrl().
717
- * Will remove any previously configured scopes.
718
- * @param array $scopes, ie: array('https://www.googleapis.com/auth/plus.login',
719
- * 'https://www.googleapis.com/auth/moderator')
720
- */
721
- public function setScopes($scopes)
722
- {
723
- $this->requestedScopes = array();
724
- $this->addScope($scopes);
725
- }
726
-
727
- /**
728
- * This functions adds a scope to be requested as part of the OAuth2.0 flow.
729
- * Will append any scopes not previously requested to the scope parameter.
730
- * A single string will be treated as a scope to request. An array of strings
731
- * will each be appended.
732
- * @param $scope_or_scopes string|array e.g. "profile"
733
- */
734
- public function addScope($scope_or_scopes)
735
- {
736
- if (is_string($scope_or_scopes) && !in_array($scope_or_scopes, $this->requestedScopes)) {
737
- $this->requestedScopes[] = $scope_or_scopes;
738
- } else if (is_array($scope_or_scopes)) {
739
- foreach ($scope_or_scopes as $scope) {
740
- $this->addScope($scope);
741
- }
742
- }
743
- }
744
-
745
- /**
746
- * Returns the list of scopes requested by the client
747
- * @return array the list of scopes
748
- *
749
- */
750
- public function getScopes()
751
- {
752
- return $this->requestedScopes;
753
- }
754
-
755
- /**
756
- * @return array
757
- * @visible For Testing
758
- */
759
- public function prepareScopes()
760
- {
761
- if (empty($this->requestedScopes)) {
762
- return null;
763
- }
764
-
765
- return implode(' ', $this->requestedScopes);
766
- }
767
-
768
- /**
769
- * Helper method to execute deferred HTTP requests.
770
- *
771
- * @param $request Psr\Http\Message\RequestInterface|Google_Http_Batch
772
- * @throws Google_Exception
773
- * @return object of the type of the expected class or Psr\Http\Message\ResponseInterface.
774
- */
775
- public function execute(RequestInterface $request, $expectedClass = null)
776
- {
777
- $request = $request->withHeader(
778
- 'User-Agent',
779
- $this->config['application_name']
780
- . " " . self::USER_AGENT_SUFFIX
781
- . $this->getLibraryVersion()
782
- );
783
-
784
- // call the authorize method
785
- // this is where most of the grunt work is done
786
- $http = $this->authorize();
787
-
788
- return Google_Http_REST::execute($http, $request, $expectedClass, $this->config['retry']);
789
- }
790
-
791
- /**
792
- * Declare whether batch calls should be used. This may increase throughput
793
- * by making multiple requests in one connection.
794
- *
795
- * @param boolean $useBatch True if the batch support should
796
- * be enabled. Defaults to False.
797
- */
798
- public function setUseBatch($useBatch)
799
- {
800
- // This is actually an alias for setDefer.
801
- $this->setDefer($useBatch);
802
- }
803
-
804
- /**
805
- * Are we running in Google AppEngine?
806
- * return bool
807
- */
808
- public function isAppEngine()
809
- {
810
- return (isset($_SERVER['SERVER_SOFTWARE']) &&
811
- strpos($_SERVER['SERVER_SOFTWARE'], 'Google App Engine') !== false);
812
- }
813
-
814
- public function setConfig($name, $value)
815
- {
816
- $this->config[$name] = $value;
817
- }
818
-
819
- public function getConfig($name, $default = null)
820
- {
821
- return isset($this->config[$name]) ? $this->config[$name] : $default;
822
- }
823
-
824
- /**
825
- * For backwards compatibility
826
- * alias for setAuthConfig
827
- *
828
- * @param string $file the configuration file
829
- * @throws Google_Exception
830
- * @deprecated
831
- */
832
- public function setAuthConfigFile($file)
833
- {
834
- $this->setAuthConfig($file);
835
- }
836
-
837
- /**
838
- * Set the auth config from new or deprecated JSON config.
839
- * This structure should match the file downloaded from
840
- * the "Download JSON" button on in the Google Developer
841
- * Console.
842
- * @param string|array $config the configuration json
843
- * @throws Google_Exception
844
- */
845
- public function setAuthConfig($config)
846
- {
847
- if (is_string($config)) {
848
- if (!file_exists($config)) {
849
- throw new InvalidArgumentException('file does not exist');
850
- }
851
-
852
- $json = file_get_contents($config);
853
-
854
- if (!$config = json_decode($json, true)) {
855
- throw new LogicException('invalid json for auth config');
856
- }
857
- }
858
-
859
- $key = isset($config['installed']) ? 'installed' : 'web';
860
- if (isset($config['type']) && $config['type'] == 'service_account') {
861
- // application default credentials
862
- $this->useApplicationDefaultCredentials();
863
-
864
- // set the information from the config
865
- $this->setClientId($config['client_id']);
866
- $this->config['client_email'] = $config['client_email'];
867
- $this->config['signing_key'] = $config['private_key'];
868
- $this->config['signing_algorithm'] = 'HS256';
869
- } elseif (isset($config[$key])) {
870
- // old-style
871
- $this->setClientId($config[$key]['client_id']);
872
- $this->setClientSecret($config[$key]['client_secret']);
873
- if (isset($config[$key]['redirect_uris'])) {
874
- $this->setRedirectUri($config[$key]['redirect_uris'][0]);
875
- }
876
- } else {
877
- // new-style
878
- $this->setClientId($config['client_id']);
879
- $this->setClientSecret($config['client_secret']);
880
- if (isset($config['redirect_uris'])) {
881
- $this->setRedirectUri($config['redirect_uris'][0]);
882
- }
883
- }
884
- }
885
-
886
- /**
887
- * Use when the service account has been delegated domain wide access.
888
- *
889
- * @param string subject an email address account to impersonate
890
- */
891
- public function setSubject($subject)
892
- {
893
- $this->config['subject'] = $subject;
894
- }
895
-
896
- /**
897
- * Declare whether making API calls should make the call immediately, or
898
- * return a request which can be called with ->execute();
899
- *
900
- * @param boolean $defer True if calls should not be executed right away.
901
- */
902
- public function setDefer($defer)
903
- {
904
- $this->deferExecution = $defer;
905
- }
906
-
907
- /**
908
- * Whether or not to return raw requests
909
- * @return boolean
910
- */
911
- public function shouldDefer()
912
- {
913
- return $this->deferExecution;
914
- }
915
-
916
- /**
917
- * @return Google\Auth\OAuth2 implementation
918
- */
919
- public function getOAuth2Service()
920
- {
921
- if (!isset($this->auth)) {
922
- $this->auth = $this->createOAuth2Service();
923
- }
924
-
925
- return $this->auth;
926
- }
927
-
928
- /**
929
- * create a default google auth object
930
- */
931
- protected function createOAuth2Service()
932
- {
933
- $auth = new OAuth2(
934
- [
935
- 'clientId' => $this->getClientId(),
936
- 'clientSecret' => $this->getClientSecret(),
937
- 'authorizationUri' => self::OAUTH2_AUTH_URL,
938
- 'tokenCredentialUri' => self::OAUTH2_TOKEN_URI,
939
- 'redirectUri' => $this->getRedirectUri(),
940
- 'issuer' => $this->config['client_id'],
941
- 'signingKey' => $this->config['signing_key'],
942
- 'signingAlgorithm' => $this->config['signing_algorithm'],
943
- ]
944
- );
945
-
946
- return $auth;
947
- }
948
-
949
- /**
950
- * Set the Cache object
951
- * @param Psr\Cache\CacheItemPoolInterface $cache
952
- */
953
- public function setCache(CacheItemPoolInterface $cache)
954
- {
955
- $this->cache = $cache;
956
- }
957
-
958
- /**
959
- * @return Psr\Cache\CacheItemPoolInterface Cache implementation
960
- */
961
- public function getCache()
962
- {
963
- if (!$this->cache) {
964
- $this->cache = $this->createDefaultCache();
965
- }
966
-
967
- return $this->cache;
968
- }
969
-
970
- /**
971
- * @return Google\Auth\CacheInterface Cache implementation
972
- */
973
- public function setCacheConfig(array $cacheConfig)
974
- {
975
- $this->config['cache_config'] = $cacheConfig;
976
- }
977
-
978
- /**
979
- * Set the Logger object
980
- * @param Psr\Log\LoggerInterface $logger
981
- */
982
- public function setLogger(LoggerInterface $logger)
983
- {
984
- $this->logger = $logger;
985
- }
986
-
987
- /**
988
- * @return Psr\Log\LoggerInterface implementation
989
- */
990
- public function getLogger()
991
- {
992
- if (!isset($this->logger)) {
993
- $this->logger = $this->createDefaultLogger();
994
- }
995
-
996
- return $this->logger;
997
- }
998
-
999
- protected function createDefaultLogger()
1000
- {
1001
- $logger = new Logger('google-api-php-client');
1002
- if ($this->isAppEngine()) {
1003
- $handler = new MonologSyslogHandler('app', LOG_USER, Logger::NOTICE);
1004
- } else {
1005
- $handler = new MonologStreamHandler('php://stderr', Logger::NOTICE);
1006
- }
1007
- $logger->pushHandler($handler);
1008
-
1009
- return $logger;
1010
- }
1011
-
1012
- protected function createDefaultCache()
1013
- {
1014
- return new MemoryCacheItemPool;
1015
- }
1016
-
1017
- /**
1018
- * Set the Http Client object
1019
- * @param GuzzleHttp\ClientInterface $http
1020
- */
1021
- public function setHttpClient(ClientInterface $http)
1022
- {
1023
- $this->http = $http;
1024
- }
1025
-
1026
- /**
1027
- * @return GuzzleHttp\ClientInterface implementation
1028
- */
1029
- public function getHttpClient()
1030
- {
1031
- if (null === $this->http) {
1032
- $this->http = $this->createDefaultHttpClient();
1033
- }
1034
-
1035
- return $this->http;
1036
- }
1037
-
1038
- protected function createDefaultHttpClient()
1039
- {
1040
- $options = ['exceptions' => false];
1041
-
1042
- $version = ClientInterface::VERSION;
1043
- if ('5' === $version[0]) {
1044
- $options = [
1045
- 'base_url' => $this->config['base_path'],
1046
- 'defaults' => $options,
1047
- ];
1048
- if ($this->isAppEngine()) {
1049
- // set StreamHandler on AppEngine by default
1050
- $options['handler'] = new StreamHandler();
1051
- $options['defaults']['verify'] = '/etc/ca-certificates.crt';
1052
- }
1053
- } else {
1054
- // guzzle 6
1055
- $options['base_uri'] = $this->config['base_path'];
1056
- }
1057
-
1058
- return new Client($options);
1059
- }
1060
-
1061
- private function createApplicationDefaultCredentials()
1062
- {
1063
- $scopes = $this->prepareScopes();
1064
- $sub = $this->config['subject'];
1065
- $signingKey = $this->config['signing_key'];
1066
-
1067
- // create credentials using values supplied in setAuthConfig
1068
- if ($signingKey) {
1069
- $serviceAccountCredentials = array(
1070
- 'client_id' => $this->config['client_id'],
1071
- 'client_email' => $this->config['client_email'],
1072
- 'private_key' => $signingKey,
1073
- 'type' => 'service_account',
1074
- );
1075
- $credentials = CredentialsLoader::makeCredentials($scopes, $serviceAccountCredentials);
1076
- } else {
1077
- $credentials = ApplicationDefaultCredentials::getCredentials($scopes);
1078
- }
1079
-
1080
- // for service account domain-wide authority (impersonating a user)
1081
- // @see https://developers.google.com/identity/protocols/OAuth2ServiceAccount
1082
- if ($sub) {
1083
- if (!$credentials instanceof ServiceAccountCredentials) {
1084
- throw new DomainException('domain-wide authority requires service account credentials');
1085
- }
1086
-
1087
- $credentials->setSub($sub);
1088
- }
1089
-
1090
- return $credentials;
1091
- }
1092
-
1093
- protected function getAuthHandler()
1094
- {
1095
- // Be very careful using the cache, as the underlying auth library's cache
1096
- // implementation is naive, and the cache keys do not account for user
1097
- // sessions.
1098
- //
1099
- // @see https://github.com/google/google-api-php-client/issues/821
1100
- return Google_AuthHandler_AuthHandlerFactory::build(
1101
- $this->getCache(),
1102
- $this->config['cache_config']
1103
- );
1104
- }
1105
-
1106
- private function createUserRefreshCredentials($scope, $refreshToken)
1107
- {
1108
- $creds = array_filter(
1109
- array(
1110
- 'client_id' => $this->getClientId(),
1111
- 'client_secret' => $this->getClientSecret(),
1112
- 'refresh_token' => $refreshToken,
1113
- )
1114
- );
1115
-
1116
- return new UserRefreshCredentials($scope, $creds);
1117
- }
1118
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/src/Google/Collection.php DELETED
@@ -1,101 +0,0 @@
1
- <?php
2
-
3
- if (!class_exists('Google_Client')) {
4
- require_once __DIR__ . '/autoload.php';
5
- }
6
-
7
- /**
8
- * Extension to the regular Google_Model that automatically
9
- * exposes the items array for iteration, so you can just
10
- * iterate over the object rather than a reference inside.
11
- */
12
- class Google_Collection extends Google_Model implements Iterator, Countable
13
- {
14
- protected $collection_key = 'items';
15
-
16
- public function rewind()
17
- {
18
- if (isset($this->{$this->collection_key})
19
- && is_array($this->{$this->collection_key})) {
20
- reset($this->{$this->collection_key});
21
- }
22
- }
23
-
24
- public function current()
25
- {
26
- $this->coerceType($this->key());
27
- if (is_array($this->{$this->collection_key})) {
28
- return current($this->{$this->collection_key});
29
- }
30
- }
31
-
32
- public function key()
33
- {
34
- if (isset($this->{$this->collection_key})
35
- && is_array($this->{$this->collection_key})) {
36
- return key($this->{$this->collection_key});
37
- }
38
- }
39
-
40
- public function next()
41
- {
42
- return next($this->{$this->collection_key});
43
- }
44
-
45
- public function valid()
46
- {
47
- $key = $this->key();
48
- return $key !== null && $key !== false;
49
- }
50
-
51
- public function count()
52
- {
53
- if (!isset($this->{$this->collection_key})) {
54
- return 0;
55
- }
56
- return count($this->{$this->collection_key});
57
- }
58
-
59
- public function offsetExists($offset)
60
- {
61
- if (!is_numeric($offset)) {
62
- return parent::offsetExists($offset);
63
- }
64
- return isset($this->{$this->collection_key}[$offset]);
65
- }
66
-
67
- public function offsetGet($offset)
68
- {
69
- if (!is_numeric($offset)) {
70
- return parent::offsetGet($offset);
71
- }
72
- $this->coerceType($offset);
73
- return $this->{$this->collection_key}[$offset];
74
- }
75
-
76
- public function offsetSet($offset, $value)
77
- {
78
- if (!is_numeric($offset)) {
79
- return parent::offsetSet($offset, $value);
80
- }
81
- $this->{$this->collection_key}[$offset] = $value;
82
- }
83
-
84
- public function offsetUnset($offset)
85
- {
86
- if (!is_numeric($offset)) {
87
- return parent::offsetUnset($offset);
88
- }
89
- unset($this->{$this->collection_key}[$offset]);
90
- }
91
-
92
- private function coerceType($offset)
93
- {
94
- $typeKey = $this->keyType($this->collection_key);
95
- if (isset($this->$typeKey) && !is_object($this->{$this->collection_key}[$offset])) {
96
- $type = $this->$typeKey;
97
- $this->{$this->collection_key}[$offset] =
98
- new $type($this->{$this->collection_key}[$offset]);
99
- }
100
- }
101
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/src/Google/Exception.php DELETED
@@ -1,20 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2013 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- class Google_Exception extends Exception
19
- {
20
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/src/Google/Http/Batch.php DELETED
@@ -1,249 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2012 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- use GuzzleHttp\Psr7;
19
- use GuzzleHttp\Psr7\Request;
20
- use GuzzleHttp\Psr7\Response;
21
- use Psr\Http\Message\RequestInterface;
22
- use Psr\Http\Message\ResponseInterface;
23
-
24
- /**
25
- * Class to handle batched requests to the Google API service.
26
- */
27
- class Google_Http_Batch
28
- {
29
- const BATCH_PATH = 'batch';
30
-
31
- private static $CONNECTION_ESTABLISHED_HEADERS = array(
32
- "HTTP/1.0 200 Connection established\r\n\r\n",
33
- "HTTP/1.1 200 Connection established\r\n\r\n",
34
- );
35
-
36
- /** @var string Multipart Boundary. */
37
- private $boundary;
38
-
39
- /** @var array service requests to be executed. */
40
- private $requests = array();
41
-
42
- /** @var Google_Client */
43
- private $client;
44
-
45
- private $rootUrl;
46
-
47
- private $batchPath;
48
-
49
- public function __construct(
50
- Google_Client $client,
51
- $boundary = false,
52
- $rootUrl = null,
53
- $batchPath = null
54
- ) {
55
- $this->client = $client;
56
- $this->boundary = $boundary ?: mt_rand();
57
- $this->rootUrl = rtrim($rootUrl ?: $this->client->getConfig('base_path'), '/');
58
- $this->batchPath = $batchPath ?: self::BATCH_PATH;
59
- }
60
-
61
- public function add(RequestInterface $request, $key = false)
62
- {
63
- if (false == $key) {
64
- $key = mt_rand();
65
- }
66
-
67
- $this->requests[$key] = $request;
68
- }
69
-
70
- public function execute()
71
- {
72
- $body = '';
73
- $classes = array();
74
- $batchHttpTemplate = <<<EOF
75
- --%s
76
- Content-Type: application/http
77
- Content-Transfer-Encoding: binary
78
- MIME-Version: 1.0
79
- Content-ID: %s
80
-
81
- %s
82
- %s%s
83
-
84
-
85
- EOF;
86
-
87
- /** @var Google_Http_Request $req */
88
- foreach ($this->requests as $key => $request) {
89
- $firstLine = sprintf(
90
- '%s %s HTTP/%s',
91
- $request->getMethod(),
92
- $request->getRequestTarget(),
93
- $request->getProtocolVersion()
94
- );
95
-
96
- $content = (string) $request->getBody();
97
-
98
- $headers = '';
99
- foreach ($request->getHeaders() as $name => $values) {
100
- $headers .= sprintf("%s:%s\r\n", $name, implode(', ', $values));
101
- }
102
-
103
- $body .= sprintf(
104
- $batchHttpTemplate,
105
- $this->boundary,
106
- $key,
107
- $firstLine,
108
- $headers,
109
- $content ? "\n".$content : ''
110
- );
111
-
112
- $classes['response-' . $key] = $request->getHeaderLine('X-Php-Expected-Class');
113
- }
114
-
115
- $body .= "--{$this->boundary}--";
116
- $body = trim($body);
117
- $url = $this->rootUrl . '/' . $this->batchPath;
118
- $headers = array(
119
- 'Content-Type' => sprintf('multipart/mixed; boundary=%s', $this->boundary),
120
- 'Content-Length' => strlen($body),
121
- );
122
-
123
- $request = new Request(
124
- 'POST',
125
- $url,
126
- $headers,
127
- $body
128
- );
129
-
130
- $response = $this->client->execute($request);
131
-
132
- return $this->parseResponse($response, $classes);
133
- }
134
-
135
- public function parseResponse(ResponseInterface $response, $classes = array())
136
- {
137
- $contentType = $response->getHeaderLine('content-type');
138
- $contentType = explode(';', $contentType);
139
- $boundary = false;
140
- foreach ($contentType as $part) {
141
- $part = explode('=', $part, 2);
142
- if (isset($part[0]) && 'boundary' == trim($part[0])) {
143
- $boundary = $part[1];
144
- }
145
- }
146
-
147
- $body = (string) $response->getBody();
148
- if (!empty($body)) {
149
- $body = str_replace("--$boundary--", "--$boundary", $body);
150
- $parts = explode("--$boundary", $body);
151
- $responses = array();
152
- $requests = array_values($this->requests);
153
-
154
- foreach ($parts as $i => $part) {
155
- $part = trim($part);
156
- if (!empty($part)) {
157
- list($rawHeaders, $part) = explode("\r\n\r\n", $part, 2);
158
- $headers = $this->parseRawHeaders($rawHeaders);
159
-
160
- $status = substr($part, 0, strpos($part, "\n"));
161
- $status = explode(" ", $status);
162
- $status = $status[1];
163
-
164
- list($partHeaders, $partBody) = $this->parseHttpResponse($part, false);
165
- $response = new Response(
166
- $status,
167
- $partHeaders,
168
- Psr7\stream_for($partBody)
169
- );
170
-
171
- // Need content id.
172
- $key = $headers['content-id'];
173
-
174
- try {
175
- $response = Google_Http_REST::decodeHttpResponse($response, $requests[$i-1]);
176
- } catch (Google_Service_Exception $e) {
177
- // Store the exception as the response, so successful responses
178
- // can be processed.
179
- $response = $e;
180
- }
181
-
182
- $responses[$key] = $response;
183
- }
184
- }
185
-
186
- return $responses;
187
- }
188
-
189
- return null;
190
- }
191
-
192
- private function parseRawHeaders($rawHeaders)
193
- {
194
- $headers = array();
195
- $responseHeaderLines = explode("\r\n", $rawHeaders);
196
- foreach ($responseHeaderLines as $headerLine) {
197
- if ($headerLine && strpos($headerLine, ':') !== false) {
198
- list($header, $value) = explode(': ', $headerLine, 2);
199
- $header = strtolower($header);
200
- if (isset($headers[$header])) {
201
- $headers[$header] .= "\n" . $value;
202
- } else {
203
- $headers[$header] = $value;
204
- }
205
- }
206
- }
207
- return $headers;
208
- }
209
-
210
- /**
211
- * Used by the IO lib and also the batch processing.
212
- *
213
- * @param $respData
214
- * @param $headerSize
215
- * @return array
216
- */
217
- private function parseHttpResponse($respData, $headerSize)
218
- {
219
- // check proxy header
220
- foreach (self::$CONNECTION_ESTABLISHED_HEADERS as $established_header) {
221
- if (stripos($respData, $established_header) !== false) {
222
- // existed, remove it
223
- $respData = str_ireplace($established_header, '', $respData);
224
- // Subtract the proxy header size unless the cURL bug prior to 7.30.0
225
- // is present which prevented the proxy header size from being taken into
226
- // account.
227
- // @TODO look into this
228
- // if (!$this->needsQuirk()) {
229
- // $headerSize -= strlen($established_header);
230
- // }
231
- break;
232
- }
233
- }
234
-
235
- if ($headerSize) {
236
- $responseBody = substr($respData, $headerSize);
237
- $responseHeaders = substr($respData, 0, $headerSize);
238
- } else {
239
- $responseSegments = explode("\r\n\r\n", $respData, 2);
240
- $responseHeaders = $responseSegments[0];
241
- $responseBody = isset($responseSegments[1]) ? $responseSegments[1] :
242
- null;
243
- }
244
-
245
- $responseHeaders = $this->parseRawHeaders($responseHeaders);
246
-
247
- return array($responseHeaders, $responseBody);
248
- }
249
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/src/Google/Http/MediaFileUpload.php DELETED
@@ -1,351 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright 2012 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- use GuzzleHttp\Psr7;
19
- use GuzzleHttp\Psr7\Request;
20
- use GuzzleHttp\Psr7\Uri;
21
- use Psr\Http\Message\RequestInterface;
22
-
23
- /**
24
- * Manage large file uploads, which may be media but can be any type
25
- * of sizable data.
26
- */
27
- class Google_Http_MediaFileUpload
28
- {
29
- const UPLOAD_MEDIA_TYPE = 'media';
30
- const UPLOAD_MULTIPART_TYPE = 'multipart';
31
- const UPLOAD_RESUMABLE_TYPE = 'resumable';
32
-
33
- /** @var string $mimeType */
34
- private $mimeType;
35
-
36
- /** @var string $data */
37
- private $data;
38
-
39
- /** @var bool $resumable */
40
- private $resumable;
41
-
42
- /** @var int $chunkSize */
43
- private $chunkSize;
44
-
45
- /** @var int $size */
46
- private $size;
47
-
48
- /** @var string $resumeUri */
49
- private $resumeUri;
50
-
51
- /** @var int $progress */
52
- private $progress;
53
-
54
- /** @var Google_Client */
55
- private $client;
56
-
57
- /** @var Psr\Http\Message\RequestInterface */
58
- private $request;
59
-
60
- /** @var string */
61
- private $boundary;
62
-
63
- /**
64
- * Result code from last HTTP call
65
- * @var int
66
- */
67
- private $httpResultCode;
68
-
69
- /**
70
- * @param $mimeType string
71
- * @param $data string The bytes you want to upload.
72
- * @param $resumable bool
73
- * @param bool $chunkSize File will be uploaded in chunks of this many bytes.
74
- * only used if resumable=True
75
- */
76
- public function __construct(
77
- Google_Client $client,
78
- RequestInterface $request,
79
- $mimeType,
80
- $data,
81
- $resumable = false,
82
- $chunkSize = false
83
- ) {
84
- $this->client = $client;
85
- $this->request = $request;
86
- $this->mimeType = $mimeType;
87
- $this->data = $data;
88
- $this->resumable = $resumable;
89
- $this->chunkSize = $chunkSize;
90
- $this->progress = 0;
91
-
92
- $this->process();
93
- }
94
-
95
- /**
96
- * Set the size of the file that is being uploaded.
97
- * @param $size - int file size in bytes
98
- */
99
- public function setFileSize($size)
100
- {
101
- $this->size = $size;
102
- }
103
-
104
- /**
105
- * Return the progress on the upload
106
- * @return int progress in bytes uploaded.
107
- */
108
- public function getProgress()
109
- {
110
- return $this->progress;
111
- }
112
-
113
- /**
114
- * Send the next part of the file to upload.
115
- * @param [$chunk] the next set of bytes to send. If false will used $data passed
116
- * at construct time.
117
- */
118
- public function nextChunk($chunk = false)
119
- {
120
- $resumeUri = $this->getResumeUri();
121
-
122
- if (false == $chunk) {
123
- $chunk = substr($this->data, $this->progress, $this->chunkSize);
124
- }
125
-
126
- $lastBytePos = $this->progress + strlen($chunk) - 1;
127
- $headers = array(
128
- 'content-range' => "bytes $this->progress-$lastBytePos/$this->size",
129
- 'content-length' => strlen($chunk),
130
- 'expect' => '',
131
- );
132
-
133
- $request = new Request(
134
- 'PUT',
135
- $resumeUri,
136
- $headers,
137
- Psr7\stream_for($chunk)
138
- );
139
-
140
- return $this->makePutRequest($request);
141
- }
142
-
143
- /**
144
- * Return the HTTP result code from the last call made.
145
- * @return int code
146
- */
147
- public function getHttpResultCode()
148
- {
149
- return $this->httpResultCode;
150
- }
151
-
152
- /**
153
- * Sends a PUT-Request to google drive and parses the response,
154
- * setting the appropiate variables from the response()
155
- *
156
- * @param Google_Http_Request $httpRequest the Reuqest which will be send
157
- *
158
- * @return false|mixed false when the upload is unfinished or the decoded http response
159
- *
160
- */
161
- private function makePutRequest(RequestInterface $request)
162
- {
163
- $response = $this->client->execute($request);
164
- $this->httpResultCode = $response->getStatusCode();
165
-
166
- if (308 == $this->httpResultCode) {
167
- // Track the amount uploaded.
168
- $range = $response->getHeaderLine('range');
169
- if ($range) {
170
- $range_array = explode('-', $range);
171
- $this->progress = $range_array[1] + 1;
172
- }
173
-
174
- // Allow for changing upload URLs.
175
- $location = $response->getHeaderLine('location');
176
- if ($location) {
177
- $this->resumeUri = $location;
178
- }
179
-
180
- // No problems, but upload not complete.
181
- return false;
182
- }
183
-
184
- return Google_Http_REST::decodeHttpResponse($response, $this->request);
185
- }
186
-
187
- /**
188
- * Resume a previously unfinished upload
189
- * @param $resumeUri the resume-URI of the unfinished, resumable upload.
190
- */
191
- public function resume($resumeUri)
192
- {
193
- $this->resumeUri = $resumeUri;
194
- $headers = array(
195
- 'content-range' => "bytes */$this->size",
196
- 'content-length' => 0,
197
- );
198
- $httpRequest = new Request(
199
- 'PUT',
200
- $this->resumeUri,
201
- $headers
202
- );
203
-
204
- return $this->makePutRequest($httpRequest);
205
- }
206
-
207
- /**
208
- * @return Psr\Http\Message\RequestInterface $request
209
- * @visible for testing
210
- */
211
- private function process()
212
- {
213
- $this->transformToUploadUrl();
214
- $request = $this->request;
215
-
216
- $postBody = '';
217
- $contentType = false;
218
-
219
- $meta = (string) $request->getBody();
220
- $meta = is_string($meta) ? json_decode($meta, true) : $meta;
221
-
222
- $uploadType = $this->getUploadType($meta);
223
- $request = $request->withUri(
224
- Uri::withQueryValue($request->getUri(), 'uploadType', $uploadType)
225
- );
226
-
227
- $mimeType = $this->mimeType ?: $request->getHeaderLine('content-type');
228
-
229
- if (self::UPLOAD_RESUMABLE_TYPE == $uploadType) {
230
- $contentType = $mimeType;
231
- $postBody = is_string($meta) ? $meta : json_encode($meta);
232
- } else if (self::UPLOAD_MEDIA_TYPE == $uploadType) {
233
- $contentType = $mimeType;
234
- $postBody = $this->data;
235
- } else if (self::UPLOAD_MULTIPART_TYPE == $uploadType) {
236
- // This is a multipart/related upload.
237
- $boundary = $this->boundary ?: mt_rand();
238
- $boundary = str_replace('"', '', $boundary);
239
- $contentType = 'multipart/related; boundary=' . $boundary;
240
- $related = "--$boundary\r\n";
241
- $related .= "Content-Type: application/json; charset=UTF-8\r\n";
242
- $related .= "\r\n" . json_encode($meta) . "\r\n";
243
- $related .= "--$boundary\r\n";
244
- $related .= "Content-Type: $mimeType\r\n";
245
- $related .= "Content-Transfer-Encoding: base64\r\n";
246
- $related .= "\r\n" . base64_encode($this->data) . "\r\n";
247
- $related .= "--$boundary--";
248
- $postBody = $related;
249
- }
250
-
251
- $request = $request->withBody(Psr7\stream_for($postBody));
252
-
253
- if (isset($contentType) && $contentType) {
254
- $request = $request->withHeader('content-type', $contentType);
255
- }
256
-
257
- return $this->request = $request;
258
- }
259
-
260
- /**
261
- * Valid upload types:
262
- * - resumable (UPLOAD_RESUMABLE_TYPE)
263
- * - media (UPLOAD_MEDIA_TYPE)
264
- * - multipart (UPLOAD_MULTIPART_TYPE)
265
- * @param $meta
266
- * @return string
267
- * @visible for testing
268
- */
269
- public function getUploadType($meta)
270
- {
271
- if ($this->resumable) {
272
- return self::UPLOAD_RESUMABLE_TYPE;
273
- }
274
-
275
- if (false == $meta && $this->data) {
276
- return self::UPLOAD_MEDIA_TYPE;
277
- }
278
-
279
- return self::UPLOAD_MULTIPART_TYPE;
280
- }
281
-
282
- public function getResumeUri()
283
- {
284
- if (null === $this->resumeUri) {
285
- $this->resumeUri = $this->fetchResumeUri();
286
- }
287
-
288
- return $this->resumeUri;
289
- }
290
-
291
- private function fetchResumeUri()
292
- {
293
- $body = $this->request->getBody();
294
- if ($body) {
295
- $headers = array(
296
- 'content-type' => 'application/json; charset=UTF-8',
297
- 'content-length' => $body->getSize(),
298
- 'x-upload-content-type' => $this->mimeType,
299
- 'x-upload-content-length' => $this->size,
300
- 'expect' => '',
301
- );
302
- foreach ($headers as $key => $value) {
303
- $this->request = $this->request->withHeader($key, $value);
304
- }
305
- }
306
-
307
- $response = $this->client->execute($this->request, false);
308
- $location = $response->getHeaderLine('location');
309
- $code = $response->getStatusCode();
310
-
311
- if (200 == $code && true == $location) {
312
- return $location;
313
- }
314
-
315
- $message = $code;
316
- $body = json_decode((string) $this->request->getBody(), true);
317
- if (isset($body['error']['errors'])) {
318
- $message .= ': ';
319
- foreach ($body['error']['errors'] as $error) {
320
- $message .= "{$error[domain]}, {$error[message]};";
321
- }
322
- $message = rtrim($message, ';');
323
- }
324
-
325
- $error = "Failed to start the resumable upload (HTTP {$message})";
326
- $this->client->getLogger()->error($error);
327
-
328
- throw new Google_Exception($error);
329
- }
330
-
331
- private function transformToUploadUrl()
332
- {
333
- $parts = parse_url((string) $this->request->getUri());
334
- if (!isset($parts['path'])) {
335
- $parts['path'] = '';
336
- }
337
- $parts['path'] = '/upload' . $parts['path'];
338
- $uri = Uri::fromParts($parts);
339
- $this->request = $this->request->withUri($uri);
340
- }
341
-
342
- public function setChunkSize($chunkSize)
343
- {
344
- $this->chunkSize = $chunkSize;
345
- }
346
-
347
- public function getRequest()
348
- {
349
- return $this->request;
350
- }
351
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/src/Google/Http/REST.php DELETED
@@ -1,182 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2010 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- use Google\Auth\HttpHandler\HttpHandlerFactory;
19
- use GuzzleHttp\ClientInterface;
20
- use GuzzleHttp\Exception\RequestException;
21
- use GuzzleHttp\Psr7\Response;
22
- use Psr\Http\Message\RequestInterface;
23
- use Psr\Http\Message\ResponseInterface;
24
-
25
- /**
26
- * This class implements the RESTful transport of apiServiceRequest()'s
27
- */
28
- class Google_Http_REST
29
- {
30
- /**
31
- * Executes a Psr\Http\Message\RequestInterface and (if applicable) automatically retries
32
- * when errors occur.
33
- *
34
- * @param Google_Client $client
35
- * @param Psr\Http\Message\RequestInterface $req
36
- * @return array decoded result
37
- * @throws Google_Service_Exception on server side error (ie: not authenticated,
38
- * invalid or malformed post body, invalid url)
39
- */
40
- public static function execute(
41
- ClientInterface $client,
42
- RequestInterface $request,
43
- $expectedClass = null,
44
- $config = array(),
45
- $retryMap = null
46
- ) {
47
- $runner = new Google_Task_Runner(
48
- $config,
49
- sprintf('%s %s', $request->getMethod(), (string) $request->getUri()),
50
- array(get_class(), 'doExecute'),
51
- array($client, $request, $expectedClass)
52
- );
53
-
54
- if (null !== $retryMap) {
55
- $runner->setRetryMap($retryMap);
56
- }
57
-
58
- return $runner->run();
59
- }
60
-
61
- /**
62
- * Executes a Psr\Http\Message\RequestInterface
63
- *
64
- * @param Google_Client $client
65
- * @param Psr\Http\Message\RequestInterface $request
66
- * @return array decoded result
67
- * @throws Google_Service_Exception on server side error (ie: not authenticated,
68
- * invalid or malformed post body, invalid url)
69
- */
70
- public static function doExecute(ClientInterface $client, RequestInterface $request, $expectedClass = null)
71
- {
72
- try {
73
- $httpHandler = HttpHandlerFactory::build($client);
74
- $response = $httpHandler($request);
75
- } catch (RequestException $e) {
76
- // if Guzzle throws an exception, catch it and handle the response
77
- if (!$e->hasResponse()) {
78
- throw $e;
79
- }
80
-
81
- $response = $e->getResponse();
82
- // specific checking for Guzzle 5: convert to PSR7 response
83
- if ($response instanceof \GuzzleHttp\Message\ResponseInterface) {
84
- $response = new Response(
85
- $response->getStatusCode(),
86
- $response->getHeaders() ?: [],
87
- $response->getBody(),
88
- $response->getProtocolVersion(),
89
- $response->getReasonPhrase()
90
- );
91
- }
92
- }
93
-
94
- return self::decodeHttpResponse($response, $request, $expectedClass);
95
- }
96
-
97
- /**
98
- * Decode an HTTP Response.
99
- * @static
100
- * @throws Google_Service_Exception
101
- * @param Psr\Http\Message\RequestInterface $response The http response to be decoded.
102
- * @param Psr\Http\Message\ResponseInterface $response
103
- * @return mixed|null
104
- */
105
- public static function decodeHttpResponse(
106
- ResponseInterface $response,
107
- RequestInterface $request = null,
108
- $expectedClass = null
109
- ) {
110
- $code = $response->getStatusCode();
111
-
112
- // retry strategy
113
- if (intVal($code) >= 400) {
114
- // if we errored out, it should be safe to grab the response body
115
- $body = (string) $response->getBody();
116
-
117
- // Check if we received errors, and add those to the Exception for convenience
118
- throw new Google_Service_Exception($body, $code, null, self::getResponseErrors($body));
119
- }
120
-
121
- // Ensure we only pull the entire body into memory if the request is not
122
- // of media type
123
- $body = self::decodeBody($response, $request);
124
-
125
- if ($expectedClass = self::determineExpectedClass($expectedClass, $request)) {
126
- $json = json_decode($body, true);
127
-
128
- return new $expectedClass($json);
129
- }
130
-
131
- return $response;
132
- }
133
-
134
- private static function decodeBody(ResponseInterface $response, RequestInterface $request = null)
135
- {
136
- if (self::isAltMedia($request)) {
137
- // don't decode the body, it's probably a really long string
138
- return '';
139
- }
140
-
141
- return (string) $response->getBody();
142
- }
143
-
144
- private static function determineExpectedClass($expectedClass, RequestInterface $request = null)
145
- {
146
- // "false" is used to explicitly prevent an expected class from being returned
147
- if (false === $expectedClass) {
148
- return null;
149
- }
150
-
151
- // if we don't have a request, we just use what's passed in
152
- if (null === $request) {
153
- return $expectedClass;
154
- }
155
-
156
- // return what we have in the request header if one was not supplied
157
- return $expectedClass ?: $request->getHeaderLine('X-Php-Expected-Class');
158
- }
159
-
160
- private static function getResponseErrors($body)
161
- {
162
- $json = json_decode($body, true);
163
-
164
- if (isset($json['error']['errors'])) {
165
- return $json['error']['errors'];
166
- }
167
-
168
- return null;
169
- }
170
-
171
- private static function isAltMedia(RequestInterface $request = null)
172
- {
173
- if ($request && $qs = $request->getUri()->getQuery()) {
174
- parse_str($qs, $query);
175
- if (isset($query['alt']) && $query['alt'] == 'media') {
176
- return true;
177
- }
178
- }
179
-
180
- return false;
181
- }
182
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/src/Google/Model.php DELETED
@@ -1,324 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2011 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- /**
19
- * This class defines attributes, valid values, and usage which is generated
20
- * from a given json schema.
21
- * http://tools.ietf.org/html/draft-zyp-json-schema-03#section-5
22
- *
23
- */
24
- class Google_Model implements ArrayAccess
25
- {
26
- /**
27
- * If you need to specify a NULL JSON value, use Google_Model::NULL_VALUE
28
- * instead - it will be replaced when converting to JSON with a real null.
29
- */
30
- const NULL_VALUE = "{}gapi-php-null";
31
- protected $internal_gapi_mappings = array();
32
- protected $modelData = array();
33
- protected $processed = array();
34
-
35
- /**
36
- * Polymorphic - accepts a variable number of arguments dependent
37
- * on the type of the model subclass.
38
- */
39
- final public function __construct()
40
- {
41
- if (func_num_args() == 1 && is_array(func_get_arg(0))) {
42
- // Initialize the model with the array's contents.
43
- $array = func_get_arg(0);
44
- $this->mapTypes($array);
45
- }
46
- $this->gapiInit();
47
- }
48
-
49
- /**
50
- * Getter that handles passthrough access to the data array, and lazy object creation.
51
- * @param string $key Property name.
52
- * @return mixed The value if any, or null.
53
- */
54
- public function __get($key)
55
- {
56
- $keyTypeName = $this->keyType($key);
57
- $keyDataType = $this->dataType($key);
58
- if (isset($this->$keyTypeName) && !isset($this->processed[$key])) {
59
- if (isset($this->modelData[$key])) {
60
- $val = $this->modelData[$key];
61
- } else if (isset($this->$keyDataType) &&
62
- ($this->$keyDataType == 'array' || $this->$keyDataType == 'map')) {
63
- $val = array();
64
- } else {
65
- $val = null;
66
- }
67
-
68
- if ($this->isAssociativeArray($val)) {
69
- if (isset($this->$keyDataType) && 'map' == $this->$keyDataType) {
70
- foreach ($val as $arrayKey => $arrayItem) {
71
- $this->modelData[$key][$arrayKey] =
72
- $this->createObjectFromName($keyTypeName, $arrayItem);
73
- }
74
- } else {
75
- $this->modelData[$key] = $this->createObjectFromName($keyTypeName, $val);
76
- }
77
- } else if (is_array($val)) {
78
- $arrayObject = array();
79
- foreach ($val as $arrayIndex => $arrayItem) {
80
- $arrayObject[$arrayIndex] =
81
- $this->createObjectFromName($keyTypeName, $arrayItem);
82
- }
83
- $this->modelData[$key] = $arrayObject;
84
- }
85
- $this->processed[$key] = true;
86
- }
87
-
88
- return isset($this->modelData[$key]) ? $this->modelData[$key] : null;
89
- }
90
-
91
- /**
92
- * Initialize this object's properties from an array.
93
- *
94
- * @param array $array Used to seed this object's properties.
95
- * @return void
96
- */
97
- protected function mapTypes($array)
98
- {
99
- // Hard initialise simple types, lazy load more complex ones.
100
- foreach ($array as $key => $val) {
101
- if (property_exists($this, $this->keyType($key))) {
102
- $propertyClass = $this->{$this->keyType($key)};
103
- $dataType = $this->{$this->dataType($key)};
104
- if ($dataType == 'array' || $dataType == 'map') {
105
- $this->$key = array();
106
- foreach ($val as $itemKey => $itemVal) {
107
- if ($itemVal instanceof $propertyClass) {
108
- $this->{$key}[$itemKey] = $itemVal;
109
- } else {
110
- $this->{$key}[$itemKey] = new $propertyClass($itemVal);
111
- }
112
- }
113
- } elseif ($val instanceof $propertyClass) {
114
- $this->$key = $val;
115
- } else {
116
- $this->$key = new $propertyClass($val);
117
- }
118
- unset($array[$key]);
119
- } elseif (property_exists($this, $key)) {
120
- $this->$key = $val;
121
- unset($array[$key]);
122
- } elseif (property_exists($this, $camelKey = $this->camelCase($key))) {
123
- // This checks if property exists as camelCase, leaving it in array as snake_case
124
- // in case of backwards compatibility issues.
125
- $this->$camelKey = $val;
126
- }
127
- }
128
- $this->modelData = $array;
129
- }
130
-
131
- /**
132
- * Blank initialiser to be used in subclasses to do post-construction initialisation - this
133
- * avoids the need for subclasses to have to implement the variadics handling in their
134
- * constructors.
135
- */
136
- protected function gapiInit()
137
- {
138
- return;
139
- }
140
-
141
- /**
142
- * Create a simplified object suitable for straightforward
143
- * conversion to JSON. This is relatively expensive
144
- * due to the usage of reflection, but shouldn't be called
145
- * a whole lot, and is the most straightforward way to filter.
146
- */
147
- public function toSimpleObject()
148
- {
149
- $object = new stdClass();
150
-
151
- // Process all other data.
152
- foreach ($this->modelData as $key => $val) {
153
- $result = $this->getSimpleValue($val);
154
- if ($result !== null) {
155
- $object->$key = $this->nullPlaceholderCheck($result);
156
- }
157
- }
158
-
159
- // Process all public properties.
160
- $reflect = new ReflectionObject($this);
161
- $props = $reflect->getProperties(ReflectionProperty::IS_PUBLIC);
162
- foreach ($props as $member) {
163
- $name = $member->getName();
164
- $result = $this->getSimpleValue($this->$name);
165
- if ($result !== null) {
166
- $name = $this->getMappedName($name);
167
- $object->$name = $this->nullPlaceholderCheck($result);
168
- }
169
- }
170
-
171
- return $object;
172
- }
173
-
174
- /**
175
- * Handle different types of values, primarily
176
- * other objects and map and array data types.
177
- */
178
- private function getSimpleValue($value)
179
- {
180
- if ($value instanceof Google_Model) {
181
- return $value->toSimpleObject();
182
- } else if (is_array($value)) {
183
- $return = array();
184
- foreach ($value as $key => $a_value) {
185
- $a_value = $this->getSimpleValue($a_value);
186
- if ($a_value !== null) {
187
- $key = $this->getMappedName($key);
188
- $return[$key] = $this->nullPlaceholderCheck($a_value);
189
- }
190
- }
191
- return $return;
192
- }
193
- return $value;
194
- }
195
-
196
- /**
197
- * Check whether the value is the null placeholder and return true null.
198
- */
199
- private function nullPlaceholderCheck($value)
200
- {
201
- if ($value === self::NULL_VALUE) {
202
- return null;
203
- }
204
- return $value;
205
- }
206
-
207
- /**
208
- * If there is an internal name mapping, use that.
209
- */
210
- private function getMappedName($key)
211
- {
212
- if (isset($this->internal_gapi_mappings, $this->internal_gapi_mappings[$key])) {
213
- $key = $this->internal_gapi_mappings[$key];
214
- }
215
- return $key;
216
- }
217
-
218
- /**
219
- * Returns true only if the array is associative.
220
- * @param array $array
221
- * @return bool True if the array is associative.
222
- */
223
- protected function isAssociativeArray($array)
224
- {
225
- if (!is_array($array)) {
226
- return false;
227
- }
228
- $keys = array_keys($array);
229
- foreach ($keys as $key) {
230
- if (is_string($key)) {
231
- return true;
232
- }
233
- }
234
- return false;
235
- }
236
-
237
- /**
238
- * Given a variable name, discover its type.
239
- *
240
- * @param $name
241
- * @param $item
242
- * @return object The object from the item.
243
- */
244
- private function createObjectFromName($name, $item)
245
- {
246
- $type = $this->$name;
247
- return new $type($item);
248
- }
249
-
250
- /**
251
- * Verify if $obj is an array.
252
- * @throws Google_Exception Thrown if $obj isn't an array.
253
- * @param array $obj Items that should be validated.
254
- * @param string $method Method expecting an array as an argument.
255
- */
256
- public function assertIsArray($obj, $method)
257
- {
258
- if ($obj && !is_array($obj)) {
259
- throw new Google_Exception(
260
- "Incorrect parameter type passed to $method(). Expected an array."
261
- );
262
- }
263
- }
264
-
265
- public function offsetExists($offset)
266
- {
267
- return isset($this->$offset) || isset($this->modelData[$offset]);
268
- }
269
-
270
- public function offsetGet($offset)
271
- {
272
- return isset($this->$offset) ?
273
- $this->$offset :
274
- $this->__get($offset);
275
- }
276
-
277
- public function offsetSet($offset, $value)
278
- {
279
- if (property_exists($this, $offset)) {
280
- $this->$offset = $value;
281
- } else {
282
- $this->modelData[$offset] = $value;
283
- $this->processed[$offset] = true;
284
- }
285
- }
286
-
287
- public function offsetUnset($offset)
288
- {
289
- unset($this->modelData[$offset]);
290
- }
291
-
292
- protected function keyType($key)
293
- {
294
- return $key . "Type";
295
- }
296
-
297
- protected function dataType($key)
298
- {
299
- return $key . "DataType";
300
- }
301
-
302
- public function __isset($key)
303
- {
304
- return isset($this->modelData[$key]);
305
- }
306
-
307
- public function __unset($key)
308
- {
309
- unset($this->modelData[$key]);
310
- }
311
-
312
- /**
313
- * Convert a string to camelCase
314
- * @param string $value
315
- * @return string
316
- */
317
- private function camelCase($value)
318
- {
319
- $value = ucwords(str_replace(array('-', '_'), ' ', $value));
320
- $value = str_replace(' ', '', $value);
321
- $value[0] = strtolower($value[0]);
322
- return $value;
323
- }
324
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/src/Google/Service.php DELETED
@@ -1,56 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2010 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- class Google_Service
19
- {
20
- public $batchPath;
21
- public $rootUrl;
22
- public $version;
23
- public $servicePath;
24
- public $availableScopes;
25
- public $resource;
26
- private $client;
27
-
28
- public function __construct(Google_Client $client)
29
- {
30
- $this->client = $client;
31
- }
32
-
33
- /**
34
- * Return the associated Google_Client class.
35
- * @return Google_Client
36
- */
37
- public function getClient()
38
- {
39
- return $this->client;
40
- }
41
-
42
- /**
43
- * Create a new HTTP Batch handler for this service
44
- *
45
- * @return Google_Http_Batch
46
- */
47
- public function createBatch()
48
- {
49
- return new Google_Http_Batch(
50
- $this->client,
51
- false,
52
- $this->rootUrl,
53
- $this->batchPath
54
- );
55
- }
56
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/src/Google/Service/Exception.php DELETED
@@ -1,68 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2014 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- class Google_Service_Exception extends Google_Exception
19
- {
20
- /**
21
- * Optional list of errors returned in a JSON body of an HTTP error response.
22
- */
23
- protected $errors = array();
24
-
25
- /**
26
- * Override default constructor to add the ability to set $errors and a retry
27
- * map.
28
- *
29
- * @param string $message
30
- * @param int $code
31
- * @param Exception|null $previous
32
- * @param [{string, string}] errors List of errors returned in an HTTP
33
- * response. Defaults to [].
34
- * @param array|null $retryMap Map of errors with retry counts.
35
- */
36
- public function __construct(
37
- $message,
38
- $code = 0,
39
- Exception $previous = null,
40
- $errors = array()
41
- ) {
42
- if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
43
- parent::__construct($message, $code, $previous);
44
- } else {
45
- parent::__construct($message, $code);
46
- }
47
-
48
- $this->errors = $errors;
49
- }
50
-
51
- /**
52
- * An example of the possible errors returned.
53
- *
54
- * {
55
- * "domain": "global",
56
- * "reason": "authError",
57
- * "message": "Invalid Credentials",
58
- * "locationType": "header",
59
- * "location": "Authorization",
60
- * }
61
- *
62
- * @return [{string, string}] List of errors return in an HTTP response or [].
63
- */
64
- public function getErrors()
65
- {
66
- return $this->errors;
67
- }
68
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/src/Google/Service/README.md DELETED
@@ -1,5 +0,0 @@
1
- # Google API Client Services
2
-
3
- Google API Client Service classes have been moved to the
4
- [google-api-php-client-services](https://github.com/google/google-api-php-client-services)
5
- repository.
 
 
 
 
 
lib/google-api-php-client/src/Google/Service/Resource.php DELETED
@@ -1,296 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright 2010 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- use GuzzleHttp\Psr7\Request;
19
-
20
- /**
21
- * Implements the actual methods/resources of the discovered Google API using magic function
22
- * calling overloading (__call()), which on call will see if the method name (plus.activities.list)
23
- * is available in this service, and if so construct an apiHttpRequest representing it.
24
- *
25
- */
26
- class Google_Service_Resource
27
- {
28
- // Valid query parameters that work, but don't appear in discovery.
29
- private $stackParameters = array(
30
- 'alt' => array('type' => 'string', 'location' => 'query'),
31
- 'fields' => array('type' => 'string', 'location' => 'query'),
32
- 'trace' => array('type' => 'string', 'location' => 'query'),
33
- 'userIp' => array('type' => 'string', 'location' => 'query'),
34
- 'quotaUser' => array('type' => 'string', 'location' => 'query'),
35
- 'data' => array('type' => 'string', 'location' => 'body'),
36
- 'mimeType' => array('type' => 'string', 'location' => 'header'),
37
- 'uploadType' => array('type' => 'string', 'location' => 'query'),
38
- 'mediaUpload' => array('type' => 'complex', 'location' => 'query'),
39
- 'prettyPrint' => array('type' => 'string', 'location' => 'query'),
40
- );
41
-
42
- /** @var string $rootUrl */
43
- private $rootUrl;
44
-
45
- /** @var Google_Client $client */
46
- private $client;
47
-
48
- /** @var string $serviceName */
49
- private $serviceName;
50
-
51
- /** @var string $servicePath */
52
- private $servicePath;
53
-
54
- /** @var string $resourceName */
55
- private $resourceName;
56
-
57
- /** @var array $methods */
58
- private $methods;
59
-
60
- public function __construct($service, $serviceName, $resourceName, $resource)
61
- {
62
- $this->rootUrl = $service->rootUrl;
63
- $this->client = $service->getClient();
64
- $this->servicePath = $service->servicePath;
65
- $this->serviceName = $serviceName;
66
- $this->resourceName = $resourceName;
67
- $this->methods = is_array($resource) && isset($resource['methods']) ?
68
- $resource['methods'] :
69
- array($resourceName => $resource);
70
- }
71
-
72
- /**
73
- * TODO: This function needs simplifying.
74
- * @param $name
75
- * @param $arguments
76
- * @param $expectedClass - optional, the expected class name
77
- * @return Google_Http_Request|expectedClass
78
- * @throws Google_Exception
79
- */
80
- public function call($name, $arguments, $expectedClass = null)
81
- {
82
- if (! isset($this->methods[$name])) {
83
- $this->client->getLogger()->error(
84
- 'Service method unknown',
85
- array(
86
- 'service' => $this->serviceName,
87
- 'resource' => $this->resourceName,
88
- 'method' => $name
89
- )
90
- );
91
-
92
- throw new Google_Exception(
93
- "Unknown function: " .
94
- "{$this->serviceName}->{$this->resourceName}->{$name}()"
95
- );
96
- }
97
- $method = $this->methods[$name];
98
- $parameters = $arguments[0];
99
-
100
- // postBody is a special case since it's not defined in the discovery
101
- // document as parameter, but we abuse the param entry for storing it.
102
- $postBody = null;
103
- if (isset($parameters['postBody'])) {
104
- if ($parameters['postBody'] instanceof Google_Model) {
105
- // In the cases the post body is an existing object, we want
106
- // to use the smart method to create a simple object for
107
- // for JSONification.
108
- $parameters['postBody'] = $parameters['postBody']->toSimpleObject();
109
- } else if (is_object($parameters['postBody'])) {
110
- // If the post body is another kind of object, we will try and
111
- // wrangle it into a sensible format.
112
- $parameters['postBody'] =
113
- $this->convertToArrayAndStripNulls($parameters['postBody']);
114
- }
115
- $postBody = (array) $parameters['postBody'];
116
- unset($parameters['postBody']);
117
- }
118
-
119
- // TODO: optParams here probably should have been
120
- // handled already - this may well be redundant code.
121
- if (isset($parameters['optParams'])) {
122
- $optParams = $parameters['optParams'];
123
- unset($parameters['optParams']);
124
- $parameters = array_merge($parameters, $optParams);
125
- }
126
-
127
- if (!isset($method['parameters'])) {
128
- $method['parameters'] = array();
129
- }
130
-
131
- $method['parameters'] = array_merge(
132
- $this->stackParameters,
133
- $method['parameters']
134
- );
135
-
136
- foreach ($parameters as $key => $val) {
137
- if ($key != 'postBody' && ! isset($method['parameters'][$key])) {
138
- $this->client->getLogger()->error(
139
- 'Service parameter unknown',
140
- array(
141
- 'service' => $this->serviceName,
142
- 'resource' => $this->resourceName,
143
- 'method' => $name,
144
- 'parameter' => $key
145
- )
146
- );
147
- throw new Google_Exception("($name) unknown parameter: '$key'");
148
- }
149
- }
150
-
151
- foreach ($method['parameters'] as $paramName => $paramSpec) {
152
- if (isset($paramSpec['required']) &&
153
- $paramSpec['required'] &&
154
- ! isset($parameters[$paramName])
155
- ) {
156
- $this->client->getLogger()->error(
157
- 'Service parameter missing',
158
- array(
159
- 'service' => $this->serviceName,
160
- 'resource' => $this->resourceName,
161
- 'method' => $name,
162
- 'parameter' => $paramName
163
- )
164
- );
165
- throw new Google_Exception("($name) missing required param: '$paramName'");
166
- }
167
- if (isset($parameters[$paramName])) {
168
- $value = $parameters[$paramName];
169
- $parameters[$paramName] = $paramSpec;
170
- $parameters[$paramName]['value'] = $value;
171
- unset($parameters[$paramName]['required']);
172
- } else {
173
- // Ensure we don't pass nulls.
174
- unset($parameters[$paramName]);
175
- }
176
- }
177
-
178
- $this->client->getLogger()->info(
179
- 'Service Call',
180
- array(
181
- 'service' => $this->serviceName,
182
- 'resource' => $this->resourceName,
183
- 'method' => $name,
184
- 'arguments' => $parameters,
185
- )
186
- );
187
-
188
- // build the service uri
189
- $url = $this->createRequestUri(
190
- $method['path'],
191
- $parameters
192
- );
193
-
194
- // NOTE: because we're creating the request by hand,
195
- // and because the service has a rootUrl property
196
- // the "base_uri" of the Http Client is not accounted for
197
- $request = new Request(
198
- $method['httpMethod'],
199
- $url,
200
- ['content-type' => 'application/json'],
201
- $postBody ? json_encode($postBody) : ''
202
- );
203
-
204
- // support uploads
205
- if (isset($parameters['data'])) {
206
- $mimeType = isset($parameters['mimeType'])
207
- ? $parameters['mimeType']['value']
208
- : 'application/octet-stream';
209
- $data = $parameters['data']['value'];
210
- $upload = new Google_Http_MediaFileUpload($this->client, $request, $mimeType, $data);
211
-
212
- // pull down the modified request
213
- $request = $upload->getRequest();
214
- }
215
-
216
- // if this is a media type, we will return the raw response
217
- // rather than using an expected class
218
- if (isset($parameters['alt']) && $parameters['alt']['value'] == 'media') {
219
- $expectedClass = null;
220
- }
221
-
222
- // if the client is marked for deferring, rather than
223
- // execute the request, return the response
224
- if ($this->client->shouldDefer()) {
225
- // @TODO find a better way to do this
226
- $request = $request
227
- ->withHeader('X-Php-Expected-Class', $expectedClass);
228
-
229
- return $request;
230
- }
231
-
232
- return $this->client->execute($request, $expectedClass);
233
- }
234
-
235
- protected function convertToArrayAndStripNulls($o)
236
- {
237
- $o = (array) $o;
238
- foreach ($o as $k => $v) {
239
- if ($v === null) {
240
- unset($o[$k]);
241
- } elseif (is_object($v) || is_array($v)) {
242
- $o[$k] = $this->convertToArrayAndStripNulls($o[$k]);
243
- }
244
- }
245
- return $o;
246
- }
247
-
248
- /**
249
- * Parse/expand request parameters and create a fully qualified
250
- * request uri.
251
- * @static
252
- * @param string $restPath
253
- * @param array $params
254
- * @return string $requestUrl
255
- */
256
- public function createRequestUri($restPath, $params)
257
- {
258
- // code for leading slash
259
- $requestUrl = $this->servicePath . $restPath;
260
- if ($this->rootUrl) {
261
- if ('/' !== substr($this->rootUrl, -1) && '/' !== substr($requestUrl, 0, 1)) {
262
- $requestUrl = '/' . $requestUrl;
263
- }
264
- $requestUrl = $this->rootUrl . $requestUrl;
265
- }
266
- $uriTemplateVars = array();
267
- $queryVars = array();
268
- foreach ($params as $paramName => $paramSpec) {
269
- if ($paramSpec['type'] == 'boolean') {
270
- $paramSpec['value'] = $paramSpec['value'] ? 'true' : 'false';
271
- }
272
- if ($paramSpec['location'] == 'path') {
273
- $uriTemplateVars[$paramName] = $paramSpec['value'];
274
- } else if ($paramSpec['location'] == 'query') {
275
- if (isset($paramSpec['repeated']) && is_array($paramSpec['value'])) {
276
- foreach ($paramSpec['value'] as $value) {
277
- $queryVars[] = $paramName . '=' . rawurlencode(rawurldecode($value));
278
- }
279
- } else {
280
- $queryVars[] = $paramName . '=' . rawurlencode(rawurldecode($paramSpec['value']));
281
- }
282
- }
283
- }
284
-
285
- if (count($uriTemplateVars)) {
286
- $uriTemplateParser = new Google_Utils_UriTemplate();
287
- $requestUrl = $uriTemplateParser->parse($requestUrl, $uriTemplateVars);
288
- }
289
-
290
- if (count($queryVars)) {
291
- $requestUrl .= '?' . implode($queryVars, '&');
292
- }
293
-
294
- return $requestUrl;
295
- }
296
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/src/Google/Task/Exception.php DELETED
@@ -1,20 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2014 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- class Google_Task_Exception extends Google_Exception
19
- {
20
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/src/Google/Task/Retryable.php DELETED
@@ -1,24 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2014 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- /**
19
- * Interface for checking how many times a given task can be retried following
20
- * a failure.
21
- */
22
- interface Google_Task_Retryable
23
- {
24
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/src/Google/Task/Runner.php DELETED
@@ -1,281 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2014 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- /**
19
- * A task runner with exponential backoff support.
20
- *
21
- * @see https://developers.google.com/drive/web/handle-errors#implementing_exponential_backoff
22
- */
23
- class Google_Task_Runner
24
- {
25
- const TASK_RETRY_NEVER = 0;
26
- const TASK_RETRY_ONCE = 1;
27
- const TASK_RETRY_ALWAYS = -1;
28
-
29
- /**
30
- * @var integer $maxDelay The max time (in seconds) to wait before a retry.
31
- */
32
- private $maxDelay = 60;
33
- /**
34
- * @var integer $delay The previous delay from which the next is calculated.
35
- */
36
- private $delay = 1;
37
-
38
- /**
39
- * @var integer $factor The base number for the exponential back off.
40
- */
41
- private $factor = 2;
42
- /**
43
- * @var float $jitter A random number between -$jitter and $jitter will be
44
- * added to $factor on each iteration to allow for a better distribution of
45
- * retries.
46
- */
47
- private $jitter = 0.5;
48
-
49
- /**
50
- * @var integer $attempts The number of attempts that have been tried so far.
51
- */
52
- private $attempts = 0;
53
- /**
54
- * @var integer $maxAttempts The max number of attempts allowed.
55
- */
56
- private $maxAttempts = 1;
57
-
58
- /**
59
- * @var callable $action The task to run and possibly retry.
60
- */
61
- private $action;
62
- /**
63
- * @var array $arguments The task arguments.
64
- */
65
- private $arguments;
66
-
67
- /**
68
- * @var array $retryMap Map of errors with retry counts.
69
- */
70
- protected $retryMap = [
71
- '500' => self::TASK_RETRY_ALWAYS,
72
- '503' => self::TASK_RETRY_ALWAYS,
73
- 'rateLimitExceeded' => self::TASK_RETRY_ALWAYS,
74
- 'userRateLimitExceeded' => self::TASK_RETRY_ALWAYS,
75
- 6 => self::TASK_RETRY_ALWAYS, // CURLE_COULDNT_RESOLVE_HOST
76
- 7 => self::TASK_RETRY_ALWAYS, // CURLE_COULDNT_CONNECT
77
- 28 => self::TASK_RETRY_ALWAYS, // CURLE_OPERATION_TIMEOUTED
78
- 35 => self::TASK_RETRY_ALWAYS, // CURLE_SSL_CONNECT_ERROR
79
- 52 => self::TASK_RETRY_ALWAYS // CURLE_GOT_NOTHING
80
- ];
81
-
82
- /**
83
- * Creates a new task runner with exponential backoff support.
84
- *
85
- * @param array $config The task runner config
86
- * @param string $name The name of the current task (used for logging)
87
- * @param callable $action The task to run and possibly retry
88
- * @param array $arguments The task arguments
89
- * @throws Google_Task_Exception when misconfigured
90
- */
91
- public function __construct(
92
- $config,
93
- $name,
94
- $action,
95
- array $arguments = array()
96
- ) {
97
- if (isset($config['initial_delay'])) {
98
- if ($config['initial_delay'] < 0) {
99
- throw new Google_Task_Exception(
100
- 'Task configuration `initial_delay` must not be negative.'
101
- );
102
- }
103
-
104
- $this->delay = $config['initial_delay'];
105
- }
106
-
107
- if (isset($config['max_delay'])) {
108
- if ($config['max_delay'] <= 0) {
109
- throw new Google_Task_Exception(
110
- 'Task configuration `max_delay` must be greater than 0.'
111
- );
112
- }
113
-
114
- $this->maxDelay = $config['max_delay'];
115
- }
116
-
117
- if (isset($config['factor'])) {
118
- if ($config['factor'] <= 0) {
119
- throw new Google_Task_Exception(
120
- 'Task configuration `factor` must be greater than 0.'
121
- );
122
- }
123
-
124
- $this->factor = $config['factor'];
125
- }
126
-
127
- if (isset($config['jitter'])) {
128
- if ($config['jitter'] <= 0) {
129
- throw new Google_Task_Exception(
130
- 'Task configuration `jitter` must be greater than 0.'
131
- );
132
- }
133
-
134
- $this->jitter = $config['jitter'];
135
- }
136
-
137
- if (isset($config['retries'])) {
138
- if ($config['retries'] < 0) {
139
- throw new Google_Task_Exception(
140
- 'Task configuration `retries` must not be negative.'
141
- );
142
- }
143
- $this->maxAttempts += $config['retries'];
144
- }
145
-
146
- if (!is_callable($action)) {
147
- throw new Google_Task_Exception(
148
- 'Task argument `$action` must be a valid callable.'
149
- );
150
- }
151
-
152
- $this->action = $action;
153
- $this->arguments = $arguments;
154
- }
155
-
156
- /**
157
- * Checks if a retry can be attempted.
158
- *
159
- * @return boolean
160
- */
161
- public function canAttempt()
162
- {
163
- return $this->attempts < $this->maxAttempts;
164
- }
165
-
166
- /**
167
- * Runs the task and (if applicable) automatically retries when errors occur.
168
- *
169
- * @return mixed
170
- * @throws Google_Task_Retryable on failure when no retries are available.
171
- */
172
- public function run()
173
- {
174
- while ($this->attempt()) {
175
- try {
176
- return call_user_func_array($this->action, $this->arguments);
177
- } catch (Google_Service_Exception $exception) {
178
- $allowedRetries = $this->allowedRetries(
179
- $exception->getCode(),
180
- $exception->getErrors()
181
- );
182
-
183
- if (!$this->canAttempt() || !$allowedRetries) {
184
- throw $exception;
185
- }
186
-
187
- if ($allowedRetries > 0) {
188
- $this->maxAttempts = min(
189
- $this->maxAttempts,
190
- $this->attempts + $allowedRetries
191
- );
192
- }
193
- }
194
- }
195
- }
196
-
197
- /**
198
- * Runs a task once, if possible. This is useful for bypassing the `run()`
199
- * loop.
200
- *
201
- * NOTE: If this is not the first attempt, this function will sleep in
202
- * accordance to the backoff configurations before running the task.
203
- *
204
- * @return boolean
205
- */
206
- public function attempt()
207
- {
208
- if (!$this->canAttempt()) {
209
- return false;
210
- }
211
-
212
- if ($this->attempts > 0) {
213
- $this->backOff();
214
- }
215
-
216
- $this->attempts++;
217
- return true;
218
- }
219
-
220
- /**
221
- * Sleeps in accordance to the backoff configurations.
222
- */
223
- private function backOff()
224
- {
225
- $delay = $this->getDelay();
226
-
227
- usleep($delay * 1000000);
228
- }
229
-
230
- /**
231
- * Gets the delay (in seconds) for the current backoff period.
232
- *
233
- * @return float
234
- */
235
- private function getDelay()
236
- {
237
- $jitter = $this->getJitter();
238
- $factor = $this->attempts > 1 ? $this->factor + $jitter : 1 + abs($jitter);
239
-
240
- return $this->delay = min($this->maxDelay, $this->delay * $factor);
241
- }
242
-
243
- /**
244
- * Gets the current jitter (random number between -$this->jitter and
245
- * $this->jitter).
246
- *
247
- * @return float
248
- */
249
- private function getJitter()
250
- {
251
- return $this->jitter * 2 * mt_rand() / mt_getrandmax() - $this->jitter;
252
- }
253
-
254
- /**
255
- * Gets the number of times the associated task can be retried.
256
- *
257
- * NOTE: -1 is returned if the task can be retried indefinitely
258
- *
259
- * @return integer
260
- */
261
- public function allowedRetries($code, $errors = array())
262
- {
263
- if (isset($this->retryMap[$code])) {
264
- return $this->retryMap[$code];
265
- }
266
-
267
- if (
268
- !empty($errors) &&
269
- isset($errors[0]['reason'], $this->retryMap[$errors[0]['reason']])
270
- ) {
271
- return $this->retryMap[$errors[0]['reason']];
272
- }
273
-
274
- return 0;
275
- }
276
-
277
- public function setRetryMap($retryMap)
278
- {
279
- $this->retryMap = $retryMap;
280
- }
281
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/src/Google/Utils/UriTemplate.php DELETED
@@ -1,333 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2013 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- /**
19
- * Implementation of levels 1-3 of the URI Template spec.
20
- * @see http://tools.ietf.org/html/rfc6570
21
- */
22
- class Google_Utils_UriTemplate
23
- {
24
- const TYPE_MAP = "1";
25
- const TYPE_LIST = "2";
26
- const TYPE_SCALAR = "4";
27
-
28
- /**
29
- * @var $operators array
30
- * These are valid at the start of a template block to
31
- * modify the way in which the variables inside are
32
- * processed.
33
- */
34
- private $operators = array(
35
- "+" => "reserved",
36
- "/" => "segments",
37
- "." => "dotprefix",
38
- "#" => "fragment",
39
- ";" => "semicolon",
40
- "?" => "form",
41
- "&" => "continuation"
42
- );
43
-
44
- /**
45
- * @var reserved array
46
- * These are the characters which should not be URL encoded in reserved
47
- * strings.
48
- */
49
- private $reserved = array(
50
- "=", ",", "!", "@", "|", ":", "/", "?", "#",
51
- "[", "]",'$', "&", "'", "(", ")", "*", "+", ";"
52
- );
53
- private $reservedEncoded = array(
54
- "%3D", "%2C", "%21", "%40", "%7C", "%3A", "%2F", "%3F",
55
- "%23", "%5B", "%5D", "%24", "%26", "%27", "%28", "%29",
56
- "%2A", "%2B", "%3B"
57
- );
58
-
59
- public function parse($string, array $parameters)
60
- {
61
- return $this->resolveNextSection($string, $parameters);
62
- }
63
-
64
- /**
65
- * This function finds the first matching {...} block and
66
- * executes the replacement. It then calls itself to find
67
- * subsequent blocks, if any.
68
- */
69
- private function resolveNextSection($string, $parameters)
70
- {
71
- $start = strpos($string, "{");
72
- if ($start === false) {
73
- return $string;
74
- }
75
- $end = strpos($string, "}");
76
- if ($end === false) {
77
- return $string;
78
- }
79
- $string = $this->replace($string, $start, $end, $parameters);
80
- return $this->resolveNextSection($string, $parameters);
81
- }
82
-
83
- private function replace($string, $start, $end, $parameters)
84
- {
85
- // We know a data block will have {} round it, so we can strip that.
86
- $data = substr($string, $start + 1, $end - $start - 1);
87
-
88
- // If the first character is one of the reserved operators, it effects
89
- // the processing of the stream.
90
- if (isset($this->operators[$data[0]])) {
91
- $op = $this->operators[$data[0]];
92
- $data = substr($data, 1);
93
- $prefix = "";
94
- $prefix_on_missing = false;
95
-
96
- switch ($op) {
97
- case "reserved":
98
- // Reserved means certain characters should not be URL encoded
99
- $data = $this->replaceVars($data, $parameters, ",", null, true);
100
- break;
101
- case "fragment":
102
- // Comma separated with fragment prefix. Bare values only.
103
- $prefix = "#";
104
- $prefix_on_missing = true;
105
- $data = $this->replaceVars($data, $parameters, ",", null, true);
106
- break;
107
- case "segments":
108
- // Slash separated data. Bare values only.
109
- $prefix = "/";
110
- $data =$this->replaceVars($data, $parameters, "/");
111
- break;
112
- case "dotprefix":
113
- // Dot separated data. Bare values only.
114
- $prefix = ".";
115
- $prefix_on_missing = true;
116
- $data = $this->replaceVars($data, $parameters, ".");
117
- break;
118
- case "semicolon":
119
- // Semicolon prefixed and separated. Uses the key name
120
- $prefix = ";";
121
- $data = $this->replaceVars($data, $parameters, ";", "=", false, true, false);
122
- break;
123
- case "form":
124
- // Standard URL format. Uses the key name
125
- $prefix = "?";
126
- $data = $this->replaceVars($data, $parameters, "&", "=");
127
- break;
128
- case "continuation":
129
- // Standard URL, but with leading ampersand. Uses key name.
130
- $prefix = "&";
131
- $data = $this->replaceVars($data, $parameters, "&", "=");
132
- break;
133
- }
134
-
135
- // Add the initial prefix character if data is valid.
136
- if ($data || ($data !== false && $prefix_on_missing)) {
137
- $data = $prefix . $data;
138
- }
139
-
140
- } else {
141
- // If no operator we replace with the defaults.
142
- $data = $this->replaceVars($data, $parameters);
143
- }
144
- // This is chops out the {...} and replaces with the new section.
145
- return substr($string, 0, $start) . $data . substr($string, $end + 1);
146
- }
147
-
148
- private function replaceVars(
149
- $section,
150
- $parameters,
151
- $sep = ",",
152
- $combine = null,
153
- $reserved = false,
154
- $tag_empty = false,
155
- $combine_on_empty = true
156
- ) {
157
- if (strpos($section, ",") === false) {
158
- // If we only have a single value, we can immediately process.
159
- return $this->combine(
160
- $section,
161
- $parameters,
162
- $sep,
163
- $combine,
164
- $reserved,
165
- $tag_empty,
166
- $combine_on_empty
167
- );
168
- } else {
169
- // If we have multiple values, we need to split and loop over them.
170
- // Each is treated individually, then glued together with the
171
- // separator character.
172
- $vars = explode(",", $section);
173
- return $this->combineList(
174
- $vars,
175
- $sep,
176
- $parameters,
177
- $combine,
178
- $reserved,
179
- false, // Never emit empty strings in multi-param replacements
180
- $combine_on_empty
181
- );
182
- }
183
- }
184
-
185
- public function combine(
186
- $key,
187
- $parameters,
188
- $sep,
189
- $combine,
190
- $reserved,
191
- $tag_empty,
192
- $combine_on_empty
193
- ) {
194
- $length = false;
195
- $explode = false;
196
- $skip_final_combine = false;
197
- $value = false;
198
-
199
- // Check for length restriction.
200
- if (strpos($key, ":") !== false) {
201
- list($key, $length) = explode(":", $key);
202
- }
203
-
204
- // Check for explode parameter.
205
- if ($key[strlen($key) - 1] == "*") {
206
- $explode = true;
207
- $key = substr($key, 0, -1);
208
- $skip_final_combine = true;
209
- }
210
-
211
- // Define the list separator.
212
- $list_sep = $explode ? $sep : ",";
213
-
214
- if (isset($parameters[$key])) {
215
- $data_type = $this->getDataType($parameters[$key]);
216
- switch ($data_type) {
217
- case self::TYPE_SCALAR:
218
- $value = $this->getValue($parameters[$key], $length);
219
- break;
220
- case self::TYPE_LIST:
221
- $values = array();
222
- foreach ($parameters[$key] as $pkey => $pvalue) {
223
- $pvalue = $this->getValue($pvalue, $length);
224
- if ($combine && $explode) {
225
- $values[$pkey] = $key . $combine . $pvalue;
226
- } else {
227
- $values[$pkey] = $pvalue;
228
- }
229
- }
230
- $value = implode($list_sep, $values);
231
- if ($value == '') {
232
- return '';
233
- }
234
- break;
235
- case self::TYPE_MAP:
236
- $values = array();
237
- foreach ($parameters[$key] as $pkey => $pvalue) {
238
- $pvalue = $this->getValue($pvalue, $length);
239
- if ($explode) {
240
- $pkey = $this->getValue($pkey, $length);
241
- $values[] = $pkey . "=" . $pvalue; // Explode triggers = combine.
242
- } else {
243
- $values[] = $pkey;
244
- $values[] = $pvalue;
245
- }
246
- }
247
- $value = implode($list_sep, $values);
248
- if ($value == '') {
249
- return false;
250
- }
251
- break;
252
- }
253
- } else if ($tag_empty) {
254
- // If we are just indicating empty values with their key name, return that.
255
- return $key;
256
- } else {
257
- // Otherwise we can skip this variable due to not being defined.
258
- return false;
259
- }
260
-
261
- if ($reserved) {
262
- $value = str_replace($this->reservedEncoded, $this->reserved, $value);
263
- }
264
-
265
- // If we do not need to include the key name, we just return the raw
266
- // value.
267
- if (!$combine || $skip_final_combine) {
268
- return $value;
269
- }
270
-
271
- // Else we combine the key name: foo=bar, if value is not the empty string.
272
- return $key . ($value != '' || $combine_on_empty ? $combine . $value : '');
273
- }
274
-
275
- /**
276
- * Return the type of a passed in value
277
- */
278
- private function getDataType($data)
279
- {
280
- if (is_array($data)) {
281
- reset($data);
282
- if (key($data) !== 0) {
283
- return self::TYPE_MAP;
284
- }
285
- return self::TYPE_LIST;
286
- }
287
- return self::TYPE_SCALAR;
288
- }
289
-
290
- /**
291
- * Utility function that merges multiple combine calls
292
- * for multi-key templates.
293
- */
294
- private function combineList(
295
- $vars,
296
- $sep,
297
- $parameters,
298
- $combine,
299
- $reserved,
300
- $tag_empty,
301
- $combine_on_empty
302
- ) {
303
- $ret = array();
304
- foreach ($vars as $var) {
305
- $response = $this->combine(
306
- $var,
307
- $parameters,
308
- $sep,
309
- $combine,
310
- $reserved,
311
- $tag_empty,
312
- $combine_on_empty
313
- );
314
- if ($response === false) {
315
- continue;
316
- }
317
- $ret[] = $response;
318
- }
319
- return implode($sep, $ret);
320
- }
321
-
322
- /**
323
- * Utility function to encode and trim values
324
- */
325
- private function getValue($value, $length)
326
- {
327
- if ($length) {
328
- $value = substr($value, 0, $length);
329
- }
330
- $value = rawurlencode($value);
331
- return $value;
332
- }
333
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/src/Google/autoload.php DELETED
@@ -1,21 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * THIS FILE IS FOR BACKWARDS COMPATIBLITY ONLY
5
- *
6
- * If you were not already including this file in your project, please ignore it
7
- */
8
-
9
- $file = __DIR__ . '/../../vendor/autoload.php';
10
-
11
- if (!file_exists($file)) {
12
- $exception = 'This library must be installed via composer or by downloading the full package.';
13
- $exception .= ' See the instructions at https://github.com/google/google-api-php-client#installation.';
14
- throw new Exception($exception);
15
- }
16
-
17
- $error = 'google-api-php-client\'s autoloader was moved to vendor/autoload.php in 2.0.0. This ';
18
- $error .= 'redirect will be removed in 2.1. Please adjust your code to use the new location.';
19
- trigger_error($error, E_USER_DEPRECATED);
20
-
21
- require_once $file;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/autoload.php DELETED
@@ -1,7 +0,0 @@
1
- <?php
2
-
3
- // autoload.php @generated by Composer
4
-
5
- require_once __DIR__ . '/composer/autoload_real.php';
6
-
7
- return ComposerAutoloaderInit414fe7d6bd384b75fb7b7a29cfd20ec4::getLoader();
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/composer/ClassLoader.php DELETED
@@ -1,445 +0,0 @@
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
- private $classMapAuthoritative = false;
57
- private $missingClasses = array();
58
- private $apcuPrefix;
59
-
60
- public function getPrefixes()
61
- {
62
- if (!empty($this->prefixesPsr0)) {
63
- return call_user_func_array('array_merge', $this->prefixesPsr0);
64
- }
65
-
66
- return array();
67
- }
68
-
69
- public function getPrefixesPsr4()
70
- {
71
- return $this->prefixDirsPsr4;
72
- }
73
-
74
- public function getFallbackDirs()
75
- {
76
- return $this->fallbackDirsPsr0;
77
- }
78
-
79
- public function getFallbackDirsPsr4()
80
- {
81
- return $this->fallbackDirsPsr4;
82
- }
83
-
84
- public function getClassMap()
85
- {
86
- return $this->classMap;
87
- }
88
-
89
- /**
90
- * @param array $classMap Class to filename map
91
- */
92
- public function addClassMap(array $classMap)
93
- {
94
- if ($this->classMap) {
95
- $this->classMap = array_merge($this->classMap, $classMap);
96
- } else {
97
- $this->classMap = $classMap;
98
- }
99
- }
100
-
101
- /**
102
- * Registers a set of PSR-0 directories for a given prefix, either
103
- * appending or prepending to the ones previously set for this prefix.
104
- *
105
- * @param string $prefix The prefix
106
- * @param array|string $paths The PSR-0 root directories
107
- * @param bool $prepend Whether to prepend the directories
108
- */
109
- public function add($prefix, $paths, $prepend = false)
110
- {
111
- if (!$prefix) {
112
- if ($prepend) {
113
- $this->fallbackDirsPsr0 = array_merge(
114
- (array) $paths,
115
- $this->fallbackDirsPsr0
116
- );
117
- } else {
118
- $this->fallbackDirsPsr0 = array_merge(
119
- $this->fallbackDirsPsr0,
120
- (array) $paths
121
- );
122
- }
123
-
124
- return;
125
- }
126
-
127
- $first = $prefix[0];
128
- if (!isset($this->prefixesPsr0[$first][$prefix])) {
129
- $this->prefixesPsr0[$first][$prefix] = (array) $paths;
130
-
131
- return;
132
- }
133
- if ($prepend) {
134
- $this->prefixesPsr0[$first][$prefix] = array_merge(
135
- (array) $paths,
136
- $this->prefixesPsr0[$first][$prefix]
137
- );
138
- } else {
139
- $this->prefixesPsr0[$first][$prefix] = array_merge(
140
- $this->prefixesPsr0[$first][$prefix],
141
- (array) $paths
142
- );
143
- }
144
- }
145
-
146
- /**
147
- * Registers a set of PSR-4 directories for a given namespace, either
148
- * appending or prepending to the ones previously set for this namespace.
149
- *
150
- * @param string $prefix The prefix/namespace, with trailing '\\'
151
- * @param array|string $paths The PSR-4 base directories
152
- * @param bool $prepend Whether to prepend the directories
153
- *
154
- * @throws \InvalidArgumentException
155
- */
156
- public function addPsr4($prefix, $paths, $prepend = false)
157
- {
158
- if (!$prefix) {
159
- // Register directories for the root namespace.
160
- if ($prepend) {
161
- $this->fallbackDirsPsr4 = array_merge(
162
- (array) $paths,
163
- $this->fallbackDirsPsr4
164
- );
165
- } else {
166
- $this->fallbackDirsPsr4 = array_merge(
167
- $this->fallbackDirsPsr4,
168
- (array) $paths
169
- );
170
- }
171
- } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
172
- // Register directories for a new namespace.
173
- $length = strlen($prefix);
174
- if ('\\' !== $prefix[$length - 1]) {
175
- throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
176
- }
177
- $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
178
- $this->prefixDirsPsr4[$prefix] = (array) $paths;
179
- } elseif ($prepend) {
180
- // Prepend directories for an already registered namespace.
181
- $this->prefixDirsPsr4[$prefix] = array_merge(
182
- (array) $paths,
183
- $this->prefixDirsPsr4[$prefix]
184
- );
185
- } else {
186
- // Append directories for an already registered namespace.
187
- $this->prefixDirsPsr4[$prefix] = array_merge(
188
- $this->prefixDirsPsr4[$prefix],
189
- (array) $paths
190
- );
191
- }
192
- }
193
-
194
- /**
195
- * Registers a set of PSR-0 directories for a given prefix,
196
- * replacing any others previously set for this prefix.
197
- *
198
- * @param string $prefix The prefix
199
- * @param array|string $paths The PSR-0 base directories
200
- */
201
- public function set($prefix, $paths)
202
- {
203
- if (!$prefix) {
204
- $this->fallbackDirsPsr0 = (array) $paths;
205
- } else {
206
- $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
207
- }
208
- }
209
-
210
- /**
211
- * Registers a set of PSR-4 directories for a given namespace,
212
- * replacing any others previously set for this namespace.
213
- *
214
- * @param string $prefix The prefix/namespace, with trailing '\\'
215
- * @param array|string $paths The PSR-4 base directories
216
- *
217
- * @throws \InvalidArgumentException
218
- */
219
- public function setPsr4($prefix, $paths)
220
- {
221
- if (!$prefix) {
222
- $this->fallbackDirsPsr4 = (array) $paths;
223
- } else {
224
- $length = strlen($prefix);
225
- if ('\\' !== $prefix[$length - 1]) {
226
- throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
227
- }
228
- $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
229
- $this->prefixDirsPsr4[$prefix] = (array) $paths;
230
- }
231
- }
232
-
233
- /**
234
- * Turns on searching the include path for class files.
235
- *
236
- * @param bool $useIncludePath
237
- */
238
- public function setUseIncludePath($useIncludePath)
239
- {
240
- $this->useIncludePath = $useIncludePath;
241
- }
242
-
243
- /**
244
- * Can be used to check if the autoloader uses the include path to check
245
- * for classes.
246
- *
247
- * @return bool
248
- */
249
- public function getUseIncludePath()
250
- {
251
- return $this->useIncludePath;
252
- }
253
-
254
- /**
255
- * Turns off searching the prefix and fallback directories for classes
256
- * that have not been registered with the class map.
257
- *
258
- * @param bool $classMapAuthoritative
259
- */
260
- public function setClassMapAuthoritative($classMapAuthoritative)
261
- {
262
- $this->classMapAuthoritative = $classMapAuthoritative;
263
- }
264
-
265
- /**
266
- * Should class lookup fail if not found in the current class map?
267
- *
268
- * @return bool
269
- */
270
- public function isClassMapAuthoritative()
271
- {
272
- return $this->classMapAuthoritative;
273
- }
274
-
275
- /**
276
- * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
277
- *
278
- * @param string|null $apcuPrefix
279
- */
280
- public function setApcuPrefix($apcuPrefix)
281
- {
282
- $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null;
283
- }
284
-
285
- /**
286
- * The APCu prefix in use, or null if APCu caching is not enabled.
287
- *
288
- * @return string|null
289
- */
290
- public function getApcuPrefix()
291
- {
292
- return $this->apcuPrefix;
293
- }
294
-
295
- /**
296
- * Registers this instance as an autoloader.
297
- *
298
- * @param bool $prepend Whether to prepend the autoloader or not
299
- */
300
- public function register($prepend = false)
301
- {
302
- spl_autoload_register(array($this, 'loadClass'), true, $prepend);
303
- }
304
-
305
- /**
306
- * Unregisters this instance as an autoloader.
307
- */
308
- public function unregister()
309
- {
310
- spl_autoload_unregister(array($this, 'loadClass'));
311
- }
312
-
313
- /**
314
- * Loads the given class or interface.
315
- *
316
- * @param string $class The name of the class
317
- * @return bool|null True if loaded, null otherwise
318
- */
319
- public function loadClass($class)
320
- {
321
- if ($file = $this->findFile($class)) {
322
- includeFile($file);
323
-
324
- return true;
325
- }
326
- }
327
-
328
- /**
329
- * Finds the path to the file where the class is defined.
330
- *
331
- * @param string $class The name of the class
332
- *
333
- * @return string|false The path if found, false otherwise
334
- */
335
- public function findFile($class)
336
- {
337
- // class map lookup
338
- if (isset($this->classMap[$class])) {
339
- return $this->classMap[$class];
340
- }
341
- if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
342
- return false;
343
- }
344
- if (null !== $this->apcuPrefix) {
345
- $file = apcu_fetch($this->apcuPrefix.$class, $hit);
346
- if ($hit) {
347
- return $file;
348
- }
349
- }
350
-
351
- $file = $this->findFileWithExtension($class, '.php');
352
-
353
- // Search for Hack files if we are running on HHVM
354
- if (false === $file && defined('HHVM_VERSION')) {
355
- $file = $this->findFileWithExtension($class, '.hh');
356
- }
357
-
358
- if (null !== $this->apcuPrefix) {
359
- apcu_add($this->apcuPrefix.$class, $file);
360
- }
361
-
362
- if (false === $file) {
363
- // Remember that this class does not exist.
364
- $this->missingClasses[$class] = true;
365
- }
366
-
367
- return $file;
368
- }
369
-
370
- private function findFileWithExtension($class, $ext)
371
- {
372
- // PSR-4 lookup
373
- $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
374
-
375
- $first = $class[0];
376
- if (isset($this->prefixLengthsPsr4[$first])) {
377
- $subPath = $class;
378
- while (false !== $lastPos = strrpos($subPath, '\\')) {
379
- $subPath = substr($subPath, 0, $lastPos);
380
- $search = $subPath.'\\';
381
- if (isset($this->prefixDirsPsr4[$search])) {
382
- foreach ($this->prefixDirsPsr4[$search] as $dir) {
383
- $length = $this->prefixLengthsPsr4[$first][$search];
384
- if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
385
- return $file;
386
- }
387
- }
388
- }
389
- }
390
- }
391
-
392
- // PSR-4 fallback dirs
393
- foreach ($this->fallbackDirsPsr4 as $dir) {
394
- if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
395
- return $file;
396
- }
397
- }
398
-
399
- // PSR-0 lookup
400
- if (false !== $pos = strrpos($class, '\\')) {
401
- // namespaced class name
402
- $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
403
- . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
404
- } else {
405
- // PEAR-like class name
406
- $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
407
- }
408
-
409
- if (isset($this->prefixesPsr0[$first])) {
410
- foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
411
- if (0 === strpos($class, $prefix)) {
412
- foreach ($dirs as $dir) {
413
- if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
414
- return $file;
415
- }
416
- }
417
- }
418
- }
419
- }
420
-
421
- // PSR-0 fallback dirs
422
- foreach ($this->fallbackDirsPsr0 as $dir) {
423
- if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
424
- return $file;
425
- }
426
- }
427
-
428
- // PSR-0 include paths.
429
- if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
430
- return $file;
431
- }
432
-
433
- return false;
434
- }
435
- }
436
-
437
- /**
438
- * Scope isolated include.
439
- *
440
- * Prevents access to $this/self from included files.
441
- */
442
- function includeFile($file)
443
- {
444
- include $file;
445
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/composer/LICENSE DELETED
@@ -1,21 +0,0 @@
1
-
2
- Copyright (c) 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
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/composer/autoload_classmap.php DELETED
@@ -1,39 +0,0 @@
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
- 'BeforeValidException' => $vendorDir . '/firebase/php-jwt/Firebase/PHP-JWT/Exceptions/BeforeValidException.php',
10
- 'ExpiredException' => $vendorDir . '/firebase/php-jwt/Firebase/PHP-JWT/Exceptions/ExpiredException.php',
11
- 'Google\\Auth\\ApplicationDefaultCredentials' => $vendorDir . '/google/auth/src/ApplicationDefaultCredentials.php',
12
- 'Google\\Auth\\CacheTrait' => $vendorDir . '/google/auth/src/CacheTrait.php',
13
- 'Google\\Auth\\Cache\\InvalidArgumentException' => $vendorDir . '/google/auth/src/Cache/InvalidArgumentException.php',
14
- 'Google\\Auth\\Cache\\Item' => $vendorDir . '/google/auth/src/Cache/Item.php',
15
- 'Google\\Auth\\Cache\\MemoryCacheItemPool' => $vendorDir . '/google/auth/src/Cache/MemoryCacheItemPool.php',
16
- 'Google\\Auth\\CredentialsLoader' => $vendorDir . '/google/auth/src/CredentialsLoader.php',
17
- 'Google\\Auth\\Credentials\\AppIdentityCredentials' => $vendorDir . '/google/auth/src/Credentials/AppIdentityCredentials.php',
18
- 'Google\\Auth\\Credentials\\GCECredentials' => $vendorDir . '/google/auth/src/Credentials/GCECredentials.php',
19
- 'Google\\Auth\\Credentials\\IAMCredentials' => $vendorDir . '/google/auth/src/Credentials/IAMCredentials.php',
20
- 'Google\\Auth\\Credentials\\ServiceAccountCredentials' => $vendorDir . '/google/auth/src/Credentials/ServiceAccountCredentials.php',
21
- 'Google\\Auth\\Credentials\\ServiceAccountJwtAccessCredentials' => $vendorDir . '/google/auth/src/Credentials/ServiceAccountJwtAccessCredentials.php',
22
- 'Google\\Auth\\Credentials\\UserRefreshCredentials' => $vendorDir . '/google/auth/src/Credentials/UserRefreshCredentials.php',
23
- 'Google\\Auth\\FetchAuthTokenCache' => $vendorDir . '/google/auth/src/FetchAuthTokenCache.php',
24
- 'Google\\Auth\\FetchAuthTokenInterface' => $vendorDir . '/google/auth/src/FetchAuthTokenInterface.php',
25
- 'Google\\Auth\\HttpHandler\\Guzzle5HttpHandler' => $vendorDir . '/google/auth/src/HttpHandler/Guzzle5HttpHandler.php',
26
- 'Google\\Auth\\HttpHandler\\Guzzle6HttpHandler' => $vendorDir . '/google/auth/src/HttpHandler/Guzzle6HttpHandler.php',
27
- 'Google\\Auth\\HttpHandler\\HttpHandlerFactory' => $vendorDir . '/google/auth/src/HttpHandler/HttpHandlerFactory.php',
28
- 'Google\\Auth\\Middleware\\AuthTokenMiddleware' => $vendorDir . '/google/auth/src/Middleware/AuthTokenMiddleware.php',
29
- 'Google\\Auth\\Middleware\\ScopedAccessTokenMiddleware' => $vendorDir . '/google/auth/src/Middleware/ScopedAccessTokenMiddleware.php',
30
- 'Google\\Auth\\Middleware\\SimpleMiddleware' => $vendorDir . '/google/auth/src/Middleware/SimpleMiddleware.php',
31
- 'Google\\Auth\\OAuth2' => $vendorDir . '/google/auth/src/OAuth2.php',
32
- 'Google\\Auth\\Subscriber\\AuthTokenSubscriber' => $vendorDir . '/google/auth/src/Subscriber/AuthTokenSubscriber.php',
33
- 'Google\\Auth\\Subscriber\\ScopedAccessTokenSubscriber' => $vendorDir . '/google/auth/src/Subscriber/ScopedAccessTokenSubscriber.php',
34
- 'Google\\Auth\\Subscriber\\SimpleSubscriber' => $vendorDir . '/google/auth/src/Subscriber/SimpleSubscriber.php',
35
- 'Google_Service_Exception' => $baseDir . '/src/Google/Service/Exception.php',
36
- 'Google_Service_Resource' => $baseDir . '/src/Google/Service/Resource.php',
37
- 'JWT' => $vendorDir . '/firebase/php-jwt/Firebase/PHP-JWT/Authentication/JWT.php',
38
- 'SignatureInvalidException' => $vendorDir . '/firebase/php-jwt/Firebase/PHP-JWT/Exceptions/SignatureInvalidException.php',
39
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/composer/autoload_files.php DELETED
@@ -1,12 +0,0 @@
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
- 'e7ef766f7bcc15ba09cd6308370a95d7' => $vendorDir . '/react/promise/src/React/Promise/functions.php',
10
- 'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php',
11
- '3919eeb97e98d4648304477f8ef734ba' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Random.php',
12
- );
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/composer/autoload_namespaces.php DELETED
@@ -1,18 +0,0 @@
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
- 'System' => array($vendorDir . '/phpseclib/phpseclib/phpseclib'),
10
- 'React\\Promise' => array($vendorDir . '/react/promise/src'),
11
- 'Psr\\Log\\' => array($vendorDir . '/psr/log'),
12
- 'Net' => array($vendorDir . '/phpseclib/phpseclib/phpseclib'),
13
- 'Math' => array($vendorDir . '/phpseclib/phpseclib/phpseclib'),
14
- 'Google_Service_' => array($vendorDir . '/google/apiclient-services/src'),
15
- 'Google_' => array($baseDir . '/src'),
16
- 'File' => array($vendorDir . '/phpseclib/phpseclib/phpseclib'),
17
- 'Crypt' => array($vendorDir . '/phpseclib/phpseclib/phpseclib'),
18
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/composer/autoload_psr4.php DELETED
@@ -1,17 +0,0 @@
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
- 'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src'),
10
- 'Psr\\Cache\\' => array($vendorDir . '/psr/cache/src'),
11
- 'Monolog\\' => array($vendorDir . '/monolog/monolog/src/Monolog'),
12
- 'GuzzleHttp\\Stream\\' => array($vendorDir . '/guzzlehttp/streams/src'),
13
- 'GuzzleHttp\\Ring\\' => array($vendorDir . '/guzzlehttp/ringphp/src'),
14
- 'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'),
15
- 'GuzzleHttp\\' => array($vendorDir . '/guzzlehttp/guzzle/src'),
16
- 'Google\\Auth\\' => array($vendorDir . '/google/auth/src'),
17
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/composer/autoload_real.php DELETED
@@ -1,74 +0,0 @@
1
- <?php
2
-
3
- // autoload_real.php @generated by Composer
4
-
5
- class ComposerAutoloaderInit414fe7d6bd384b75fb7b7a29cfd20ec4
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('ComposerAutoloaderInit414fe7d6bd384b75fb7b7a29cfd20ec4', 'loadClassLoader'), true, true);
23
- self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInit414fe7d6bd384b75fb7b7a29cfd20ec4', 'loadClassLoader'));
25
-
26
- $includePaths = require __DIR__ . '/include_paths.php';
27
- array_push($includePaths, get_include_path());
28
- set_include_path(implode(PATH_SEPARATOR, $includePaths));
29
-
30
- $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
31
- if ($useStaticLoader) {
32
- require_once __DIR__ . '/autoload_static.php';
33
-
34
- call_user_func(\Composer\Autoload\ComposerStaticInit414fe7d6bd384b75fb7b7a29cfd20ec4::getInitializer($loader));
35
- } else {
36
- $map = require __DIR__ . '/autoload_namespaces.php';
37
- foreach ($map as $namespace => $path) {
38
- $loader->set($namespace, $path);
39
- }
40
-
41
- $map = require __DIR__ . '/autoload_psr4.php';
42
- foreach ($map as $namespace => $path) {
43
- $loader->setPsr4($namespace, $path);
44
- }
45
-
46
- $classMap = require __DIR__ . '/autoload_classmap.php';
47
- if ($classMap) {
48
- $loader->addClassMap($classMap);
49
- }
50
- }
51
-
52
- $loader->register(true);
53
-
54
- if ($useStaticLoader) {
55
- $includeFiles = Composer\Autoload\ComposerStaticInit414fe7d6bd384b75fb7b7a29cfd20ec4::$files;
56
- } else {
57
- $includeFiles = require __DIR__ . '/autoload_files.php';
58
- }
59
- foreach ($includeFiles as $fileIdentifier => $file) {
60
- composerRequire414fe7d6bd384b75fb7b7a29cfd20ec4($fileIdentifier, $file);
61
- }
62
-
63
- return $loader;
64
- }
65
- }
66
-
67
- function composerRequire414fe7d6bd384b75fb7b7a29cfd20ec4($fileIdentifier, $file)
68
- {
69
- if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
70
- require $file;
71
-
72
- $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
73
- }
74
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/composer/autoload_static.php DELETED
@@ -1,176 +0,0 @@
1
- <?php
2
-
3
- // autoload_static.php @generated by Composer
4
-
5
- namespace Composer\Autoload;
6
-
7
- class ComposerStaticInit414fe7d6bd384b75fb7b7a29cfd20ec4
8
- {
9
- public static $files = array (
10
- 'e7ef766f7bcc15ba09cd6308370a95d7' => __DIR__ . '/..' . '/react/promise/src/React/Promise/functions.php',
11
- 'a0edc8309cc5e1d60e3047b5df6b7052' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php',
12
- '3919eeb97e98d4648304477f8ef734ba' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/Random.php',
13
- );
14
-
15
- public static $prefixLengthsPsr4 = array (
16
- 'P' =>
17
- array (
18
- 'Psr\\Http\\Message\\' => 17,
19
- 'Psr\\Cache\\' => 10,
20
- ),
21
- 'M' =>
22
- array (
23
- 'Monolog\\' => 8,
24
- ),
25
- 'G' =>
26
- array (
27
- 'GuzzleHttp\\Stream\\' => 18,
28
- 'GuzzleHttp\\Ring\\' => 16,
29
- 'GuzzleHttp\\Psr7\\' => 16,
30
- 'GuzzleHttp\\' => 11,
31
- 'Google\\Auth\\' => 12,
32
- ),
33
- );
34
-
35
- public static $prefixDirsPsr4 = array (
36
- 'Psr\\Http\\Message\\' =>
37
- array (
38
- 0 => __DIR__ . '/..' . '/psr/http-message/src',
39
- ),
40
- 'Psr\\Cache\\' =>
41
- array (
42
- 0 => __DIR__ . '/..' . '/psr/cache/src',
43
- ),
44
- 'Monolog\\' =>
45
- array (
46
- 0 => __DIR__ . '/..' . '/monolog/monolog/src/Monolog',
47
- ),
48
- 'GuzzleHttp\\Stream\\' =>
49
- array (
50
- 0 => __DIR__ . '/..' . '/guzzlehttp/streams/src',
51
- ),
52
- 'GuzzleHttp\\Ring\\' =>
53
- array (
54
- 0 => __DIR__ . '/..' . '/guzzlehttp/ringphp/src',
55
- ),
56
- 'GuzzleHttp\\Psr7\\' =>
57
- array (
58
- 0 => __DIR__ . '/..' . '/guzzlehttp/psr7/src',
59
- ),
60
- 'GuzzleHttp\\' =>
61
- array (
62
- 0 => __DIR__ . '/..' . '/guzzlehttp/guzzle/src',
63
- ),
64
- 'Google\\Auth\\' =>
65
- array (
66
- 0 => __DIR__ . '/..' . '/google/auth/src',
67
- ),
68
- );
69
-
70
- public static $prefixesPsr0 = array (
71
- 'S' =>
72
- array (
73
- 'System' =>
74
- array (
75
- 0 => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib',
76
- ),
77
- ),
78
- 'R' =>
79
- array (
80
- 'React\\Promise' =>
81
- array (
82
- 0 => __DIR__ . '/..' . '/react/promise/src',
83
- ),
84
- ),
85
- 'P' =>
86
- array (
87
- 'Psr\\Log\\' =>
88
- array (
89
- 0 => __DIR__ . '/..' . '/psr/log',
90
- ),
91
- ),
92
- 'N' =>
93
- array (
94
- 'Net' =>
95
- array (
96
- 0 => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib',
97
- ),
98
- ),
99
- 'M' =>
100
- array (
101
- 'Math' =>
102
- array (
103
- 0 => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib',
104
- ),
105
- ),
106
- 'G' =>
107
- array (
108
- 'Google_Service_' =>
109
- array (
110
- 0 => __DIR__ . '/..' . '/google/apiclient-services/src',
111
- ),
112
- 'Google_' =>
113
- array (
114
- 0 => __DIR__ . '/../..' . '/src',
115
- ),
116
- ),
117
- 'F' =>
118
- array (
119
- 'File' =>
120
- array (
121
- 0 => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib',
122
- ),
123
- ),
124
- 'C' =>
125
- array (
126
- 'Crypt' =>
127
- array (
128
- 0 => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib',
129
- ),
130
- ),
131
- );
132
-
133
- public static $classMap = array (
134
- 'BeforeValidException' => __DIR__ . '/..' . '/firebase/php-jwt/Firebase/PHP-JWT/Exceptions/BeforeValidException.php',
135
- 'ExpiredException' => __DIR__ . '/..' . '/firebase/php-jwt/Firebase/PHP-JWT/Exceptions/ExpiredException.php',
136
- 'Google\\Auth\\ApplicationDefaultCredentials' => __DIR__ . '/..' . '/google/auth/src/ApplicationDefaultCredentials.php',
137
- 'Google\\Auth\\CacheTrait' => __DIR__ . '/..' . '/google/auth/src/CacheTrait.php',
138
- 'Google\\Auth\\Cache\\InvalidArgumentException' => __DIR__ . '/..' . '/google/auth/src/Cache/InvalidArgumentException.php',
139
- 'Google\\Auth\\Cache\\Item' => __DIR__ . '/..' . '/google/auth/src/Cache/Item.php',
140
- 'Google\\Auth\\Cache\\MemoryCacheItemPool' => __DIR__ . '/..' . '/google/auth/src/Cache/MemoryCacheItemPool.php',
141
- 'Google\\Auth\\CredentialsLoader' => __DIR__ . '/..' . '/google/auth/src/CredentialsLoader.php',
142
- 'Google\\Auth\\Credentials\\AppIdentityCredentials' => __DIR__ . '/..' . '/google/auth/src/Credentials/AppIdentityCredentials.php',
143
- 'Google\\Auth\\Credentials\\GCECredentials' => __DIR__ . '/..' . '/google/auth/src/Credentials/GCECredentials.php',
144
- 'Google\\Auth\\Credentials\\IAMCredentials' => __DIR__ . '/..' . '/google/auth/src/Credentials/IAMCredentials.php',
145
- 'Google\\Auth\\Credentials\\ServiceAccountCredentials' => __DIR__ . '/..' . '/google/auth/src/Credentials/ServiceAccountCredentials.php',
146
- 'Google\\Auth\\Credentials\\ServiceAccountJwtAccessCredentials' => __DIR__ . '/..' . '/google/auth/src/Credentials/ServiceAccountJwtAccessCredentials.php',
147
- 'Google\\Auth\\Credentials\\UserRefreshCredentials' => __DIR__ . '/..' . '/google/auth/src/Credentials/UserRefreshCredentials.php',
148
- 'Google\\Auth\\FetchAuthTokenCache' => __DIR__ . '/..' . '/google/auth/src/FetchAuthTokenCache.php',
149
- 'Google\\Auth\\FetchAuthTokenInterface' => __DIR__ . '/..' . '/google/auth/src/FetchAuthTokenInterface.php',
150
- 'Google\\Auth\\HttpHandler\\Guzzle5HttpHandler' => __DIR__ . '/..' . '/google/auth/src/HttpHandler/Guzzle5HttpHandler.php',
151
- 'Google\\Auth\\HttpHandler\\Guzzle6HttpHandler' => __DIR__ . '/..' . '/google/auth/src/HttpHandler/Guzzle6HttpHandler.php',
152
- 'Google\\Auth\\HttpHandler\\HttpHandlerFactory' => __DIR__ . '/..' . '/google/auth/src/HttpHandler/HttpHandlerFactory.php',
153
- 'Google\\Auth\\Middleware\\AuthTokenMiddleware' => __DIR__ . '/..' . '/google/auth/src/Middleware/AuthTokenMiddleware.php',
154
- 'Google\\Auth\\Middleware\\ScopedAccessTokenMiddleware' => __DIR__ . '/..' . '/google/auth/src/Middleware/ScopedAccessTokenMiddleware.php',
155
- 'Google\\Auth\\Middleware\\SimpleMiddleware' => __DIR__ . '/..' . '/google/auth/src/Middleware/SimpleMiddleware.php',
156
- 'Google\\Auth\\OAuth2' => __DIR__ . '/..' . '/google/auth/src/OAuth2.php',
157
- 'Google\\Auth\\Subscriber\\AuthTokenSubscriber' => __DIR__ . '/..' . '/google/auth/src/Subscriber/AuthTokenSubscriber.php',
158
- 'Google\\Auth\\Subscriber\\ScopedAccessTokenSubscriber' => __DIR__ . '/..' . '/google/auth/src/Subscriber/ScopedAccessTokenSubscriber.php',
159
- 'Google\\Auth\\Subscriber\\SimpleSubscriber' => __DIR__ . '/..' . '/google/auth/src/Subscriber/SimpleSubscriber.php',
160
- 'Google_Service_Exception' => __DIR__ . '/../..' . '/src/Google/Service/Exception.php',
161
- 'Google_Service_Resource' => __DIR__ . '/../..' . '/src/Google/Service/Resource.php',
162
- 'JWT' => __DIR__ . '/..' . '/firebase/php-jwt/Firebase/PHP-JWT/Authentication/JWT.php',
163
- 'SignatureInvalidException' => __DIR__ . '/..' . '/firebase/php-jwt/Firebase/PHP-JWT/Exceptions/SignatureInvalidException.php',
164
- );
165
-
166
- public static function getInitializer(ClassLoader $loader)
167
- {
168
- return \Closure::bind(function () use ($loader) {
169
- $loader->prefixLengthsPsr4 = ComposerStaticInit414fe7d6bd384b75fb7b7a29cfd20ec4::$prefixLengthsPsr4;
170
- $loader->prefixDirsPsr4 = ComposerStaticInit414fe7d6bd384b75fb7b7a29cfd20ec4::$prefixDirsPsr4;
171
- $loader->prefixesPsr0 = ComposerStaticInit414fe7d6bd384b75fb7b7a29cfd20ec4::$prefixesPsr0;
172
- $loader->classMap = ComposerStaticInit414fe7d6bd384b75fb7b7a29cfd20ec4::$classMap;
173
-
174
- }, null, ClassLoader::class);
175
- }
176
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/composer/include_paths.php DELETED
@@ -1,10 +0,0 @@
1
- <?php
2
-
3
- // include_paths.php @generated by Composer
4
-
5
- $vendorDir = dirname(dirname(__FILE__));
6
- $baseDir = dirname($vendorDir);
7
-
8
- return array(
9
- $vendorDir . '/phpseclib/phpseclib/phpseclib',
10
- );
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/composer/installed.json DELETED
@@ -1,720 +0,0 @@
1
- [
2
- {
3
- "name": "google/auth",
4
- "version": "v1.0",
5
- "version_normalized": "1.0.0.0",
6
- "source": {
7
- "type": "git",
8
- "url": "https://github.com/google/google-auth-library-php.git",
9
- "reference": "db77bd2de0bcc40bf50ebe851e9eed332aeaa4df"
10
- },
11
- "dist": {
12
- "type": "zip",
13
- "url": "https://api.github.com/repos/google/google-auth-library-php/zipball/db77bd2de0bcc40bf50ebe851e9eed332aeaa4df",
14
- "reference": "db77bd2de0bcc40bf50ebe851e9eed332aeaa4df",
15
- "shasum": ""
16
- },
17
- "require": {
18
- "firebase/php-jwt": "~2.0|~3.0|~4.0",
19
- "guzzlehttp/guzzle": "~5.3.1|~6.0",
20
- "guzzlehttp/psr7": "~1.2",
21
- "php": ">=5.4",
22
- "psr/cache": "^1.0",
23
- "psr/http-message": "^1.0"
24
- },
25
- "require-dev": {
26
- "friendsofphp/php-cs-fixer": "^1.11",
27
- "phpunit/phpunit": "3.7.*"
28
- },
29
- "time": "2017-06-13T18:00:07+00:00",
30
- "type": "library",
31
- "installation-source": "dist",
32
- "autoload": {
33
- "classmap": [
34
- "src/"
35
- ],
36
- "psr-4": {
37
- "Google\\Auth\\": "src"
38
- }
39
- },
40
- "notification-url": "https://packagist.org/downloads/",
41
- "license": [
42
- "Apache-2.0"
43
- ],
44
- "description": "Google Auth Library for PHP",
45
- "homepage": "http://github.com/google/google-auth-library-php",
46
- "keywords": [
47
- "Authentication",
48
- "google",
49
- "oauth2"
50
- ]
51
- },
52
- {
53
- "name": "google/apiclient-services",
54
- "version": "v0.13",
55
- "version_normalized": "0.13.0.0",
56
- "source": {
57
- "type": "git",
58
- "url": "https://github.com/google/google-api-php-client-services.git",
59
- "reference": "0805897f3435f9eea73ce21da9d55f51c69c1171"
60
- },
61
- "dist": {
62
- "type": "zip",
63
- "url": "https://api.github.com/repos/google/google-api-php-client-services/zipball/0805897f3435f9eea73ce21da9d55f51c69c1171",
64
- "reference": "0805897f3435f9eea73ce21da9d55f51c69c1171",
65
- "shasum": ""
66
- },
67
- "require": {
68
- "php": ">=5.4"
69
- },
70
- "require-dev": {
71
- "phpunit/phpunit": "~4.8"
72
- },
73
- "time": "2017-07-07T16:01:27+00:00",
74
- "type": "library",
75
- "installation-source": "dist",
76
- "autoload": {
77
- "psr-0": {
78
- "Google_Service_": "src"
79
- }
80
- },
81
- "notification-url": "https://packagist.org/downloads/",
82
- "license": [
83
- "Apache-2.0"
84
- ],
85
- "description": "Client library for Google APIs",
86
- "homepage": "http://developers.google.com/api-client-library/php",
87
- "keywords": [
88
- "google"
89
- ]
90
- },
91
- {
92
- "name": "firebase/php-jwt",
93
- "version": "2.0.0",
94
- "version_normalized": "2.0.0.0",
95
- "target-dir": "Firebase/PHP-JWT",
96
- "source": {
97
- "type": "git",
98
- "url": "https://github.com/firebase/php-jwt.git",
99
- "reference": "ffcfd888ce1e4f2d70cac2dc9b7301038332fe57"
100
- },
101
- "dist": {
102
- "type": "zip",
103
- "url": "https://api.github.com/repos/firebase/php-jwt/zipball/ffcfd888ce1e4f2d70cac2dc9b7301038332fe57",
104
- "reference": "ffcfd888ce1e4f2d70cac2dc9b7301038332fe57",
105
- "shasum": ""
106
- },
107
- "require": {
108
- "php": ">=5.2.0"
109
- },
110
- "time": "2015-04-01T18:46:38+00:00",
111
- "type": "library",
112
- "installation-source": "dist",
113
- "autoload": {
114
- "classmap": [
115
- "Authentication/",
116
- "Exceptions/"
117
- ]
118
- },
119
- "notification-url": "https://packagist.org/downloads/",
120
- "license": [
121
- "BSD-3-Clause"
122
- ],
123
- "authors": [
124
- {
125
- "name": "Neuman Vong",
126
- "email": "neuman+pear@twilio.com",
127
- "role": "Developer"
128
- },
129
- {
130
- "name": "Anant Narayanan",
131
- "email": "anant@php.net",
132
- "role": "Developer"
133
- }
134
- ],
135
- "description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.",
136
- "homepage": "https://github.com/firebase/php-jwt"
137
- },
138
- {
139
- "name": "psr/log",
140
- "version": "1.0.0",
141
- "version_normalized": "1.0.0.0",
142
- "source": {
143
- "type": "git",
144
- "url": "https://github.com/php-fig/log.git",
145
- "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b"
146
- },
147
- "dist": {
148
- "type": "zip",
149
- "url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b",
150
- "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b",
151
- "shasum": ""
152
- },
153
- "time": "2012-12-21T11:40:51+00:00",
154
- "type": "library",
155
- "installation-source": "dist",
156
- "autoload": {
157
- "psr-0": {
158
- "Psr\\Log\\": ""
159
- }
160
- },
161
- "notification-url": "https://packagist.org/downloads/",
162
- "license": [
163
- "MIT"
164
- ],
165
- "authors": [
166
- {
167
- "name": "PHP-FIG",
168
- "homepage": "http://www.php-fig.org/"
169
- }
170
- ],
171
- "description": "Common interface for logging libraries",
172
- "keywords": [
173
- "log",
174
- "psr",
175
- "psr-3"
176
- ]
177
- },
178
- {
179
- "name": "monolog/monolog",
180
- "version": "1.17.0",
181
- "version_normalized": "1.17.0.0",
182
- "source": {
183
- "type": "git",
184
- "url": "https://github.com/Seldaek/monolog.git",
185
- "reference": "877ae631713cc961952df713ae785735b90df682"
186
- },
187
- "dist": {
188
- "type": "zip",
189
- "url": "https://api.github.com/repos/Seldaek/monolog/zipball/877ae631713cc961952df713ae785735b90df682",
190
- "reference": "877ae631713cc961952df713ae785735b90df682",
191
- "shasum": ""
192
- },
193
- "require": {
194
- "php": ">=5.3.0",
195
- "psr/log": "~1.0"
196
- },
197
- "provide": {
198
- "psr/log-implementation": "1.0.0"
199
- },
200
- "require-dev": {
201
- "aws/aws-sdk-php": "^2.4.9",
202
- "doctrine/couchdb": "~1.0@dev",
203
- "graylog2/gelf-php": "~1.0",
204
- "php-console/php-console": "^3.1.3",
205
- "phpunit/phpunit": "~4.5",
206
- "phpunit/phpunit-mock-objects": "2.3.0",
207
- "raven/raven": "~0.11",
208
- "ruflin/elastica": ">=0.90 <3.0",
209
- "swiftmailer/swiftmailer": "~5.3",
210
- "videlalvaro/php-amqplib": "~2.4"
211
- },
212
- "suggest": {
213
- "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB",
214
- "doctrine/couchdb": "Allow sending log messages to a CouchDB server",
215
- "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)",
216
- "ext-mongo": "Allow sending log messages to a MongoDB server",
217
- "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
218
- "php-console/php-console": "Allow sending log messages to Google Chrome",
219
- "raven/raven": "Allow sending log messages to a Sentry server",
220
- "rollbar/rollbar": "Allow sending log messages to Rollbar",
221
- "ruflin/elastica": "Allow sending log messages to an Elastic Search server",
222
- "videlalvaro/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib"
223
- },
224
- "time": "2015-08-30T11:40:25+00:00",
225
- "type": "library",
226
- "extra": {
227
- "branch-alias": {
228
- "dev-master": "1.16.x-dev"
229
- }
230
- },
231
- "installation-source": "dist",
232
- "autoload": {
233
- "psr-4": {
234
- "Monolog\\": "src/Monolog"
235
- }
236
- },
237
- "notification-url": "https://packagist.org/downloads/",
238
- "license": [
239
- "MIT"
240
- ],
241
- "authors": [
242
- {
243
- "name": "Jordi Boggiano",
244
- "email": "j.boggiano@seld.be",
245
- "homepage": "http://seld.be"
246
- }
247
- ],
248
- "description": "Sends your logs to files, sockets, inboxes, databases and various web services",
249
- "homepage": "http://github.com/Seldaek/monolog",
250
- "keywords": [
251
- "log",
252
- "logging",
253
- "psr-3"
254
- ]
255
- },
256
- {
257
- "name": "phpseclib/phpseclib",
258
- "version": "0.3.10",
259
- "version_normalized": "0.3.10.0",
260
- "source": {
261
- "type": "git",
262
- "url": "https://github.com/phpseclib/phpseclib.git",
263
- "reference": "d15bba1edcc7c89e09cc74c5d961317a8b947bf4"
264
- },
265
- "dist": {
266
- "type": "zip",
267
- "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/d15bba1edcc7c89e09cc74c5d961317a8b947bf4",
268
- "reference": "d15bba1edcc7c89e09cc74c5d961317a8b947bf4",
269
- "shasum": ""
270
- },
271
- "require": {
272
- "php": ">=5.0.0"
273
- },
274
- "require-dev": {
275
- "phing/phing": "~2.7",
276
- "phpunit/phpunit": "~4.0",
277
- "sami/sami": "~2.0",
278
- "squizlabs/php_codesniffer": "~1.5"
279
- },
280
- "suggest": {
281
- "ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.",
282
- "ext-mcrypt": "Install the Mcrypt extension in order to speed up a wide variety of cryptographic operations.",
283
- "pear-pear/PHP_Compat": "Install PHP_Compat to get phpseclib working on PHP < 4.3.3."
284
- },
285
- "time": "2015-01-28T21:50:33+00:00",
286
- "type": "library",
287
- "extra": {
288
- "branch-alias": {
289
- "dev-master": "0.3-dev"
290
- }
291
- },
292
- "installation-source": "dist",
293
- "autoload": {
294
- "psr-0": {
295
- "Crypt": "phpseclib/",
296
- "File": "phpseclib/",
297
- "Math": "phpseclib/",
298
- "Net": "phpseclib/",
299
- "System": "phpseclib/"
300
- },
301
- "files": [
302
- "phpseclib/Crypt/Random.php"
303
- ]
304
- },
305
- "notification-url": "https://packagist.org/downloads/",
306
- "include-path": [
307
- "phpseclib/"
308
- ],
309
- "license": [
310
- "MIT"
311
- ],
312
- "authors": [
313
- {
314
- "name": "Jim Wigginton",
315
- "email": "terrafrost@php.net",
316
- "role": "Lead Developer"
317
- },
318
- {
319
- "name": "Patrick Monnerat",
320
- "email": "pm@datasphere.ch",
321
- "role": "Developer"
322
- },
323
- {
324
- "name": "Andreas Fischer",
325
- "email": "bantu@phpbb.com",
326
- "role": "Developer"
327
- },
328
- {
329
- "name": "Hans-Jürgen Petrich",
330
- "email": "petrich@tronic-media.com",
331
- "role": "Developer"
332
- }
333
- ],
334
- "description": "PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.",
335
- "homepage": "http://phpseclib.sourceforge.net",
336
- "keywords": [
337
- "BigInteger",
338
- "aes",
339
- "asn.1",
340
- "asn1",
341
- "blowfish",
342
- "crypto",
343
- "cryptography",
344
- "encryption",
345
- "rsa",
346
- "security",
347
- "sftp",
348
- "signature",
349
- "signing",
350
- "ssh",
351
- "twofish",
352
- "x.509",
353
- "x509"
354
- ]
355
- },
356
- {
357
- "name": "react/promise",
358
- "version": "v2.0.0",
359
- "version_normalized": "2.0.0.0",
360
- "source": {
361
- "type": "git",
362
- "url": "https://github.com/reactphp/promise.git",
363
- "reference": "58129a9cb9da88f2055309a805e2696b06928bb0"
364
- },
365
- "dist": {
366
- "type": "zip",
367
- "url": "https://api.github.com/repos/reactphp/promise/zipball/58129a9cb9da88f2055309a805e2696b06928bb0",
368
- "reference": "58129a9cb9da88f2055309a805e2696b06928bb0",
369
- "shasum": ""
370
- },
371
- "require": {
372
- "php": ">=5.4.0"
373
- },
374
- "time": "2013-12-10T15:40:36+00:00",
375
- "type": "library",
376
- "extra": {
377
- "branch-alias": {
378
- "dev-master": "2.0-dev"
379
- }
380
- },
381
- "installation-source": "dist",
382
- "autoload": {
383
- "psr-0": {
384
- "React\\Promise": "src/"
385
- },
386
- "files": [
387
- "src/React/Promise/functions.php"
388
- ]
389
- },
390
- "notification-url": "https://packagist.org/downloads/",
391
- "license": [
392
- "MIT"
393
- ],
394
- "authors": [
395
- {
396
- "name": "Jan Sorgalla",
397
- "email": "jsorgalla@googlemail.com"
398
- }
399
- ],
400
- "description": "A lightweight implementation of CommonJS Promises/A for PHP"
401
- },
402
- {
403
- "name": "guzzlehttp/streams",
404
- "version": "3.0.0",
405
- "version_normalized": "3.0.0.0",
406
- "source": {
407
- "type": "git",
408
- "url": "https://github.com/guzzle/streams.git",
409
- "reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5"
410
- },
411
- "dist": {
412
- "type": "zip",
413
- "url": "https://api.github.com/repos/guzzle/streams/zipball/47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5",
414
- "reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5",
415
- "shasum": ""
416
- },
417
- "require": {
418
- "php": ">=5.4.0"
419
- },
420
- "require-dev": {
421
- "phpunit/phpunit": "~4.0"
422
- },
423
- "time": "2014-10-12T19:18:40+00:00",
424
- "type": "library",
425
- "extra": {
426
- "branch-alias": {
427
- "dev-master": "3.0-dev"
428
- }
429
- },
430
- "installation-source": "dist",
431
- "autoload": {
432
- "psr-4": {
433
- "GuzzleHttp\\Stream\\": "src/"
434
- }
435
- },
436
- "notification-url": "https://packagist.org/downloads/",
437
- "license": [
438
- "MIT"
439
- ],
440
- "authors": [
441
- {
442
- "name": "Michael Dowling",
443
- "email": "mtdowling@gmail.com",
444
- "homepage": "https://github.com/mtdowling"
445
- }
446
- ],
447
- "description": "Provides a simple abstraction over streams of data",
448
- "homepage": "http://guzzlephp.org/",
449
- "keywords": [
450
- "Guzzle",
451
- "stream"
452
- ]
453
- },
454
- {
455
- "name": "guzzlehttp/ringphp",
456
- "version": "1.1.0",
457
- "version_normalized": "1.1.0.0",
458
- "source": {
459
- "type": "git",
460
- "url": "https://github.com/guzzle/RingPHP.git",
461
- "reference": "dbbb91d7f6c191e5e405e900e3102ac7f261bc0b"
462
- },
463
- "dist": {
464
- "type": "zip",
465
- "url": "https://api.github.com/repos/guzzle/RingPHP/zipball/dbbb91d7f6c191e5e405e900e3102ac7f261bc0b",
466
- "reference": "dbbb91d7f6c191e5e405e900e3102ac7f261bc0b",
467
- "shasum": ""
468
- },
469
- "require": {
470
- "guzzlehttp/streams": "~3.0",
471
- "php": ">=5.4.0",
472
- "react/promise": "~2.0"
473
- },
474
- "require-dev": {
475
- "ext-curl": "*",
476
- "phpunit/phpunit": "~4.0"
477
- },
478
- "suggest": {
479
- "ext-curl": "Guzzle will use specific adapters if cURL is present"
480
- },
481
- "time": "2015-05-20T03:37:09+00:00",
482
- "type": "library",
483
- "extra": {
484
- "branch-alias": {
485
- "dev-master": "1.1-dev"
486
- }
487
- },
488
- "installation-source": "dist",
489
- "autoload": {
490
- "psr-4": {
491
- "GuzzleHttp\\Ring\\": "src/"
492
- }
493
- },
494
- "notification-url": "https://packagist.org/downloads/",
495
- "license": [
496
- "MIT"
497
- ],
498
- "authors": [
499
- {
500
- "name": "Michael Dowling",
501
- "email": "mtdowling@gmail.com",
502
- "homepage": "https://github.com/mtdowling"
503
- }
504
- ],
505
- "description": "Provides a simple API and specification that abstracts away the details of HTTP into a single PHP function."
506
- },
507
- {
508
- "name": "guzzlehttp/guzzle",
509
- "version": "5.3.1",
510
- "version_normalized": "5.3.1.0",
511
- "source": {
512
- "type": "git",
513
- "url": "https://github.com/guzzle/guzzle.git",
514
- "reference": "70f1fa53b71c4647bf2762c09068a95f77e12fb8"
515
- },
516
- "dist": {
517
- "type": "zip",
518
- "url": "https://api.github.com/repos/guzzle/guzzle/zipball/70f1fa53b71c4647bf2762c09068a95f77e12fb8",
519
- "reference": "70f1fa53b71c4647bf2762c09068a95f77e12fb8",
520
- "shasum": ""
521
- },
522
- "require": {
523
- "guzzlehttp/ringphp": "^1.1",
524
- "php": ">=5.4.0"
525
- },
526
- "require-dev": {
527
- "ext-curl": "*",
528
- "phpunit/phpunit": "^4.0"
529
- },
530
- "time": "2016-07-15T19:28:39+00:00",
531
- "type": "library",
532
- "installation-source": "dist",
533
- "autoload": {
534
- "psr-4": {
535
- "GuzzleHttp\\": "src/"
536
- }
537
- },
538
- "notification-url": "https://packagist.org/downloads/",
539
- "license": [
540
- "MIT"
541
- ],
542
- "authors": [
543
- {
544
- "name": "Michael Dowling",
545
- "email": "mtdowling@gmail.com",
546
- "homepage": "https://github.com/mtdowling"
547
- }
548
- ],
549
- "description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients",
550
- "homepage": "http://guzzlephp.org/",
551
- "keywords": [
552
- "client",
553
- "curl",
554
- "framework",
555
- "http",
556
- "http client",
557
- "rest",
558
- "web service"
559
- ]
560
- },
561
- {
562
- "name": "psr/http-message",
563
- "version": "1.0",
564
- "version_normalized": "1.0.0.0",
565
- "source": {
566
- "type": "git",
567
- "url": "https://github.com/php-fig/http-message.git",
568
- "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298"
569
- },
570
- "dist": {
571
- "type": "zip",
572
- "url": "https://api.github.com/repos/php-fig/http-message/zipball/85d63699f0dbedb190bbd4b0d2b9dc707ea4c298",
573
- "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298",
574
- "shasum": ""
575
- },
576
- "require": {
577
- "php": ">=5.3.0"
578
- },
579
- "time": "2015-05-04T20:22:00+00:00",
580
- "type": "library",
581
- "extra": {
582
- "branch-alias": {
583
- "dev-master": "1.0.x-dev"
584
- }
585
- },
586
- "installation-source": "dist",
587
- "autoload": {
588
- "psr-4": {
589
- "Psr\\Http\\Message\\": "src/"
590
- }
591
- },
592
- "notification-url": "https://packagist.org/downloads/",
593
- "license": [
594
- "MIT"
595
- ],
596
- "authors": [
597
- {
598
- "name": "PHP-FIG",
599
- "homepage": "http://www.php-fig.org/"
600
- }
601
- ],
602
- "description": "Common interface for HTTP messages",
603
- "keywords": [
604
- "http",
605
- "http-message",
606
- "psr",
607
- "psr-7",
608
- "request",
609
- "response"
610
- ]
611
- },
612
- {
613
- "name": "guzzlehttp/psr7",
614
- "version": "1.2.0",
615
- "version_normalized": "1.2.0.0",
616
- "source": {
617
- "type": "git",
618
- "url": "https://github.com/guzzle/psr7.git",
619
- "reference": "4ef919b0cf3b1989523138b60163bbcb7ba1ff7e"
620
- },
621
- "dist": {
622
- "type": "zip",
623
- "url": "https://api.github.com/repos/guzzle/psr7/zipball/4ef919b0cf3b1989523138b60163bbcb7ba1ff7e",
624
- "reference": "4ef919b0cf3b1989523138b60163bbcb7ba1ff7e",
625
- "shasum": ""
626
- },
627
- "require": {
628
- "php": ">=5.4.0",
629
- "psr/http-message": "~1.0"
630
- },
631
- "provide": {
632
- "psr/http-message-implementation": "1.0"
633
- },
634
- "require-dev": {
635
- "phpunit/phpunit": "~4.0"
636
- },
637
- "time": "2015-08-15T19:32:36+00:00",
638
- "type": "library",
639
- "extra": {
640
- "branch-alias": {
641
- "dev-master": "1.0-dev"
642
- }
643
- },
644
- "installation-source": "dist",
645
- "autoload": {
646
- "psr-4": {
647
- "GuzzleHttp\\Psr7\\": "src/"
648
- },
649
- "files": [
650
- "src/functions_include.php"
651
- ]
652
- },
653
- "notification-url": "https://packagist.org/downloads/",
654
- "license": [
655
- "MIT"
656
- ],
657
- "authors": [
658
- {
659
- "name": "Michael Dowling",
660
- "email": "mtdowling@gmail.com",
661
- "homepage": "https://github.com/mtdowling"
662
- }
663
- ],
664
- "description": "PSR-7 message implementation",
665
- "keywords": [
666
- "http",
667
- "message",
668
- "stream",
669
- "uri"
670
- ]
671
- },
672
- {
673
- "name": "psr/cache",
674
- "version": "1.0.0",
675
- "version_normalized": "1.0.0.0",
676
- "source": {
677
- "type": "git",
678
- "url": "https://github.com/php-fig/cache.git",
679
- "reference": "9e66031f41fbbdda45ee11e93c45d480ccba3eb3"
680
- },
681
- "dist": {
682
- "type": "zip",
683
- "url": "https://api.github.com/repos/php-fig/cache/zipball/9e66031f41fbbdda45ee11e93c45d480ccba3eb3",
684
- "reference": "9e66031f41fbbdda45ee11e93c45d480ccba3eb3",
685
- "shasum": ""
686
- },
687
- "require": {
688
- "php": ">=5.3.0"
689
- },
690
- "time": "2015-12-11T02:52:07+00:00",
691
- "type": "library",
692
- "extra": {
693
- "branch-alias": {
694
- "dev-master": "1.0.x-dev"
695
- }
696
- },
697
- "installation-source": "dist",
698
- "autoload": {
699
- "psr-4": {
700
- "Psr\\Cache\\": "src/"
701
- }
702
- },
703
- "notification-url": "https://packagist.org/downloads/",
704
- "license": [
705
- "MIT"
706
- ],
707
- "authors": [
708
- {
709
- "name": "PHP-FIG",
710
- "homepage": "http://www.php-fig.org/"
711
- }
712
- ],
713
- "description": "Common interface for caching libraries",
714
- "keywords": [
715
- "cache",
716
- "psr",
717
- "psr-6"
718
- ]
719
- }
720
- ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/firebase/php-jwt/Firebase/PHP-JWT/.gitignore DELETED
@@ -1,3 +0,0 @@
1
- vendor
2
- phpunit.phar
3
- phpunit.phar.asc
 
 
 
lib/google-api-php-client/vendor/firebase/php-jwt/Firebase/PHP-JWT/.travis.yml DELETED
@@ -1,13 +0,0 @@
1
- language: php
2
-
3
- php:
4
- - 5.3
5
- - 5.4
6
- - 5.5
7
- - hhvm
8
-
9
- before_script:
10
- - wget -nc http://getcomposer.org/composer.phar
11
- - php composer.phar install
12
-
13
- script: phpunit --configuration phpunit.xml.dist
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/firebase/php-jwt/Firebase/PHP-JWT/Authentication/JWT.php DELETED
@@ -1,326 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * JSON Web Token implementation, based on this spec:
5
- * http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-06
6
- *
7
- * PHP version 5
8
- *
9
- * @category Authentication
10
- * @package Authentication_JWT
11
- * @author Neuman Vong <neuman@twilio.com>
12
- * @author Anant Narayanan <anant@php.net>
13
- * @license http://opensource.org/licenses/BSD-3-Clause 3-clause BSD
14
- * @link https://github.com/firebase/php-jwt
15
- */
16
- class JWT
17
- {
18
- public static $supported_algs = array(
19
- 'HS256' => array('hash_hmac', 'SHA256'),
20
- 'HS512' => array('hash_hmac', 'SHA512'),
21
- 'HS384' => array('hash_hmac', 'SHA384'),
22
- 'RS256' => array('openssl', 'SHA256'),
23
- );
24
-
25
- /**
26
- * Decodes a JWT string into a PHP object.
27
- *
28
- * @param string $jwt The JWT
29
- * @param string|Array|null $key The secret key, or map of keys
30
- * @param Array $allowed_algs List of supported verification algorithms
31
- *
32
- * @return object The JWT's payload as a PHP object
33
- *
34
- * @throws DomainException Algorithm was not provided
35
- * @throws UnexpectedValueException Provided JWT was invalid
36
- * @throws SignatureInvalidException Provided JWT was invalid because the signature verification failed
37
- * @throws BeforeValidException Provided JWT is trying to be used before it's eligible as defined by 'nbf'
38
- * @throws BeforeValidException Provided JWT is trying to be used before it's been created as defined by 'iat'
39
- * @throws ExpiredException Provided JWT has since expired, as defined by the 'exp' claim
40
- *
41
- * @uses jsonDecode
42
- * @uses urlsafeB64Decode
43
- */
44
- public static function decode($jwt, $key = null, $allowed_algs = array())
45
- {
46
- $tks = explode('.', $jwt);
47
- if (count($tks) != 3) {
48
- throw new UnexpectedValueException('Wrong number of segments');
49
- }
50
- list($headb64, $bodyb64, $cryptob64) = $tks;
51
- if (null === ($header = JWT::jsonDecode(JWT::urlsafeB64Decode($headb64)))) {
52
- throw new UnexpectedValueException('Invalid header encoding');
53
- }
54
- if (null === $payload = JWT::jsonDecode(JWT::urlsafeB64Decode($bodyb64))) {
55
- throw new UnexpectedValueException('Invalid claims encoding');
56
- }
57
- $sig = JWT::urlsafeB64Decode($cryptob64);
58
- if (isset($key)) {
59
- if (empty($header->alg)) {
60
- throw new DomainException('Empty algorithm');
61
- }
62
- if (empty(self::$supported_algs[$header->alg])) {
63
- throw new DomainException('Algorithm not supported');
64
- }
65
- if (!is_array($allowed_algs) || !in_array($header->alg, $allowed_algs)) {
66
- throw new DomainException('Algorithm not allowed');
67
- }
68
- if (is_array($key)) {
69
- if (isset($header->kid)) {
70
- $key = $key[$header->kid];
71
- } else {
72
- throw new DomainException('"kid" empty, unable to lookup correct key');
73
- }
74
- }
75
-
76
- // Check the signature
77
- if (!JWT::verify("$headb64.$bodyb64", $sig, $key, $header->alg)) {
78
- throw new SignatureInvalidException('Signature verification failed');
79
- }
80
-
81
- // Check if the nbf if it is defined. This is the time that the
82
- // token can actually be used. If it's not yet that time, abort.
83
- if (isset($payload->nbf) && $payload->nbf > time()) {
84
- throw new BeforeValidException(
85
- 'Cannot handle token prior to ' . date(DateTime::ISO8601, $payload->nbf)
86
- );
87
- }
88
-
89
- // Check that this token has been created before 'now'. This prevents
90
- // using tokens that have been created for later use (and haven't
91
- // correctly used the nbf claim).
92
- if (isset($payload->iat) && $payload->iat > time()) {
93
- throw new BeforeValidException(
94
- 'Cannot handle token prior to ' . date(DateTime::ISO8601, $payload->iat)
95
- );
96
- }
97
-
98
- // Check if this token has expired.
99
- if (isset($payload->exp) && time() >= $payload->exp) {
100
- throw new ExpiredException('Expired token');
101
- }
102
- }
103
-
104
- return $payload;
105
- }
106
-
107
- /**
108
- * Converts and signs a PHP object or array into a JWT string.
109
- *
110
- * @param object|array $payload PHP object or array
111
- * @param string $key The secret key
112
- * @param string $alg The signing algorithm. Supported
113
- * algorithms are 'HS256', 'HS384' and 'HS512'
114
- *
115
- * @return string A signed JWT
116
- * @uses jsonEncode
117
- * @uses urlsafeB64Encode
118
- */
119
- public static function encode($payload, $key, $alg = 'HS256', $keyId = null)
120
- {
121
- $header = array('typ' => 'JWT', 'alg' => $alg);
122
- if ($keyId !== null) {
123
- $header['kid'] = $keyId;
124
- }
125
- $segments = array();
126
- $segments[] = JWT::urlsafeB64Encode(JWT::jsonEncode($header));
127
- $segments[] = JWT::urlsafeB64Encode(JWT::jsonEncode($payload));
128
- $signing_input = implode('.', $segments);
129
-
130
- $signature = JWT::sign($signing_input, $key, $alg);
131
- $segments[] = JWT::urlsafeB64Encode($signature);
132
-
133
- return implode('.', $segments);
134
- }
135
-
136
- /**
137
- * Sign a string with a given key and algorithm.
138
- *
139
- * @param string $msg The message to sign
140
- * @param string|resource $key The secret key
141
- * @param string $alg The signing algorithm. Supported algorithms
142
- * are 'HS256', 'HS384', 'HS512' and 'RS256'
143
- *
144
- * @return string An encrypted message
145
- * @throws DomainException Unsupported algorithm was specified
146
- */
147
- public static function sign($msg, $key, $alg = 'HS256')
148
- {
149
- if (empty(self::$supported_algs[$alg])) {
150
- throw new DomainException('Algorithm not supported');
151
- }
152
- list($function, $algorithm) = self::$supported_algs[$alg];
153
- switch($function) {
154
- case 'hash_hmac':
155
- return hash_hmac($algorithm, $msg, $key, true);
156
- case 'openssl':
157
- $signature = '';
158
- $success = openssl_sign($msg, $signature, $key, $algorithm);
159
- if (!$success) {
160
- throw new DomainException("OpenSSL unable to sign data");
161
- } else {
162
- return $signature;
163
- }
164
- }
165
- }
166
-
167
- /**
168
- * Verify a signature with the mesage, key and method. Not all methods
169
- * are symmetric, so we must have a separate verify and sign method.
170
- * @param string $msg the original message
171
- * @param string $signature
172
- * @param string|resource $key for HS*, a string key works. for RS*, must be a resource of an openssl public key
173
- * @param string $alg
174
- * @return bool
175
- * @throws DomainException Invalid Algorithm or OpenSSL failure
176
- */
177
- private static function verify($msg, $signature, $key, $alg)
178
- {
179
- if (empty(self::$supported_algs[$alg])) {
180
- throw new DomainException('Algorithm not supported');
181
- }
182
-
183
- list($function, $algorithm) = self::$supported_algs[$alg];
184
- switch($function) {
185
- case 'openssl':
186
- $success = openssl_verify($msg, $signature, $key, $algorithm);
187
- if (!$success) {
188
- throw new DomainException("OpenSSL unable to verify data: " . openssl_error_string());
189
- } else {
190
- return $signature;
191
- }
192
- case 'hash_hmac':
193
- default:
194
- $hash = hash_hmac($algorithm, $msg, $key, true);
195
- if (function_exists('hash_equals')) {
196
- return hash_equals($signature, $hash);
197
- }
198
- $len = min(self::safeStrlen($signature), self::safeStrlen($hash));
199
-
200
- $status = 0;
201
- for ($i = 0; $i < $len; $i++) {
202
- $status |= (ord($signature[$i]) ^ ord($hash[$i]));
203
- }
204
- $status |= (self::safeStrlen($signature) ^ self::safeStrlen($hash));
205
-
206
- return ($status === 0);
207
- }
208
- }
209
-
210
- /**
211
- * Decode a JSON string into a PHP object.
212
- *
213
- * @param string $input JSON string
214
- *
215
- * @return object Object representation of JSON string
216
- * @throws DomainException Provided string was invalid JSON
217
- */
218
- public static function jsonDecode($input)
219
- {
220
- if (version_compare(PHP_VERSION, '5.4.0', '>=') && !(defined('JSON_C_VERSION') && PHP_INT_SIZE > 4)) {
221
- /** In PHP >=5.4.0, json_decode() accepts an options parameter, that allows you
222
- * to specify that large ints (like Steam Transaction IDs) should be treated as
223
- * strings, rather than the PHP default behaviour of converting them to floats.
224
- */
225
- $obj = json_decode($input, false, 512, JSON_BIGINT_AS_STRING);
226
- } else {
227
- /** Not all servers will support that, however, so for older versions we must
228
- * manually detect large ints in the JSON string and quote them (thus converting
229
- *them to strings) before decoding, hence the preg_replace() call.
230
- */
231
- $max_int_length = strlen((string) PHP_INT_MAX) - 1;
232
- $json_without_bigints = preg_replace('/:\s*(-?\d{'.$max_int_length.',})/', ': "$1"', $input);
233
- $obj = json_decode($json_without_bigints);
234
- }
235
-
236
- if (function_exists('json_last_error') && $errno = json_last_error()) {
237
- JWT::handleJsonError($errno);
238
- } elseif ($obj === null && $input !== 'null') {
239
- throw new DomainException('Null result with non-null input');
240
- }
241
- return $obj;
242
- }
243
-
244
- /**
245
- * Encode a PHP object into a JSON string.
246
- *
247
- * @param object|array $input A PHP object or array
248
- *
249
- * @return string JSON representation of the PHP object or array
250
- * @throws DomainException Provided object could not be encoded to valid JSON
251
- */
252
- public static function jsonEncode($input)
253
- {
254
- $json = json_encode($input);
255
- if (function_exists('json_last_error') && $errno = json_last_error()) {
256
- JWT::handleJsonError($errno);
257
- } elseif ($json === 'null' && $input !== null) {
258
- throw new DomainException('Null result with non-null input');
259
- }
260
- return $json;
261
- }
262
-
263
- /**
264
- * Decode a string with URL-safe Base64.
265
- *
266
- * @param string $input A Base64 encoded string
267
- *
268
- * @return string A decoded string
269
- */
270
- public static function urlsafeB64Decode($input)
271
- {
272
- $remainder = strlen($input) % 4;
273
- if ($remainder) {
274
- $padlen = 4 - $remainder;
275
- $input .= str_repeat('=', $padlen);
276
- }
277
- return base64_decode(strtr($input, '-_', '+/'));
278
- }
279
-
280
- /**
281
- * Encode a string with URL-safe Base64.
282
- *
283
- * @param string $input The string you want encoded
284
- *
285
- * @return string The base64 encode of what you passed in
286
- */
287
- public static function urlsafeB64Encode($input)
288
- {
289
- return str_replace('=', '', strtr(base64_encode($input), '+/', '-_'));
290
- }
291
-
292
- /**
293
- * Helper method to create a JSON error.
294
- *
295
- * @param int $errno An error number from json_last_error()
296
- *
297
- * @return void
298
- */
299
- private static function handleJsonError($errno)
300
- {
301
- $messages = array(
302
- JSON_ERROR_DEPTH => 'Maximum stack depth exceeded',
303
- JSON_ERROR_CTRL_CHAR => 'Unexpected control character found',
304
- JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON'
305
- );
306
- throw new DomainException(
307
- isset($messages[$errno])
308
- ? $messages[$errno]
309
- : 'Unknown JSON error: ' . $errno
310
- );
311
- }
312
-
313
- /**
314
- * Get the number of bytes in cryptographic strings.
315
- *
316
- * @param string
317
- * @return int
318
- */
319
- private static function safeStrlen($str)
320
- {
321
- if (function_exists('mb_strlen')) {
322
- return mb_strlen($str, '8bit');
323
- }
324
- return strlen($str);
325
- }
326
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/firebase/php-jwt/Firebase/PHP-JWT/Exceptions/BeforeValidException.php DELETED
@@ -1,6 +0,0 @@
1
- <?php
2
-
3
- class BeforeValidException extends UnexpectedValueException
4
- {
5
-
6
- }
 
 
 
 
 
 
lib/google-api-php-client/vendor/firebase/php-jwt/Firebase/PHP-JWT/Exceptions/ExpiredException.php DELETED
@@ -1,6 +0,0 @@
1
- <?php
2
-
3
- class ExpiredException extends UnexpectedValueException
4
- {
5
-
6
- }
 
 
 
 
 
 
lib/google-api-php-client/vendor/firebase/php-jwt/Firebase/PHP-JWT/Exceptions/SignatureInvalidException.php DELETED
@@ -1,6 +0,0 @@
1
- <?php
2
-
3
- class SignatureInvalidException extends UnexpectedValueException
4
- {
5
-
6
- }
 
 
 
 
 
 
lib/google-api-php-client/vendor/firebase/php-jwt/Firebase/PHP-JWT/LICENSE DELETED
@@ -1,30 +0,0 @@
1
- Copyright (c) 2011, Neuman Vong
2
-
3
- All rights reserved.
4
-
5
- Redistribution and use in source and binary forms, with or without
6
- modification, are permitted provided that the following conditions are met:
7
-
8
- * Redistributions of source code must retain the above copyright
9
- notice, this list of conditions and the following disclaimer.
10
-
11
- * Redistributions in binary form must reproduce the above
12
- copyright notice, this list of conditions and the following
13
- disclaimer in the documentation and/or other materials provided
14
- with the distribution.
15
-
16
- * Neither the name of Neuman Vong nor the names of other
17
- contributors may be used to endorse or promote products derived
18
- from this software without specific prior written permission.
19
-
20
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/firebase/php-jwt/Firebase/PHP-JWT/README.md DELETED
@@ -1,66 +0,0 @@
1
- [![Build Status](https://travis-ci.org/firebase/php-jwt.png?branch=master)](https://travis-ci.org/firebase/php-jwt)
2
-
3
- PHP-JWT
4
- =======
5
- A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should
6
- conform to the [current spec](http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-06)
7
-
8
- Installation
9
- ------------
10
-
11
- Use composer to manage your dependencies and download PHP-JWT:
12
-
13
- ```bash
14
- composer require firebase/php-jwt
15
- ```
16
-
17
- Example
18
- -------
19
- ```php
20
- <?php
21
-
22
- $key = "example_key";
23
- $token = array(
24
- "iss" => "http://example.org",
25
- "aud" => "http://example.com",
26
- "iat" => 1356999524,
27
- "nbf" => 1357000000
28
- );
29
-
30
- /**
31
- * IMPORTANT:
32
- * You must specify supported algorithms for your application. See
33
- * https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40
34
- * for a list of spec-compliant algorithms.
35
- */
36
- $jwt = JWT::encode($token, $key);
37
- $decoded = JWT::decode($jwt, $key, array('HS256'));
38
-
39
- print_r($decoded);
40
-
41
- /*
42
- NOTE: This will now be an object instead of an associative array. To get
43
- an associative array, you will need to cast it as such:
44
- */
45
-
46
- $decoded_array = (array) $decoded;
47
-
48
- ?>
49
- ```
50
-
51
- Tests
52
- -----
53
- Run the tests using phpunit:
54
-
55
- ```bash
56
- $ pear install PHPUnit
57
- $ phpunit --configuration phpunit.xml.dist
58
- PHPUnit 3.7.10 by Sebastian Bergmann.
59
- .....
60
- Time: 0 seconds, Memory: 2.50Mb
61
- OK (5 tests, 5 assertions)
62
- ```
63
-
64
- License
65
- -------
66
- [3-Clause BSD](http://opensource.org/licenses/BSD-3-Clause).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/firebase/php-jwt/Firebase/PHP-JWT/composer.json DELETED
@@ -1,27 +0,0 @@
1
- {
2
- "name": "firebase/php-jwt",
3
- "description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.",
4
- "homepage": "https://github.com/firebase/php-jwt",
5
- "authors": [
6
- {
7
- "name": "Neuman Vong",
8
- "email": "neuman+pear@twilio.com",
9
- "role": "Developer"
10
- },
11
- {
12
- "name": "Anant Narayanan",
13
- "email": "anant@php.net",
14
- "role": "Developer"
15
- }
16
- ],
17
- "version": "2.0.0",
18
- "license": "BSD-3-Clause",
19
- "require": {
20
- "php": ">=5.2.0"
21
- },
22
- "autoload": {
23
- "classmap": ["Authentication/", "Exceptions/"]
24
- },
25
- "target-dir": "Firebase/PHP-JWT",
26
- "minimum-stability": "dev"
27
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/firebase/php-jwt/Firebase/PHP-JWT/package.xml DELETED
@@ -1,77 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <package packagerversion="1.9.2" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0
3
- http://pear.php.net/dtd/tasks-1.0.xsd
4
- http://pear.php.net/dtd/package-2.0
5
- http://pear.php.net/dtd/package-2.0.xsd">
6
- <name>JWT</name>
7
- <channel>pear.php.net</channel>
8
- <summary>A JWT encoder/decoder.</summary>
9
- <description>A JWT encoder/decoder library for PHP.</description>
10
- <lead>
11
- <name>Neuman Vong</name>
12
- <user>lcfrs</user>
13
- <email>neuman+pear@twilio.com</email>
14
- <active>yes</active>
15
- </lead>
16
- <lead>
17
- <name>Anant Narayanan</name>
18
- <user>anant</user>
19
- <email>anant@php.net</email>
20
- <active>yes</active>
21
- </lead>
22
- <date>2015-04-01</date>
23
- <version>
24
- <release>2.0.0</release>
25
- <api>2.0.0</api>
26
- </version>
27
- <stability>
28
- <release>beta</release>
29
- <api>beta</api>
30
- </stability>
31
- <license uri="http://opensource.org/licenses/BSD-3-Clause">BSD 3-Clause License</license>
32
- <notes>
33
- Initial release with basic support for JWT encoding, decoding and signature verification.
34
- </notes>
35
- <contents>
36
- <dir baseinstalldir="/" name="/">
37
- <dir name="tests">
38
- <file name="JWTTest.php" role="test" />
39
- </dir>
40
- <file name="Authentication/JWT.php" role="php" />
41
- </dir>
42
- </contents>
43
- <dependencies>
44
- <required>
45
- <php>
46
- <min>5.1</min>
47
- </php>
48
- <pearinstaller>
49
- <min>1.7.0</min>
50
- </pearinstaller>
51
- <extension>
52
- <name>json</name>
53
- </extension>
54
- <extension>
55
- <name>hash</name>
56
- </extension>
57
- </required>
58
- </dependencies>
59
- <phprelease />
60
- <changelog>
61
- <release>
62
- <version>
63
- <release>0.1.0</release>
64
- <api>0.1.0</api>
65
- </version>
66
- <stability>
67
- <release>beta</release>
68
- <api>beta</api>
69
- </stability>
70
- <date>2015-04-01</date>
71
- <license uri="http://opensource.org/licenses/BSD-3-Clause">BSD 3-Clause License</license>
72
- <notes>
73
- Initial release with basic support for JWT encoding, decoding and signature verification.
74
- </notes>
75
- </release>
76
- </changelog>
77
- </package>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/firebase/php-jwt/Firebase/PHP-JWT/phpunit.xml.dist DELETED
@@ -1,19 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
-
3
- <phpunit backupGlobals="false"
4
- backupStaticAttributes="false"
5
- colors="true"
6
- convertErrorsToExceptions="true"
7
- convertNoticesToExceptions="true"
8
- convertWarningsToExceptions="true"
9
- processIsolation="false"
10
- stopOnFailure="false"
11
- syntaxCheck="false"
12
- bootstrap="tests/bootstrap.php"
13
- >
14
- <testsuites>
15
- <testsuite name="PHP JSON Web Token Test Suite">
16
- <directory>./tests</directory>
17
- </testsuite>
18
- </testsuites>
19
- </phpunit>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/firebase/php-jwt/Firebase/PHP-JWT/run-tests.sh DELETED
@@ -1,38 +0,0 @@
1
-
2
- #!/usr/bin/env bash
3
- gpg --fingerprint D8406D0D82947747293778314AA394086372C20A
4
- if [ $? -ne 0 ]; then
5
- echo -e "\033[33mDownloading PGP Public Key...\033[0m"
6
- gpg --recv-keys D8406D0D82947747293778314AA394086372C20A
7
- # Sebastian Bergmann <sb@sebastian-bergmann.de>
8
- gpg --fingerprint D8406D0D82947747293778314AA394086372C20A
9
- if [ $? -ne 0 ]; then
10
- echo -e "\033[31mCould not download PGP public key for verification\033[0m"
11
- exit
12
- fi
13
- fi
14
-
15
- # Let's grab the latest release and its signature
16
- if [ ! -f phpunit.phar ]; then
17
- wget https://phar.phpunit.de/phpunit.phar
18
- fi
19
- if [ ! -f phpunit.phar.asc ]; then
20
- wget https://phar.phpunit.de/phpunit.phar.asc
21
- fi
22
-
23
- # Verify before running
24
- gpg --verify phpunit.phar.asc phpunit.phar
25
- if [ $? -eq 0 ]; then
26
- echo
27
- echo -e "\033[33mBegin Unit Testing\033[0m"
28
- # Run the testing suite
29
- php --version
30
- php phpunit.phar --configuration phpunit.xml.dist
31
- else
32
- echo
33
- chmod -x phpunit.phar
34
- mv phpunit.phar /tmp/bad-phpunit.phar
35
- mv phpunit.phar.asc /tmp/bad-phpunit.phar.asc
36
- echo -e "\033[31mSignature did not match! PHPUnit has been moved to /tmp/bad-phpunit.phar\033[0m"
37
- exit 1
38
- fi
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/apiclient-services/.gitignore DELETED
@@ -1,4 +0,0 @@
1
- vendor
2
- composer.lock
3
- src/Google/Service/Compute/HTTPHealthCheck.php
4
- src/Google/Service/Compute/HTTPSHealthCheck.php
 
 
 
 
lib/google-api-php-client/vendor/google/apiclient-services/.travis.yml DELETED
@@ -1,14 +0,0 @@
1
- language: php
2
-
3
- php:
4
- - 5.4
5
- - 5.5
6
- - 5.6
7
- - 7.0
8
- - 7.1
9
-
10
- install:
11
- - composer install
12
-
13
- script:
14
- - phpunit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/apiclient-services/CONTRIBUTING.md DELETED
@@ -1,22 +0,0 @@
1
- # How to become a contributor and submit your own code
2
-
3
- ## Contributor License Agreements
4
-
5
- We'd love to accept your code patches! However, before we can take them, we have to jump a couple of legal hurdles.
6
-
7
- Please fill out either the individual or corporate Contributor License Agreement (CLA).
8
-
9
- * If you are an individual writing original source code and you're sure you own the intellectual property, then you'll need to sign an [individual CLA](http://code.google.com/legal/individual-cla-v1.0.html).
10
- * If you work for a company that wants to allow you to contribute your work to this client library, then you'll need to sign a[corporate CLA](http://code.google.com/legal/corporate-cla-v1.0.html).
11
-
12
- Follow either of the two links above to access the appropriate CLA and instructions for how to sign and return it. Once we receive it, we'll add you to the official list of contributors and be able to accept your patches.
13
-
14
- ## Submitting Patches
15
-
16
- 1. Fork the PHP client library on GitHub
17
- 1. Decide which code you want to submit. A submission should be a set of changes that addresses one issue in the issue tracker. Please file one change per issue, and address one issue per change. If you want to make a change that doesn't have a corresponding issue in the issue tracker, please file a new ticket!
18
- 1. Ensure that your code adheres to standard PHP conventions, as used in the rest of the library.
19
- 1. Ensure that there are unit tests for your code.
20
- 1. Sign a Contributor License Agreement (see above).
21
- 1. Submit a pull request with your patch on Github.
22
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/apiclient-services/LICENSE DELETED
@@ -1,203 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
179
-
180
- To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "[]"
182
- replaced with your own identifying information. (Don't include
183
- the brackets!) The text should be enclosed in the appropriate
184
- comment syntax for the file format. We also recommend that a
185
- file or class name and description of purpose be included on the
186
- same "printed page" as the copyright notice for easier
187
- identification within third-party archives.
188
-
189
- Copyright [yyyy] [name of copyright owner]
190
-
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
194
-
195
- http://www.apache.org/licenses/LICENSE-2.0
196
-
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.
202
-
203
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/apiclient-services/README.md DELETED
@@ -1,30 +0,0 @@
1
- Google PHP API Client Services
2
- ==============================
3
-
4
- ## Requirements
5
-
6
- [Google API PHP Client](https://github.com/google/google-api-php-client/releases)
7
-
8
- ## Usage in v2 of Google API PHP Client
9
-
10
- This library will be automatically installed with the
11
- [Google API PHP Client](https://github.com/google/google-api-php-client/releases)
12
- via composer. Composer will automatically pull down a monthly tag
13
- from this repository.
14
-
15
- If you'd like to always be up-to-date with the latest release, rather than
16
- wait for monthly tagged releases, request the `dev-master` version in composer:
17
-
18
- ```sh
19
- composer require google/apiclient-services:dev-master
20
- ```
21
-
22
- ## Usage in v1
23
-
24
- If you are currently using the [`v1-master`](https://github.com/google/google-api-php-client/tree/v1-master)
25
- branch of the client library, but want to use the latest API services, you can
26
- do so by requiring this library directly into your project via the same composer command:
27
-
28
- ```sh
29
- composer require google/apiclient-services:dev-master
30
- ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/apiclient-services/composer.json DELETED
@@ -1,19 +0,0 @@
1
- {
2
- "name": "google/apiclient-services",
3
- "type": "library",
4
- "description": "Client library for Google APIs",
5
- "keywords": ["google"],
6
- "homepage": "http://developers.google.com/api-client-library/php",
7
- "license": "Apache-2.0",
8
- "require": {
9
- "php": ">=5.4"
10
- },
11
- "require-dev": {
12
- "phpunit/phpunit": "~4.8"
13
- },
14
- "autoload": {
15
- "psr-0": {
16
- "Google_Service_": "src"
17
- }
18
- }
19
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/apiclient-services/phpunit.xml DELETED
@@ -1,11 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
- xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/3.7/phpunit.xsd"
4
- colors="true"
5
- bootstrap="tests/bootstrap.php">
6
- <testsuites>
7
- <testsuite name="Google PHP Client Unit Services Test Suite">
8
- <directory>tests</directory>
9
- </testsuite>
10
- </testsuites>
11
- </phpunit>
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/apiclient-services/src/Google/Service/Pagespeedonline.php DELETED
@@ -1,93 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2014 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
- * use this file except in compliance with the License. You may obtain a copy of
7
- * the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
- * License for the specific language governing permissions and limitations under
15
- * the License.
16
- */
17
-
18
- /**
19
- * Service definition for Pagespeedonline (v2).
20
- *
21
- * <p>
22
- * Analyzes the performance of a web page and provides tailored suggestions to
23
- * make that page faster.</p>
24
- *
25
- * <p>
26
- * For more information about this service, see the API
27
- * <a href="https://developers.google.com/speed/docs/insights/v2/getting-started" target="_blank">Documentation</a>
28
- * </p>
29
- *
30
- * @author Google, Inc.
31
- */
32
- class Google_Service_Pagespeedonline extends Google_Service
33
- {
34
-
35
-
36
- public $pagespeedapi;
37
-
38
- /**
39
- * Constructs the internal representation of the Pagespeedonline service.
40
- *
41
- * @param Google_Client $client
42
- */
43
- public function __construct(Google_Client $client)
44
- {
45
- parent::__construct($client);
46
- $this->rootUrl = 'https://www.googleapis.com/';
47
- $this->servicePath = 'pagespeedonline/v2/';
48
- $this->version = 'v2';
49
- $this->serviceName = 'pagespeedonline';
50
-
51
- $this->pagespeedapi = new Google_Service_Pagespeedonline_Resource_Pagespeedapi(
52
- $this,
53
- $this->serviceName,
54
- 'pagespeedapi',
55
- array(
56
- 'methods' => array(
57
- 'runpagespeed' => array(
58
- 'path' => 'runPagespeed',
59
- 'httpMethod' => 'GET',
60
- 'parameters' => array(
61
- 'url' => array(
62
- 'location' => 'query',
63
- 'type' => 'string',
64
- 'required' => true,
65
- ),
66
- 'filter_third_party_resources' => array(
67
- 'location' => 'query',
68
- 'type' => 'boolean',
69
- ),
70
- 'locale' => array(
71
- 'location' => 'query',
72
- 'type' => 'string',
73
- ),
74
- 'rule' => array(
75
- 'location' => 'query',
76
- 'type' => 'string',
77
- 'repeated' => true,
78
- ),
79
- 'screenshot' => array(
80
- 'location' => 'query',
81
- 'type' => 'boolean',
82
- ),
83
- 'strategy' => array(
84
- 'location' => 'query',
85
- 'type' => 'string',
86
- ),
87
- ),
88
- ),
89
- )
90
- )
91
- );
92
- }
93
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/apiclient-services/src/Google/Service/Pagespeedonline/PagespeedApiFormatStringV2.php DELETED
@@ -1,47 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2014 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
- * use this file except in compliance with the License. You may obtain a copy of
7
- * the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
- * License for the specific language governing permissions and limitations under
15
- * the License.
16
- */
17
-
18
- class Google_Service_Pagespeedonline_PagespeedApiFormatStringV2 extends Google_Collection
19
- {
20
- protected $collection_key = 'args';
21
- protected $argsType = 'Google_Service_Pagespeedonline_PagespeedApiFormatStringV2Args';
22
- protected $argsDataType = 'array';
23
- public $format;
24
-
25
- /**
26
- * @param Google_Service_Pagespeedonline_PagespeedApiFormatStringV2Args
27
- */
28
- public function setArgs($args)
29
- {
30
- $this->args = $args;
31
- }
32
- /**
33
- * @return Google_Service_Pagespeedonline_PagespeedApiFormatStringV2Args
34
- */
35
- public function getArgs()
36
- {
37
- return $this->args;
38
- }
39
- public function setFormat($format)
40
- {
41
- $this->format = $format;
42
- }
43
- public function getFormat()
44
- {
45
- return $this->format;
46
- }
47
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/apiclient-services/src/Google/Service/Pagespeedonline/PagespeedApiFormatStringV2Args.php DELETED
@@ -1,84 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2014 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
- * use this file except in compliance with the License. You may obtain a copy of
7
- * the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
- * License for the specific language governing permissions and limitations under
15
- * the License.
16
- */
17
-
18
- class Google_Service_Pagespeedonline_PagespeedApiFormatStringV2Args extends Google_Collection
19
- {
20
- protected $collection_key = 'secondary_rects';
21
- protected $internal_gapi_mappings = array(
22
- "secondaryRects" => "secondary_rects",
23
- );
24
- public $key;
25
- protected $rectsType = 'Google_Service_Pagespeedonline_PagespeedApiFormatStringV2ArgsRects';
26
- protected $rectsDataType = 'array';
27
- protected $secondaryRectsType = 'Google_Service_Pagespeedonline_PagespeedApiFormatStringV2ArgsSecondaryRects';
28
- protected $secondaryRectsDataType = 'array';
29
- public $type;
30
- public $value;
31
-
32
- public function setKey($key)
33
- {
34
- $this->key = $key;
35
- }
36
- public function getKey()
37
- {
38
- return $this->key;
39
- }
40
- /**
41
- * @param Google_Service_Pagespeedonline_PagespeedApiFormatStringV2ArgsRects
42
- */
43
- public function setRects($rects)
44
- {
45
- $this->rects = $rects;
46
- }
47
- /**
48
- * @return Google_Service_Pagespeedonline_PagespeedApiFormatStringV2ArgsRects
49
- */
50
- public function getRects()
51
- {
52
- return $this->rects;
53
- }
54
- /**
55
- * @param Google_Service_Pagespeedonline_PagespeedApiFormatStringV2ArgsSecondaryRects
56
- */
57
- public function setSecondaryRects($secondaryRects)
58
- {
59
- $this->secondaryRects = $secondaryRects;
60
- }
61
- /**
62
- * @return Google_Service_Pagespeedonline_PagespeedApiFormatStringV2ArgsSecondaryRects
63
- */
64
- public function getSecondaryRects()
65
- {
66
- return $this->secondaryRects;
67
- }
68
- public function setType($type)
69
- {
70
- $this->type = $type;
71
- }
72
- public function getType()
73
- {
74
- return $this->type;
75
- }
76
- public function setValue($value)
77
- {
78
- $this->value = $value;
79
- }
80
- public function getValue()
81
- {
82
- return $this->value;
83
- }
84
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/apiclient-services/src/Google/Service/Pagespeedonline/PagespeedApiFormatStringV2ArgsRects.php DELETED
@@ -1,57 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2014 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
- * use this file except in compliance with the License. You may obtain a copy of
7
- * the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
- * License for the specific language governing permissions and limitations under
15
- * the License.
16
- */
17
-
18
- class Google_Service_Pagespeedonline_PagespeedApiFormatStringV2ArgsRects extends Google_Model
19
- {
20
- public $height;
21
- public $left;
22
- public $top;
23
- public $width;
24
-
25
- public function setHeight($height)
26
- {
27
- $this->height = $height;
28
- }
29
- public function getHeight()
30
- {
31
- return $this->height;
32
- }
33
- public function setLeft($left)
34
- {
35
- $this->left = $left;
36
- }
37
- public function getLeft()
38
- {
39
- return $this->left;
40
- }
41
- public function setTop($top)
42
- {
43
- $this->top = $top;
44
- }
45
- public function getTop()
46
- {
47
- return $this->top;
48
- }
49
- public function setWidth($width)
50
- {
51
- $this->width = $width;
52
- }
53
- public function getWidth()
54
- {
55
- return $this->width;
56
- }
57
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/apiclient-services/src/Google/Service/Pagespeedonline/PagespeedApiFormatStringV2ArgsSecondaryRects.php DELETED
@@ -1,57 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2014 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
- * use this file except in compliance with the License. You may obtain a copy of
7
- * the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
- * License for the specific language governing permissions and limitations under
15
- * the License.
16
- */
17
-
18
- class Google_Service_Pagespeedonline_PagespeedApiFormatStringV2ArgsSecondaryRects extends Google_Model
19
- {
20
- public $height;
21
- public $left;
22
- public $top;
23
- public $width;
24
-
25
- public function setHeight($height)
26
- {
27
- $this->height = $height;
28
- }
29
- public function getHeight()
30
- {
31
- return $this->height;
32
- }
33
- public function setLeft($left)
34
- {
35
- $this->left = $left;
36
- }
37
- public function getLeft()
38
- {
39
- return $this->left;
40
- }
41
- public function setTop($top)
42
- {
43
- $this->top = $top;
44
- }
45
- public function getTop()
46
- {
47
- return $this->top;
48
- }
49
- public function setWidth($width)
50
- {
51
- $this->width = $width;
52
- }
53
- public function getWidth()
54
- {
55
- return $this->width;
56
- }
57
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/apiclient-services/src/Google/Service/Pagespeedonline/PagespeedApiImageV2.php DELETED
@@ -1,86 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2014 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
- * use this file except in compliance with the License. You may obtain a copy of
7
- * the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
- * License for the specific language governing permissions and limitations under
15
- * the License.
16
- */
17
-
18
- class Google_Service_Pagespeedonline_PagespeedApiImageV2 extends Google_Model
19
- {
20
- protected $internal_gapi_mappings = array(
21
- "mimeType" => "mime_type",
22
- "pageRect" => "page_rect",
23
- );
24
- public $data;
25
- public $height;
26
- public $key;
27
- public $mimeType;
28
- protected $pageRectType = 'Google_Service_Pagespeedonline_PagespeedApiImageV2PageRect';
29
- protected $pageRectDataType = '';
30
- public $width;
31
-
32
- public function setData($data)
33
- {
34
- $this->data = $data;
35
- }
36
- public function getData()
37
- {
38
- return $this->data;
39
- }
40
- public function setHeight($height)
41
- {
42
- $this->height = $height;
43
- }
44
- public function getHeight()
45
- {
46
- return $this->height;
47
- }
48
- public function setKey($key)
49
- {
50
- $this->key = $key;
51
- }
52
- public function getKey()
53
- {
54
- return $this->key;
55
- }
56
- public function setMimeType($mimeType)
57
- {
58
- $this->mimeType = $mimeType;
59
- }
60
- public function getMimeType()
61
- {
62
- return $this->mimeType;
63
- }
64
- /**
65
- * @param Google_Service_Pagespeedonline_PagespeedApiImageV2PageRect
66
- */
67
- public function setPageRect(Google_Service_Pagespeedonline_PagespeedApiImageV2PageRect $pageRect)
68
- {
69
- $this->pageRect = $pageRect;
70
- }
71
- /**
72
- * @return Google_Service_Pagespeedonline_PagespeedApiImageV2PageRect
73
- */
74
- public function getPageRect()
75
- {
76
- return $this->pageRect;
77
- }
78
- public function setWidth($width)
79
- {
80
- $this->width = $width;
81
- }
82
- public function getWidth()
83
- {
84
- return $this->width;
85
- }
86
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/apiclient-services/src/Google/Service/Pagespeedonline/PagespeedApiImageV2PageRect.php DELETED
@@ -1,57 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2014 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
- * use this file except in compliance with the License. You may obtain a copy of
7
- * the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
- * License for the specific language governing permissions and limitations under
15
- * the License.
16
- */
17
-
18
- class Google_Service_Pagespeedonline_PagespeedApiImageV2PageRect extends Google_Model
19
- {
20
- public $height;
21
- public $left;
22
- public $top;
23
- public $width;
24
-
25
- public function setHeight($height)
26
- {
27
- $this->height = $height;
28
- }
29
- public function getHeight()
30
- {
31
- return $this->height;
32
- }
33
- public function setLeft($left)
34
- {
35
- $this->left = $left;
36
- }
37
- public function getLeft()
38
- {
39
- return $this->left;
40
- }
41
- public function setTop($top)
42
- {
43
- $this->top = $top;
44
- }
45
- public function getTop()
46
- {
47
- return $this->top;
48
- }
49
- public function setWidth($width)
50
- {
51
- $this->width = $width;
52
- }
53
- public function getWidth()
54
- {
55
- return $this->width;
56
- }
57
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/apiclient-services/src/Google/Service/Pagespeedonline/Resource/Pagespeedapi.php DELETED
@@ -1,52 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2014 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
- * use this file except in compliance with the License. You may obtain a copy of
7
- * the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
- * License for the specific language governing permissions and limitations under
15
- * the License.
16
- */
17
-
18
- /**
19
- * The "pagespeedapi" collection of methods.
20
- * Typical usage is:
21
- * <code>
22
- * $pagespeedonlineService = new Google_Service_Pagespeedonline(...);
23
- * $pagespeedapi = $pagespeedonlineService->pagespeedapi;
24
- * </code>
25
- */
26
- class Google_Service_Pagespeedonline_Resource_Pagespeedapi extends Google_Service_Resource
27
- {
28
- /**
29
- * Runs PageSpeed analysis on the page at the specified URL, and returns
30
- * PageSpeed scores, a list of suggestions to make that page faster, and other
31
- * information. (pagespeedapi.runpagespeed)
32
- *
33
- * @param string $url The URL to fetch and analyze
34
- * @param array $optParams Optional parameters.
35
- *
36
- * @opt_param bool filter_third_party_resources Indicates if third party
37
- * resources should be filtered out before PageSpeed analysis.
38
- * @opt_param string locale The locale used to localize formatted results
39
- * @opt_param string rule A PageSpeed rule to run; if none are given, all rules
40
- * are run
41
- * @opt_param bool screenshot Indicates if binary data containing a screenshot
42
- * should be included
43
- * @opt_param string strategy The analysis strategy to use
44
- * @return Google_Service_Pagespeedonline_Result
45
- */
46
- public function runpagespeed($url, $optParams = array())
47
- {
48
- $params = array('url' => $url);
49
- $params = array_merge($params, $optParams);
50
- return $this->call('runpagespeed', array($params), "Google_Service_Pagespeedonline_Result");
51
- }
52
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/apiclient-services/src/Google/Service/Pagespeedonline/Result.php DELETED
@@ -1,147 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2014 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
- * use this file except in compliance with the License. You may obtain a copy of
7
- * the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
- * License for the specific language governing permissions and limitations under
15
- * the License.
16
- */
17
-
18
- class Google_Service_Pagespeedonline_Result extends Google_Collection
19
- {
20
- protected $collection_key = 'invalidRules';
21
- protected $formattedResultsType = 'Google_Service_Pagespeedonline_ResultFormattedResults';
22
- protected $formattedResultsDataType = '';
23
- public $id;
24
- public $invalidRules;
25
- public $kind;
26
- protected $pageStatsType = 'Google_Service_Pagespeedonline_ResultPageStats';
27
- protected $pageStatsDataType = '';
28
- public $responseCode;
29
- protected $ruleGroupsType = 'Google_Service_Pagespeedonline_ResultRuleGroupsElement';
30
- protected $ruleGroupsDataType = 'map';
31
- protected $screenshotType = 'Google_Service_Pagespeedonline_PagespeedApiImageV2';
32
- protected $screenshotDataType = '';
33
- public $title;
34
- protected $versionType = 'Google_Service_Pagespeedonline_ResultVersion';
35
- protected $versionDataType = '';
36
-
37
- /**
38
- * @param Google_Service_Pagespeedonline_ResultFormattedResults
39
- */
40
- public function setFormattedResults(Google_Service_Pagespeedonline_ResultFormattedResults $formattedResults)
41
- {
42
- $this->formattedResults = $formattedResults;
43
- }
44
- /**
45
- * @return Google_Service_Pagespeedonline_ResultFormattedResults
46
- */
47
- public function getFormattedResults()
48
- {
49
- return $this->formattedResults;
50
- }
51
- public function setId($id)
52
- {
53
- $this->id = $id;
54
- }
55
- public function getId()
56
- {
57
- return $this->id;
58
- }
59
- public function setInvalidRules($invalidRules)
60
- {
61
- $this->invalidRules = $invalidRules;
62
- }
63
- public function getInvalidRules()
64
- {
65
- return $this->invalidRules;
66
- }
67
- public function setKind($kind)
68
- {
69
- $this->kind = $kind;
70
- }
71
- public function getKind()
72
- {
73
- return $this->kind;
74
- }
75
- /**
76
- * @param Google_Service_Pagespeedonline_ResultPageStats
77
- */
78
- public function setPageStats(Google_Service_Pagespeedonline_ResultPageStats $pageStats)
79
- {
80
- $this->pageStats = $pageStats;
81
- }
82
- /**
83
- * @return Google_Service_Pagespeedonline_ResultPageStats
84
- */
85
- public function getPageStats()
86
- {
87
- return $this->pageStats;
88
- }
89
- public function setResponseCode($responseCode)
90
- {
91
- $this->responseCode = $responseCode;
92
- }
93
- public function getResponseCode()
94
- {
95
- return $this->responseCode;
96
- }
97
- /**
98
- * @param Google_Service_Pagespeedonline_ResultRuleGroupsElement
99
- */
100
- public function setRuleGroups($ruleGroups)
101
- {
102
- $this->ruleGroups = $ruleGroups;
103
- }
104
- /**
105
- * @return Google_Service_Pagespeedonline_ResultRuleGroupsElement
106
- */
107
- public function getRuleGroups()
108
- {
109
- return $this->ruleGroups;
110
- }
111
- /**
112
- * @param Google_Service_Pagespeedonline_PagespeedApiImageV2
113
- */
114
- public function setScreenshot(Google_Service_Pagespeedonline_PagespeedApiImageV2 $screenshot)
115
- {
116
- $this->screenshot = $screenshot;
117
- }
118
- /**
119
- * @return Google_Service_Pagespeedonline_PagespeedApiImageV2
120
- */
121
- public function getScreenshot()
122
- {
123
- return $this->screenshot;
124
- }
125
- public function setTitle($title)
126
- {
127
- $this->title = $title;
128
- }
129
- public function getTitle()
130
- {
131
- return $this->title;
132
- }
133
- /**
134
- * @param Google_Service_Pagespeedonline_ResultVersion
135
- */
136
- public function setVersion(Google_Service_Pagespeedonline_ResultVersion $version)
137
- {
138
- $this->version = $version;
139
- }
140
- /**
141
- * @return Google_Service_Pagespeedonline_ResultVersion
142
- */
143
- public function getVersion()
144
- {
145
- return $this->version;
146
- }
147
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/apiclient-services/src/Google/Service/Pagespeedonline/ResultFormattedResults.php DELETED
@@ -1,46 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2014 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
- * use this file except in compliance with the License. You may obtain a copy of
7
- * the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
- * License for the specific language governing permissions and limitations under
15
- * the License.
16
- */
17
-
18
- class Google_Service_Pagespeedonline_ResultFormattedResults extends Google_Model
19
- {
20
- public $locale;
21
- protected $ruleResultsType = 'Google_Service_Pagespeedonline_ResultFormattedResultsRuleResultsElement';
22
- protected $ruleResultsDataType = 'map';
23
-
24
- public function setLocale($locale)
25
- {
26
- $this->locale = $locale;
27
- }
28
- public function getLocale()
29
- {
30
- return $this->locale;
31
- }
32
- /**
33
- * @param Google_Service_Pagespeedonline_ResultFormattedResultsRuleResultsElement
34
- */
35
- public function setRuleResults($ruleResults)
36
- {
37
- $this->ruleResults = $ruleResults;
38
- }
39
- /**
40
- * @return Google_Service_Pagespeedonline_ResultFormattedResultsRuleResultsElement
41
- */
42
- public function getRuleResults()
43
- {
44
- return $this->ruleResults;
45
- }
46
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/apiclient-services/src/Google/Service/Pagespeedonline/ResultFormattedResultsRuleResultsElement.php DELETED
@@ -1,81 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2014 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
- * use this file except in compliance with the License. You may obtain a copy of
7
- * the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
- * License for the specific language governing permissions and limitations under
15
- * the License.
16
- */
17
-
18
- class Google_Service_Pagespeedonline_ResultFormattedResultsRuleResultsElement extends Google_Collection
19
- {
20
- protected $collection_key = 'urlBlocks';
21
- public $groups;
22
- public $localizedRuleName;
23
- public $ruleImpact;
24
- protected $summaryType = 'Google_Service_Pagespeedonline_PagespeedApiFormatStringV2';
25
- protected $summaryDataType = '';
26
- protected $urlBlocksType = 'Google_Service_Pagespeedonline_ResultFormattedResultsRuleResultsElementUrlBlocks';
27
- protected $urlBlocksDataType = 'array';
28
-
29
- public function setGroups($groups)
30
- {
31
- $this->groups = $groups;
32
- }
33
- public function getGroups()
34
- {
35
- return $this->groups;
36
- }
37
- public function setLocalizedRuleName($localizedRuleName)
38
- {
39
- $this->localizedRuleName = $localizedRuleName;
40
- }
41
- public function getLocalizedRuleName()
42
- {
43
- return $this->localizedRuleName;
44
- }
45
- public function setRuleImpact($ruleImpact)
46
- {
47
- $this->ruleImpact = $ruleImpact;
48
- }
49
- public function getRuleImpact()
50
- {
51
- return $this->ruleImpact;
52
- }
53
- /**
54
- * @param Google_Service_Pagespeedonline_PagespeedApiFormatStringV2
55
- */
56
- public function setSummary(Google_Service_Pagespeedonline_PagespeedApiFormatStringV2 $summary)
57
- {
58
- $this->summary = $summary;
59
- }
60
- /**
61
- * @return Google_Service_Pagespeedonline_PagespeedApiFormatStringV2
62
- */
63
- public function getSummary()
64
- {
65
- return $this->summary;
66
- }
67
- /**
68
- * @param Google_Service_Pagespeedonline_ResultFormattedResultsRuleResultsElementUrlBlocks
69
- */
70
- public function setUrlBlocks($urlBlocks)
71
- {
72
- $this->urlBlocks = $urlBlocks;
73
- }
74
- /**
75
- * @return Google_Service_Pagespeedonline_ResultFormattedResultsRuleResultsElementUrlBlocks
76
- */
77
- public function getUrlBlocks()
78
- {
79
- return $this->urlBlocks;
80
- }
81
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/apiclient-services/src/Google/Service/Pagespeedonline/ResultFormattedResultsRuleResultsElementUrlBlocks.php DELETED
@@ -1,54 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2014 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
- * use this file except in compliance with the License. You may obtain a copy of
7
- * the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
- * License for the specific language governing permissions and limitations under
15
- * the License.
16
- */
17
-
18
- class Google_Service_Pagespeedonline_ResultFormattedResultsRuleResultsElementUrlBlocks extends Google_Collection
19
- {
20
- protected $collection_key = 'urls';
21
- protected $headerType = 'Google_Service_Pagespeedonline_PagespeedApiFormatStringV2';
22
- protected $headerDataType = '';
23
- protected $urlsType = 'Google_Service_Pagespeedonline_ResultFormattedResultsRuleResultsElementUrlBlocksUrls';
24
- protected $urlsDataType = 'array';
25
-
26
- /**
27
- * @param Google_Service_Pagespeedonline_PagespeedApiFormatStringV2
28
- */
29
- public function setHeader(Google_Service_Pagespeedonline_PagespeedApiFormatStringV2 $header)
30
- {
31
- $this->header = $header;
32
- }
33
- /**
34
- * @return Google_Service_Pagespeedonline_PagespeedApiFormatStringV2
35
- */
36
- public function getHeader()
37
- {
38
- return $this->header;
39
- }
40
- /**
41
- * @param Google_Service_Pagespeedonline_ResultFormattedResultsRuleResultsElementUrlBlocksUrls
42
- */
43
- public function setUrls($urls)
44
- {
45
- $this->urls = $urls;
46
- }
47
- /**
48
- * @return Google_Service_Pagespeedonline_ResultFormattedResultsRuleResultsElementUrlBlocksUrls
49
- */
50
- public function getUrls()
51
- {
52
- return $this->urls;
53
- }
54
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/apiclient-services/src/Google/Service/Pagespeedonline/ResultFormattedResultsRuleResultsElementUrlBlocksUrls.php DELETED
@@ -1,54 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2014 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
- * use this file except in compliance with the License. You may obtain a copy of
7
- * the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
- * License for the specific language governing permissions and limitations under
15
- * the License.
16
- */
17
-
18
- class Google_Service_Pagespeedonline_ResultFormattedResultsRuleResultsElementUrlBlocksUrls extends Google_Collection
19
- {
20
- protected $collection_key = 'details';
21
- protected $detailsType = 'Google_Service_Pagespeedonline_PagespeedApiFormatStringV2';
22
- protected $detailsDataType = 'array';
23
- protected $resultType = 'Google_Service_Pagespeedonline_PagespeedApiFormatStringV2';
24
- protected $resultDataType = '';
25
-
26
- /**
27
- * @param Google_Service_Pagespeedonline_PagespeedApiFormatStringV2
28
- */
29
- public function setDetails($details)
30
- {
31
- $this->details = $details;
32
- }
33
- /**
34
- * @return Google_Service_Pagespeedonline_PagespeedApiFormatStringV2
35
- */
36
- public function getDetails()
37
- {
38
- return $this->details;
39
- }
40
- /**
41
- * @param Google_Service_Pagespeedonline_PagespeedApiFormatStringV2
42
- */
43
- public function setResult(Google_Service_Pagespeedonline_PagespeedApiFormatStringV2 $result)
44
- {
45
- $this->result = $result;
46
- }
47
- /**
48
- * @return Google_Service_Pagespeedonline_PagespeedApiFormatStringV2
49
- */
50
- public function getResult()
51
- {
52
- return $this->result;
53
- }
54
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/apiclient-services/src/Google/Service/Pagespeedonline/ResultPageStats.php DELETED
@@ -1,138 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2014 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
- * use this file except in compliance with the License. You may obtain a copy of
7
- * the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
- * License for the specific language governing permissions and limitations under
15
- * the License.
16
- */
17
-
18
- class Google_Service_Pagespeedonline_ResultPageStats extends Google_Model
19
- {
20
- public $cssResponseBytes;
21
- public $flashResponseBytes;
22
- public $htmlResponseBytes;
23
- public $imageResponseBytes;
24
- public $javascriptResponseBytes;
25
- public $numberCssResources;
26
- public $numberHosts;
27
- public $numberJsResources;
28
- public $numberResources;
29
- public $numberStaticResources;
30
- public $otherResponseBytes;
31
- public $textResponseBytes;
32
- public $totalRequestBytes;
33
-
34
- public function setCssResponseBytes($cssResponseBytes)
35
- {
36
- $this->cssResponseBytes = $cssResponseBytes;
37
- }
38
- public function getCssResponseBytes()
39
- {
40
- return $this->cssResponseBytes;
41
- }
42
- public function setFlashResponseBytes($flashResponseBytes)
43
- {
44
- $this->flashResponseBytes = $flashResponseBytes;
45
- }
46
- public function getFlashResponseBytes()
47
- {
48
- return $this->flashResponseBytes;
49
- }
50
- public function setHtmlResponseBytes($htmlResponseBytes)
51
- {
52
- $this->htmlResponseBytes = $htmlResponseBytes;
53
- }
54
- public function getHtmlResponseBytes()
55
- {
56
- return $this->htmlResponseBytes;
57
- }
58
- public function setImageResponseBytes($imageResponseBytes)
59
- {
60
- $this->imageResponseBytes = $imageResponseBytes;
61
- }
62
- public function getImageResponseBytes()
63
- {
64
- return $this->imageResponseBytes;
65
- }
66
- public function setJavascriptResponseBytes($javascriptResponseBytes)
67
- {
68
- $this->javascriptResponseBytes = $javascriptResponseBytes;
69
- }
70
- public function getJavascriptResponseBytes()
71
- {
72
- return $this->javascriptResponseBytes;
73
- }
74
- public function setNumberCssResources($numberCssResources)
75
- {
76
- $this->numberCssResources = $numberCssResources;
77
- }
78
- public function getNumberCssResources()
79
- {
80
- return $this->numberCssResources;
81
- }
82
- public function setNumberHosts($numberHosts)
83
- {
84
- $this->numberHosts = $numberHosts;
85
- }
86
- public function getNumberHosts()
87
- {
88
- return $this->numberHosts;
89
- }
90
- public function setNumberJsResources($numberJsResources)
91
- {
92
- $this->numberJsResources = $numberJsResources;
93
- }
94
- public function getNumberJsResources()
95
- {
96
- return $this->numberJsResources;
97
- }
98
- public function setNumberResources($numberResources)
99
- {
100
- $this->numberResources = $numberResources;
101
- }
102
- public function getNumberResources()
103
- {
104
- return $this->numberResources;
105
- }
106
- public function setNumberStaticResources($numberStaticResources)
107
- {
108
- $this->numberStaticResources = $numberStaticResources;
109
- }
110
- public function getNumberStaticResources()
111
- {
112
- return $this->numberStaticResources;
113
- }
114
- public function setOtherResponseBytes($otherResponseBytes)
115
- {
116
- $this->otherResponseBytes = $otherResponseBytes;
117
- }
118
- public function getOtherResponseBytes()
119
- {
120
- return $this->otherResponseBytes;
121
- }
122
- public function setTextResponseBytes($textResponseBytes)
123
- {
124
- $this->textResponseBytes = $textResponseBytes;
125
- }
126
- public function getTextResponseBytes()
127
- {
128
- return $this->textResponseBytes;
129
- }
130
- public function setTotalRequestBytes($totalRequestBytes)
131
- {
132
- $this->totalRequestBytes = $totalRequestBytes;
133
- }
134
- public function getTotalRequestBytes()
135
- {
136
- return $this->totalRequestBytes;
137
- }
138
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/apiclient-services/src/Google/Service/Pagespeedonline/ResultRuleGroupsElement.php DELETED
@@ -1,30 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2014 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
- * use this file except in compliance with the License. You may obtain a copy of
7
- * the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
- * License for the specific language governing permissions and limitations under
15
- * the License.
16
- */
17
-
18
- class Google_Service_Pagespeedonline_ResultRuleGroupsElement extends Google_Model
19
- {
20
- public $score;
21
-
22
- public function setScore($score)
23
- {
24
- $this->score = $score;
25
- }
26
- public function getScore()
27
- {
28
- return $this->score;
29
- }
30
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/apiclient-services/src/Google/Service/Pagespeedonline/ResultVersion.php DELETED
@@ -1,39 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2014 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
- * use this file except in compliance with the License. You may obtain a copy of
7
- * the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
- * License for the specific language governing permissions and limitations under
15
- * the License.
16
- */
17
-
18
- class Google_Service_Pagespeedonline_ResultVersion extends Google_Model
19
- {
20
- public $major;
21
- public $minor;
22
-
23
- public function setMajor($major)
24
- {
25
- $this->major = $major;
26
- }
27
- public function getMajor()
28
- {
29
- return $this->major;
30
- }
31
- public function setMinor($minor)
32
- {
33
- $this->minor = $minor;
34
- }
35
- public function getMinor()
36
- {
37
- return $this->minor;
38
- }
39
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/auth/.editorconfig DELETED
@@ -1,18 +0,0 @@
1
- # EditorConfig is awesome: http://EditorConfig.org
2
-
3
- # top-most EditorConfig file
4
- root = true
5
- charset = utf-8
6
-
7
- # Get rid of whitespace to avoid diffs with a bunch of EOL changes
8
- trim_trailing_whitespace = true
9
-
10
- # Unix-style newlines with a newline ending every file
11
- [*]
12
- end_of_line = lf
13
- insert_final_newline = true
14
-
15
- # PHP-Files
16
- [*.php]
17
- indent_style = space
18
- indent_size = 4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/auth/.gitignore DELETED
@@ -1,3 +0,0 @@
1
- *~
2
- vendor
3
- composer.lock
 
 
 
lib/google-api-php-client/vendor/google/auth/.php_cs DELETED
@@ -1,54 +0,0 @@
1
- <?php
2
- /**
3
- * This file represents the configuration for Code Sniffing PSR-2-related
4
- * automatic checks of coding guidelines
5
- * Install @fabpot's great php-cs-fixer tool via
6
- *
7
- * $ composer global require fabpot/php-cs-fixer
8
- *
9
- * And then simply run
10
- *
11
- * $ php-cs-fixer fix --config-file .php_cs
12
- *
13
- * inside the root directory.
14
- *
15
- * http://www.php-fig.org/psr/psr-2/
16
- * http://cs.sensiolabs.org
17
- */
18
-
19
- if (PHP_SAPI !== 'cli') {
20
- die('This script supports command line usage only. Please check your command.');
21
- }
22
- // Define in which folders to search and which folders to exclude
23
- // Exclude some directories that are excluded by Git anyways to speed up the sniffing
24
- $finder = Symfony\CS\Finder\DefaultFinder::create()
25
- ->exclude('vendor')
26
- ->in(__DIR__);
27
-
28
- // Return a Code Sniffing configuration using
29
- // all sniffers needed for PSR-2
30
- // and additionally:
31
- // - Remove leading slashes in use clauses.
32
- // - PHP single-line arrays should not have trailing comma.
33
- // - Single-line whitespace before closing semicolon are prohibited.
34
- // - Remove unused use statements in the PHP source code
35
- // - Ensure Concatenation to have at least one whitespace around
36
- // - Remove trailing whitespace at the end of blank lines.
37
- return Symfony\CS\Config\Config::create()
38
- ->level(Symfony\CS\FixerInterface::PSR2_LEVEL)
39
- ->fixers([
40
- 'remove_leading_slash_use',
41
- 'single_array_no_trailing_comma',
42
- 'spaces_before_semicolon',
43
- 'unused_use',
44
- 'concat_with_spaces',
45
- 'whitespacy_lines',
46
- 'ordered_use',
47
- 'single_quote',
48
- 'duplicate_semicolon',
49
- 'extra_empty_lines',
50
- 'phpdoc_no_package',
51
- 'phpdoc_scalar',
52
- 'no_empty_lines_after_phpdocs'
53
- ])
54
- ->finder($finder);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/auth/.travis.yml DELETED
@@ -1,31 +0,0 @@
1
- language: php
2
-
3
- branches:
4
- only: [master]
5
-
6
- sudo: false
7
-
8
- php:
9
- - 5.4
10
- - 5.5
11
- - 5.6
12
- - 7.0
13
- - 7.1
14
-
15
- env:
16
- - COMPOSER_CMD="composer install"
17
- - COMPOSER_CMD="composer update --prefer-lowest"
18
- matrix:
19
- include:
20
- - php: "7.0"
21
- env: RUN_CS_FIXER=true COMPOSER_CMD="composer install"
22
-
23
- before_script:
24
- - $COMPOSER_CMD
25
-
26
- script:
27
- - if [ "${RUN_CS_FIXER}" = "true" ]; then
28
- vendor/bin/php-cs-fixer fix --dry-run --diff --config-file=.php_cs .;
29
- else
30
- vendor/bin/phpunit;
31
- fi
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/auth/CHANGELOG.md DELETED
@@ -1,18 +0,0 @@
1
- ## 1.0.0 (12/06/2017)
2
-
3
- ### Changes
4
-
5
- * Adds hashing and shortening to enforce max key length ([@bshaffer])
6
- * Fix for better PSR-6 compliance - verifies a hit before getting the cache item ([@bshaffer])
7
- * README fixes ([@bshaffer])
8
- * Change authorization header key to lowercase ([@stanley-cheung])
9
-
10
- ## 0.4.0 (23/04/2015)
11
-
12
- ### Changes
13
-
14
- * Export callback function to update auth metadata ([@stanley-cheung][])
15
- * Adds an implementation of User Refresh Token auth ([@stanley-cheung][])
16
-
17
- [@bshaffer]: https://github.com/bshaffer
18
- [@stanley-cheung]: https://github.com/stanley-cheung
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/auth/CONTRIBUTING.md DELETED
@@ -1,73 +0,0 @@
1
- # How to become a contributor and submit your own code
2
-
3
- ## Contributor License Agreements
4
-
5
- We'd love to accept your sample apps and patches! Before we can take them, we
6
- have to jump a couple of legal hurdles.
7
-
8
- Please fill out either the individual or corporate Contributor License Agreement
9
- (CLA).
10
-
11
- * If you are an individual writing original source code and you're sure you
12
- own the intellectual property, then you'll need to sign an [individual CLA]
13
- (http://code.google.com/legal/individual-cla-v1.0.html).
14
- * If you work for a company that wants to allow you to contribute your work,
15
- then you'll need to sign a [corporate CLA]
16
- (http://code.google.com/legal/corporate-cla-v1.0.html).
17
-
18
- Follow either of the two links above to access the appropriate CLA and
19
- instructions for how to sign and return it. Once we receive it, we'll be able to
20
- accept your pull requests.
21
-
22
- ## Issue reporting
23
-
24
- * Check that the issue has not already been reported.
25
- * Check that the issue has not already been fixed in the latest code
26
- (a.k.a. `master`).
27
- * Be clear, concise and precise in your description of the problem.
28
- * Open an issue with a descriptive title and a summary in grammatically correct,
29
- complete sentences.
30
- * Include any relevant code to the issue summary.
31
-
32
- ## Pull requests
33
-
34
- * Read [how to properly contribute to open source projects on Github][2].
35
- * Fork the project.
36
- * Use a topic/feature branch to easily amend a pull request later, if necessary.
37
- * Write [good commit messages][3].
38
- * Use the same coding conventions as the rest of the project.
39
- * Commit and push until you are happy with your contribution.
40
- * Make sure to add tests for it. This is important so I don't break it
41
- in a future version unintentionally.
42
- * Add an entry to the [Changelog](CHANGELOG.md) accordingly. See [changelog entry format](#changelog-entry-format).
43
- * Please try not to mess with the Rakefile, version, or history. If you want to
44
- have your own version, or is otherwise necessary, that is fine, but please
45
- isolate to its own commit so I can cherry-pick around it.
46
- * Make sure the test suite is passing and the code you wrote doesn't produce
47
- phpunit or phplint offenses.
48
- * [Squash related commits together][5].
49
- * Open a [pull request][4] that relates to *only* one subject with a clear title
50
- and description in grammatically correct, complete sentences.
51
-
52
- ### Changelog entry format
53
-
54
- Here are a few examples:
55
-
56
- ```
57
- * ADC Support for User Refresh Tokens (@tbetbetbe[])
58
- * [#16](https://github.com/google/google-auth-library-php/issues/16): ADC Support for User Refresh Tokens ([@tbetbetbe][])
59
- ```
60
-
61
- * Mark it up in [Markdown syntax][6].
62
- * The entry line should start with `* ` (an asterisk and a space).
63
- * If the change has a related GitHub issue (e.g. a bug fix for a reported issue), put a link to the issue as `[#16](https://github.com/google/google-auth-library-php/issues/16): `.
64
- * Describe the brief of the change. The sentence should end with a punctuation.
65
- * At the end of the entry, add an implicit link to your GitHub user page as `([@username][])`.
66
- * If this is your first contribution to google-auth-library-php project, add a link definition for the implicit link to the bottom of the changelog as `[@username]: https://github.com/username`.
67
-
68
- [1]: https://github.com/google/google-auth-php-library/issues
69
- [2]: http://gun.io/blog/how-to-github-fork-branch-and-pull-request
70
- [3]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
71
- [4]: https://help.github.com/articles/using-pull-requests
72
- [5]: http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html
73
- [6]: http://daringfireball.net/projects/markdown/syntax
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/auth/COPYING DELETED
@@ -1,202 +0,0 @@
1
-
2
- Apache License
3
- Version 2.0, January 2004
4
- http://www.apache.org/licenses/
5
-
6
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
-
8
- 1. Definitions.
9
-
10
- "License" shall mean the terms and conditions for use, reproduction,
11
- and distribution as defined by Sections 1 through 9 of this document.
12
-
13
- "Licensor" shall mean the copyright owner or entity authorized by
14
- the copyright owner that is granting the License.
15
-
16
- "Legal Entity" shall mean the union of the acting entity and all
17
- other entities that control, are controlled by, or are under common
18
- control with that entity. For the purposes of this definition,
19
- "control" means (i) the power, direct or indirect, to cause the
20
- direction or management of such entity, whether by contract or
21
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
- outstanding shares, or (iii) beneficial ownership of such entity.
23
-
24
- "You" (or "Your") shall mean an individual or Legal Entity
25
- exercising permissions granted by this License.
26
-
27
- "Source" form shall mean the preferred form for making modifications,
28
- including but not limited to software source code, documentation
29
- source, and configuration files.
30
-
31
- "Object" form shall mean any form resulting from mechanical
32
- transformation or translation of a Source form, including but
33
- not limited to compiled object code, generated documentation,
34
- and conversions to other media types.
35
-
36
- "Work" shall mean the work of authorship, whether in Source or
37
- Object form, made available under the License, as indicated by a
38
- copyright notice that is included in or attached to the work
39
- (an example is provided in the Appendix below).
40
-
41
- "Derivative Works" shall mean any work, whether in Source or Object
42
- form, that is based on (or derived from) the Work and for which the
43
- editorial revisions, annotations, elaborations, or other modifications
44
- represent, as a whole, an original work of authorship. For the purposes
45
- of this License, Derivative Works shall not include works that remain
46
- separable from, or merely link (or bind by name) to the interfaces of,
47
- the Work and Derivative Works thereof.
48
-
49
- "Contribution" shall mean any work of authorship, including
50
- the original version of the Work and any modifications or additions
51
- to that Work or Derivative Works thereof, that is intentionally
52
- submitted to Licensor for inclusion in the Work by the copyright owner
53
- or by an individual or Legal Entity authorized to submit on behalf of
54
- the copyright owner. For the purposes of this definition, "submitted"
55
- means any form of electronic, verbal, or written communication sent
56
- to the Licensor or its representatives, including but not limited to
57
- communication on electronic mailing lists, source code control systems,
58
- and issue tracking systems that are managed by, or on behalf of, the
59
- Licensor for the purpose of discussing and improving the Work, but
60
- excluding communication that is conspicuously marked or otherwise
61
- designated in writing by the copyright owner as "Not a Contribution."
62
-
63
- "Contributor" shall mean Licensor and any individual or Legal Entity
64
- on behalf of whom a Contribution has been received by Licensor and
65
- subsequently incorporated within the Work.
66
-
67
- 2. Grant of Copyright License. Subject to the terms and conditions of
68
- this License, each Contributor hereby grants to You a perpetual,
69
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
- copyright license to reproduce, prepare Derivative Works of,
71
- publicly display, publicly perform, sublicense, and distribute the
72
- Work and such Derivative Works in Source or Object form.
73
-
74
- 3. Grant of Patent License. Subject to the terms and conditions of
75
- this License, each Contributor hereby grants to You a perpetual,
76
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
- (except as stated in this section) patent license to make, have made,
78
- use, offer to sell, sell, import, and otherwise transfer the Work,
79
- where such license applies only to those patent claims licensable
80
- by such Contributor that are necessarily infringed by their
81
- Contribution(s) alone or by combination of their Contribution(s)
82
- with the Work to which such Contribution(s) was submitted. If You
83
- institute patent litigation against any entity (including a
84
- cross-claim or counterclaim in a lawsuit) alleging that the Work
85
- or a Contribution incorporated within the Work constitutes direct
86
- or contributory patent infringement, then any patent licenses
87
- granted to You under this License for that Work shall terminate
88
- as of the date such litigation is filed.
89
-
90
- 4. Redistribution. You may reproduce and distribute copies of the
91
- Work or Derivative Works thereof in any medium, with or without
92
- modifications, and in Source or Object form, provided that You
93
- meet the following conditions:
94
-
95
- (a) You must give any other recipients of the Work or
96
- Derivative Works a copy of this License; and
97
-
98
- (b) You must cause any modified files to carry prominent notices
99
- stating that You changed the files; and
100
-
101
- (c) You must retain, in the Source form of any Derivative Works
102
- that You distribute, all copyright, patent, trademark, and
103
- attribution notices from the Source form of the Work,
104
- excluding those notices that do not pertain to any part of
105
- the Derivative Works; and
106
-
107
- (d) If the Work includes a "NOTICE" text file as part of its
108
- distribution, then any Derivative Works that You distribute must
109
- include a readable copy of the attribution notices contained
110
- within such NOTICE file, excluding those notices that do not
111
- pertain to any part of the Derivative Works, in at least one
112
- of the following places: within a NOTICE text file distributed
113
- as part of the Derivative Works; within the Source form or
114
- documentation, if provided along with the Derivative Works; or,
115
- within a display generated by the Derivative Works, if and
116
- wherever such third-party notices normally appear. The contents
117
- of the NOTICE file are for informational purposes only and
118
- do not modify the License. You may add Your own attribution
119
- notices within Derivative Works that You distribute, alongside
120
- or as an addendum to the NOTICE text from the Work, provided
121
- that such additional attribution notices cannot be construed
122
- as modifying the License.
123
-
124
- You may add Your own copyright statement to Your modifications and
125
- may provide additional or different license terms and conditions
126
- for use, reproduction, or distribution of Your modifications, or
127
- for any such Derivative Works as a whole, provided Your use,
128
- reproduction, and distribution of the Work otherwise complies with
129
- the conditions stated in this License.
130
-
131
- 5. Submission of Contributions. Unless You explicitly state otherwise,
132
- any Contribution intentionally submitted for inclusion in the Work
133
- by You to the Licensor shall be under the terms and conditions of
134
- this License, without any additional terms or conditions.
135
- Notwithstanding the above, nothing herein shall supersede or modify
136
- the terms of any separate license agreement you may have executed
137
- with Licensor regarding such Contributions.
138
-
139
- 6. Trademarks. This License does not grant permission to use the trade
140
- names, trademarks, service marks, or product names of the Licensor,
141
- except as required for reasonable and customary use in describing the
142
- origin of the Work and reproducing the content of the NOTICE file.
143
-
144
- 7. Disclaimer of Warranty. Unless required by applicable law or
145
- agreed to in writing, Licensor provides the Work (and each
146
- Contributor provides its Contributions) on an "AS IS" BASIS,
147
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
- implied, including, without limitation, any warranties or conditions
149
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
- PARTICULAR PURPOSE. You are solely responsible for determining the
151
- appropriateness of using or redistributing the Work and assume any
152
- risks associated with Your exercise of permissions under this License.
153
-
154
- 8. Limitation of Liability. In no event and under no legal theory,
155
- whether in tort (including negligence), contract, or otherwise,
156
- unless required by applicable law (such as deliberate and grossly
157
- negligent acts) or agreed to in writing, shall any Contributor be
158
- liable to You for damages, including any direct, indirect, special,
159
- incidental, or consequential damages of any character arising as a
160
- result of this License or out of the use or inability to use the
161
- Work (including but not limited to damages for loss of goodwill,
162
- work stoppage, computer failure or malfunction, or any and all
163
- other commercial damages or losses), even if such Contributor
164
- has been advised of the possibility of such damages.
165
-
166
- 9. Accepting Warranty or Additional Liability. While redistributing
167
- the Work or Derivative Works thereof, You may choose to offer,
168
- and charge a fee for, acceptance of support, warranty, indemnity,
169
- or other liability obligations and/or rights consistent with this
170
- License. However, in accepting such obligations, You may act only
171
- on Your own behalf and on Your sole responsibility, not on behalf
172
- of any other Contributor, and only if You agree to indemnify,
173
- defend, and hold each Contributor harmless for any liability
174
- incurred by, or claims asserted against, such Contributor by reason
175
- of your accepting any such warranty or additional liability.
176
-
177
- END OF TERMS AND CONDITIONS
178
-
179
- APPENDIX: How to apply the Apache License to your work.
180
-
181
- To apply the Apache License to your work, attach the following
182
- boilerplate notice, with the fields enclosed by brackets "[]"
183
- replaced with your own identifying information. (Don't include
184
- the brackets!) The text should be enclosed in the appropriate
185
- comment syntax for the file format. We also recommend that a
186
- file or class name and description of purpose be included on the
187
- same "printed page" as the copyright notice for easier
188
- identification within third-party archives.
189
-
190
- Copyright 2015 Google Inc.
191
-
192
- Licensed under the Apache License, Version 2.0 (the "License");
193
- you may not use this file except in compliance with the License.
194
- You may obtain a copy of the License at
195
-
196
- http://www.apache.org/licenses/LICENSE-2.0
197
-
198
- Unless required by applicable law or agreed to in writing, software
199
- distributed under the License is distributed on an "AS IS" BASIS,
200
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
- See the License for the specific language governing permissions and
202
- limitations under the License.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/auth/LICENSE DELETED
@@ -1,203 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
179
-
180
- To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "[]"
182
- replaced with your own identifying information. (Don't include
183
- the brackets!) The text should be enclosed in the appropriate
184
- comment syntax for the file format. We also recommend that a
185
- file or class name and description of purpose be included on the
186
- same "printed page" as the copyright notice for easier
187
- identification within third-party archives.
188
-
189
- Copyright [yyyy] [name of copyright owner]
190
-
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
194
-
195
- http://www.apache.org/licenses/LICENSE-2.0
196
-
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.
202
-
203
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/auth/README.md DELETED
@@ -1,150 +0,0 @@
1
- # Google Auth Library for PHP
2
-
3
- <dl>
4
- <dt>Homepage</dt><dd><a href="http://www.github.com/google/google-auth-library-php">http://www.github.com/google/google-auth-library-php</a></dd>
5
- <dt>Authors</dt>
6
- <dd><a href="mailto:temiola@google.com">Tim Emiola</a></dd>
7
- <dd><a href="mailto:stanleycheung@google.com">Stanley Cheung</a></dd>
8
- <dd><a href="mailto:betterbrent@google.com">Brent Shaffer</a></dd>
9
- <dt>Copyright</dt><dd>Copyright © 2015 Google, Inc.</dd>
10
- <dt>License</dt><dd>Apache 2.0</dd>
11
- </dl>
12
-
13
- ## Description
14
-
15
- This is Google's officially supported PHP client library for using OAuth 2.0
16
- authorization and authentication with Google APIs.
17
-
18
- ### Installing via Composer
19
-
20
- The recommended way to install the google auth library is through
21
- [Composer](http://getcomposer.org).
22
-
23
- ```bash
24
- # Install Composer
25
- curl -sS https://getcomposer.org/installer | php
26
- ```
27
-
28
- Next, run the Composer command to install the latest stable version:
29
-
30
- ```bash
31
- composer.phar require google/auth
32
- ```
33
-
34
- ## Application Default Credentials
35
-
36
- This library provides an implementation of
37
- [application default credentials][application default credentials] for PHP.
38
-
39
- The Application Default Credentials provide a simple way to get authorization
40
- credentials for use in calling Google APIs.
41
-
42
- They are best suited for cases when the call needs to have the same identity
43
- and authorization level for the application independent of the user. This is
44
- the recommended approach to authorize calls to Cloud APIs, particularly when
45
- you're building an application that uses Google Compute Engine.
46
-
47
- #### Download your Service Account Credentials JSON file
48
-
49
- To use `Application Default Credentials`, You first need to download a set of
50
- JSON credentials for your project. Go to **APIs & Auth** > **Credentials** in
51
- the [Google Developers Console][developer console] and select
52
- **Service account** from the **Add credentials** dropdown.
53
-
54
- > This file is your *only copy* of these credentials. It should never be
55
- > committed with your source code, and should be stored securely.
56
-
57
- Once downloaded, store the path to this file in the
58
- `GOOGLE_APPLICATION_CREDENTIALS` environment variable.
59
-
60
- ```php
61
- putenv('GOOGLE_APPLICATION_CREDENTIALS=/path/to/my/credentials.json');
62
- ```
63
-
64
- > PHP's `putenv` function is just one way to set an environment variable.
65
- > Consider using `.htaccess` or apache configuration files as well.
66
-
67
- #### Enable the API you want to use
68
-
69
- Before making your API call, you must be sure the API you're calling has been
70
- enabled. Go to **APIs & Auth** > **APIs** in the
71
- [Google Developers Console][developer console] and enable the APIs you'd like to
72
- call. For the example below, you must enable the `Drive API`.
73
-
74
- #### Call the APIs
75
-
76
- As long as you update the environment variable below to point to *your* JSON
77
- credentials file, the following code should output a list of your Drive files.
78
-
79
- ```php
80
- use Google\Auth\ApplicationDefaultCredentials;
81
- use GuzzleHttp\Client;
82
- use GuzzleHttp\HandlerStack;
83
-
84
- // specify the path to your application credentials
85
- putenv('GOOGLE_APPLICATION_CREDENTIALS=/path/to/my/credentials.json');
86
-
87
- // define the scopes for your API call
88
- $scopes = ['https://www.googleapis.com/auth/drive.readonly'];
89
-
90
- // create middleware
91
- $middleware = ApplicationDefaultCredentials::getMiddleware($scopes);
92
- $stack = HandlerStack::create();
93
- $stack->push($middleware);
94
-
95
- // create the HTTP client
96
- $client = new Client([
97
- 'handler' => $stack,
98
- 'base_uri' => 'https://www.googleapis.com',
99
- 'auth' => 'google_auth' // authorize all requests
100
- ]);
101
-
102
- // make the request
103
- $response = $client->get('drive/v2/files');
104
-
105
- // show the result!
106
- print_r((string) $response->getBody());
107
- ```
108
-
109
- ##### Guzzle 5 Compatibility
110
-
111
- If you are using [Guzzle 5][Guzzle 5], replace the `create middleware` and
112
- `create the HTTP Client` steps with the following:
113
-
114
- ```php
115
- // create the HTTP client
116
- $client = new Client([
117
- 'base_url' => 'https://www.googleapis.com',
118
- 'auth' => 'google_auth' // authorize all requests
119
- ]);
120
-
121
- // create subscriber
122
- $subscriber = ApplicationDefaultCredentials::getSubscriber($scopes);
123
- $client->getEmitter()->attach($subscriber);
124
-
125
- ```
126
-
127
- ## License
128
-
129
- This library is licensed under Apache 2.0. Full license text is
130
- available in [COPYING][copying].
131
-
132
- ## Contributing
133
-
134
- See [CONTRIBUTING][contributing].
135
-
136
- ## Support
137
-
138
- Please
139
- [report bugs at the project on Github](https://github.com/google/google-auth-library-php/issues). Don't
140
- hesitate to
141
- [ask questions](http://stackoverflow.com/questions/tagged/google-auth-library-php)
142
- about the client or APIs on [StackOverflow](http://stackoverflow.com).
143
-
144
- [google-apis-php-client]: https://github.com/google/google-api-php-client
145
- [application default credentials]: https://developers.google.com/accounts/docs/application-default-credentials
146
- [contributing]: https://github.com/google/google-auth-library-php/tree/master/CONTRIBUTING.md
147
- [copying]: https://github.com/google/google-auth-library-php/tree/master/COPYING
148
- [Guzzle]: https://github.com/guzzle/guzzle
149
- [Guzzle 5]: http://docs.guzzlephp.org/en/5.3
150
- [developer console]: https://console.developers.google.com
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/auth/autoload.php DELETED
@@ -1,34 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2014 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- function oauth2client_php_autoload($className)
19
- {
20
- $classPath = explode('_', $className);
21
- if ($classPath[0] != 'Google') {
22
- return;
23
- }
24
- if (count($classPath) > 3) {
25
- // Maximum class file path depth in this project is 3.
26
- $classPath = array_slice($classPath, 0, 3);
27
- }
28
- $filePath = dirname(__FILE__) . '/src/' . implode('/', $classPath) . '.php';
29
- if (file_exists($filePath)) {
30
- require_once $filePath;
31
- }
32
- }
33
-
34
- spl_autoload_register('oauth2client_php_autoload');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/auth/composer.json DELETED
@@ -1,28 +0,0 @@
1
- {
2
- "name": "google/auth",
3
- "type": "library",
4
- "description": "Google Auth Library for PHP",
5
- "keywords": ["google", "oauth2", "authentication"],
6
- "homepage": "http://github.com/google/google-auth-library-php",
7
- "license": "Apache-2.0",
8
- "require": {
9
- "php": ">=5.4",
10
- "firebase/php-jwt": "~2.0|~3.0|~4.0",
11
- "guzzlehttp/guzzle": "~5.3.1|~6.0",
12
- "guzzlehttp/psr7": "~1.2",
13
- "psr/http-message": "^1.0",
14
- "psr/cache": "^1.0"
15
- },
16
- "require-dev": {
17
- "phpunit/phpunit": "3.7.*",
18
- "friendsofphp/php-cs-fixer": "^1.11"
19
- },
20
- "autoload": {
21
- "classmap": [
22
- "src/"
23
- ],
24
- "psr-4": {
25
- "Google\\Auth\\": "src"
26
- }
27
- }
28
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/auth/phpunit.xml.dist DELETED
@@ -1,16 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <phpunit bootstrap="tests/bootstrap.php" colors="true">
3
- <testsuites>
4
- <testsuite name="google-auth-tests">
5
- <directory suffix="Test.php">tests</directory>
6
- </testsuite>
7
- </testsuites>
8
- <filter>
9
- <whitelist>
10
- <directory suffix=".php">src</directory>
11
- <exclude>
12
- <directory suffix="Interface.php">src/</directory>
13
- </exclude>
14
- </whitelist>
15
- </filter>
16
- </phpunit>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/auth/src/ApplicationDefaultCredentials.php DELETED
@@ -1,173 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2015 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- namespace Google\Auth;
19
-
20
- use DomainException;
21
- use Google\Auth\Credentials\AppIdentityCredentials;
22
- use Google\Auth\Credentials\GCECredentials;
23
- use Google\Auth\Middleware\AuthTokenMiddleware;
24
- use Google\Auth\Subscriber\AuthTokenSubscriber;
25
- use Psr\Cache\CacheItemPoolInterface;
26
-
27
- /**
28
- * ApplicationDefaultCredentials obtains the default credentials for
29
- * authorizing a request to a Google service.
30
- *
31
- * Application Default Credentials are described here:
32
- * https://developers.google.com/accounts/docs/application-default-credentials
33
- *
34
- * This class implements the search for the application default credentials as
35
- * described in the link.
36
- *
37
- * It provides three factory methods:
38
- * - #get returns the computed credentials object
39
- * - #getSubscriber returns an AuthTokenSubscriber built from the credentials object
40
- * - #getMiddleware returns an AuthTokenMiddleware built from the credentials object
41
- *
42
- * This allows it to be used as follows with GuzzleHttp\Client:
43
- *
44
- * use Google\Auth\ApplicationDefaultCredentials;
45
- * use GuzzleHttp\Client;
46
- * use GuzzleHttp\HandlerStack;
47
- *
48
- * $middleware = ApplicationDefaultCredentials::getMiddleware(
49
- * 'https://www.googleapis.com/auth/taskqueue'
50
- * );
51
- * $stack = HandlerStack::create();
52
- * $stack->push($middleware);
53
- *
54
- * $client = new Client([
55
- * 'handler' => $stack,
56
- * 'base_uri' => 'https://www.googleapis.com/taskqueue/v1beta2/projects/',
57
- * 'auth' => 'google_auth' // authorize all requests
58
- * ]);
59
- *
60
- * $res = $client->get('myproject/taskqueues/myqueue');
61
- */
62
- class ApplicationDefaultCredentials
63
- {
64
- /**
65
- * Obtains an AuthTokenSubscriber that uses the default FetchAuthTokenInterface
66
- * implementation to use in this environment.
67
- *
68
- * If supplied, $scope is used to in creating the credentials instance if
69
- * this does not fallback to the compute engine defaults.
70
- *
71
- * @param string|array scope the scope of the access request, expressed
72
- * either as an Array or as a space-delimited String.
73
- * @param callable $httpHandler callback which delivers psr7 request
74
- * @param array $cacheConfig configuration for the cache when it's present
75
- * @param CacheItemPoolInterface $cache an implementation of CacheItemPoolInterface
76
- *
77
- * @return AuthTokenSubscriber
78
- *
79
- * @throws DomainException if no implementation can be obtained.
80
- */
81
- public static function getSubscriber(
82
- $scope = null,
83
- callable $httpHandler = null,
84
- array $cacheConfig = null,
85
- CacheItemPoolInterface $cache = null
86
- ) {
87
- $creds = self::getCredentials($scope, $httpHandler, $cacheConfig, $cache);
88
-
89
- return new AuthTokenSubscriber($creds, $cacheConfig);
90
- }
91
-
92
- /**
93
- * Obtains an AuthTokenMiddleware that uses the default FetchAuthTokenInterface
94
- * implementation to use in this environment.
95
- *
96
- * If supplied, $scope is used to in creating the credentials instance if
97
- * this does not fallback to the compute engine defaults.
98
- *
99
- * @param string|array scope the scope of the access request, expressed
100
- * either as an Array or as a space-delimited String.
101
- * @param callable $httpHandler callback which delivers psr7 request
102
- * @param array $cacheConfig configuration for the cache when it's present
103
- * @param CacheItemPoolInterface $cache
104
- *
105
- * @return AuthTokenMiddleware
106
- *
107
- * @throws DomainException if no implementation can be obtained.
108
- */
109
- public static function getMiddleware(
110
- $scope = null,
111
- callable $httpHandler = null,
112
- array $cacheConfig = null,
113
- CacheItemPoolInterface $cache = null
114
- ) {
115
- $creds = self::getCredentials($scope, $httpHandler, $cacheConfig, $cache);
116
-
117
- return new AuthTokenMiddleware($creds, $cacheConfig);
118
- }
119
-
120
- /**
121
- * Obtains the default FetchAuthTokenInterface implementation to use
122
- * in this environment.
123
- *
124
- * If supplied, $scope is used to in creating the credentials instance if
125
- * this does not fallback to the Compute Engine defaults.
126
- *
127
- * @param string|array scope the scope of the access request, expressed
128
- * either as an Array or as a space-delimited String.
129
- * @param callable $httpHandler callback which delivers psr7 request
130
- * @param array $cacheConfig configuration for the cache when it's present
131
- * @param CacheItemPoolInterface $cache
132
- *
133
- * @return CredentialsLoader
134
- *
135
- * @throws DomainException if no implementation can be obtained.
136
- */
137
- public static function getCredentials(
138
- $scope = null,
139
- callable $httpHandler = null,
140
- array $cacheConfig = null,
141
- CacheItemPoolInterface $cache = null
142
- ) {
143
- $creds = null;
144
- $jsonKey = CredentialsLoader::fromEnv()
145
- ?: CredentialsLoader::fromWellKnownFile();
146
-
147
- if (!is_null($jsonKey)) {
148
- $creds = CredentialsLoader::makeCredentials($scope, $jsonKey);
149
- } elseif (AppIdentityCredentials::onAppEngine() && !GCECredentials::onAppEngineFlexible()) {
150
- $creds = new AppIdentityCredentials($scope);
151
- } elseif (GCECredentials::onGce($httpHandler)) {
152
- $creds = new GCECredentials();
153
- }
154
-
155
- if (is_null($creds)) {
156
- throw new \DomainException(self::notFound());
157
- }
158
- if (!is_null($cache)) {
159
- $creds = new FetchAuthTokenCache($creds, $cacheConfig, $cache);
160
- }
161
- return $creds;
162
- }
163
-
164
- private static function notFound()
165
- {
166
- $msg = 'Could not load the default credentials. Browse to ';
167
- $msg .= 'https://developers.google.com';
168
- $msg .= '/accounts/docs/application-default-credentials';
169
- $msg .= ' for more information';
170
-
171
- return $msg;
172
- }
173
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/auth/src/Cache/InvalidArgumentException.php DELETED
@@ -1,24 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2016 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- namespace Google\Auth\Cache;
19
-
20
- use Psr\Cache\InvalidArgumentException as PsrInvalidArgumentException;
21
-
22
- class InvalidArgumentException extends \InvalidArgumentException implements PsrInvalidArgumentException
23
- {
24
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/auth/src/Cache/Item.php DELETED
@@ -1,185 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2016 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- namespace Google\Auth\Cache;
19
-
20
- use Psr\Cache\CacheItemInterface;
21
-
22
- /**
23
- * A cache item.
24
- */
25
- final class Item implements CacheItemInterface
26
- {
27
- /**
28
- * @var string
29
- */
30
- private $key;
31
-
32
- /**
33
- * @var mixed
34
- */
35
- private $value;
36
-
37
- /**
38
- * @var \DateTime
39
- */
40
- private $expiration;
41
-
42
- /**
43
- * @var bool
44
- */
45
- private $isHit = false;
46
-
47
- /**
48
- * @param string $key
49
- */
50
- public function __construct($key)
51
- {
52
- $this->key = $key;
53
- }
54
-
55
- /**
56
- * {@inheritdoc}
57
- */
58
- public function getKey()
59
- {
60
- return $this->key;
61
- }
62
-
63
- /**
64
- * {@inheritdoc}
65
- */
66
- public function get()
67
- {
68
- return $this->isHit() ? $this->value : null;
69
- }
70
-
71
- /**
72
- * {@inheritdoc}
73
- */
74
- public function isHit()
75
- {
76
- if (!$this->isHit) {
77
- return false;
78
- }
79
-
80
- if ($this->expiration === null) {
81
- return true;
82
- }
83
-
84
- return new \DateTime() < $this->expiration;
85
- }
86
-
87
- /**
88
- * {@inheritdoc}
89
- */
90
- public function set($value)
91
- {
92
- $this->isHit = true;
93
- $this->value = $value;
94
-
95
- return $this;
96
- }
97
-
98
- /**
99
- * {@inheritdoc}
100
- */
101
- public function expiresAt($expiration)
102
- {
103
- if ($this->isValidExpiration($expiration)) {
104
- $this->expiration = $expiration;
105
-
106
- return $this;
107
- }
108
-
109
- $implementationMessage = interface_exists('DateTimeInterface')
110
- ? 'implement interface DateTimeInterface'
111
- : 'be an instance of DateTime';
112
-
113
- $error = sprintf(
114
- 'Argument 1 passed to %s::expiresAt() must %s, %s given',
115
- get_class($this),
116
- $implementationMessage,
117
- gettype($expiration)
118
- );
119
-
120
- $this->handleError($error);
121
- }
122
-
123
- /**
124
- * {@inheritdoc}
125
- */
126
- public function expiresAfter($time)
127
- {
128
- if (is_int($time)) {
129
- $this->expiration = new \DateTime("now + $time seconds");
130
- } elseif ($time instanceof \DateInterval) {
131
- $this->expiration = (new \DateTime())->add($time);
132
- } elseif ($time === null) {
133
- $this->expiration = $time;
134
- } else {
135
- $message = 'Argument 1 passed to %s::expiresAfter() must be an ' .
136
- 'instance of DateInterval or of the type integer, %s given';
137
- $error = sprintf($message, get_class($this), gettype($expiration));
138
-
139
- $this->handleError($error);
140
- }
141
-
142
- return $this;
143
- }
144
-
145
- /**
146
- * Handles an error.
147
- *
148
- * @param string $error
149
- * @throws \TypeError
150
- */
151
- private function handleError($error)
152
- {
153
- if (class_exists('TypeError')) {
154
- throw new \TypeError($error);
155
- }
156
-
157
- trigger_error($error, E_USER_ERROR);
158
- }
159
-
160
- /**
161
- * Determines if an expiration is valid based on the rules defined by PSR6.
162
- *
163
- * @param mixed $expiration
164
- * @return bool
165
- */
166
- private function isValidExpiration($expiration)
167
- {
168
- if ($expiration === null) {
169
- return true;
170
- }
171
-
172
- // We test for two types here due to the fact the DateTimeInterface
173
- // was not introduced until PHP 5.5. Checking for the DateTime type as
174
- // well allows us to support 5.4.
175
- if ($expiration instanceof \DateTimeInterface) {
176
- return true;
177
- }
178
-
179
- if ($expiration instanceof \DateTime) {
180
- return true;
181
- }
182
-
183
- return false;
184
- }
185
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/auth/src/Cache/MemoryCacheItemPool.php DELETED
@@ -1,155 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2016 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- namespace Google\Auth\Cache;
19
-
20
- use Psr\Cache\CacheItemInterface;
21
- use Psr\Cache\CacheItemPoolInterface;
22
-
23
- /**
24
- * Simple in-memory cache implementation.
25
- */
26
- final class MemoryCacheItemPool implements CacheItemPoolInterface
27
- {
28
- /**
29
- * @var CacheItemInterface[]
30
- */
31
- private $items;
32
-
33
- /**
34
- * @var CacheItemInterface[]
35
- */
36
- private $deferredItems;
37
-
38
- /**
39
- * {@inheritdoc}
40
- */
41
- public function getItem($key)
42
- {
43
- return current($this->getItems([$key]));
44
- }
45
-
46
- /**
47
- * {@inheritdoc}
48
- */
49
- public function getItems(array $keys = [])
50
- {
51
- $items = [];
52
-
53
- foreach ($keys as $key) {
54
- $this->isValidKey($key);
55
- $items[$key] = $this->hasItem($key) ? clone $this->items[$key] : new Item($key);
56
- }
57
-
58
- return $items;
59
- }
60
-
61
- /**
62
- * {@inheritdoc}
63
- */
64
- public function hasItem($key)
65
- {
66
- $this->isValidKey($key);
67
-
68
- return isset($this->items[$key]) && $this->items[$key]->isHit();
69
- }
70
-
71
- /**
72
- * {@inheritdoc}
73
- */
74
- public function clear()
75
- {
76
- $this->items = [];
77
- $this->deferred = [];
78
-
79
- return true;
80
- }
81
-
82
- /**
83
- * {@inheritdoc}
84
- */
85
- public function deleteItem($key)
86
- {
87
- return $this->deleteItems([$key]);
88
- }
89
-
90
- /**
91
- * {@inheritdoc}
92
- */
93
- public function deleteItems(array $keys)
94
- {
95
- array_walk($keys, [$this, 'isValidKey']);
96
-
97
- foreach ($keys as $key) {
98
- unset($this->items[$key]);
99
- }
100
-
101
- return true;
102
- }
103
-
104
- /**
105
- * {@inheritdoc}
106
- */
107
- public function save(CacheItemInterface $item)
108
- {
109
- $this->items[$item->getKey()] = $item;
110
-
111
- return true;
112
- }
113
-
114
- /**
115
- * {@inheritdoc}
116
- */
117
- public function saveDeferred(CacheItemInterface $item)
118
- {
119
- $this->deferredItems[$item->getKey()] = $item;
120
-
121
- return true;
122
- }
123
-
124
- /**
125
- * {@inheritdoc}
126
- */
127
- public function commit()
128
- {
129
- foreach ($this->deferredItems as $item) {
130
- $this->save($item);
131
- }
132
-
133
- $this->deferredItems = [];
134
-
135
- return true;
136
- }
137
-
138
- /**
139
- * Determines if the provided key is valid.
140
- *
141
- * @param string $key
142
- * @return bool
143
- * @throws InvalidArgumentException
144
- */
145
- private function isValidKey($key)
146
- {
147
- $invalidCharacters = '{}()/\\\\@:';
148
-
149
- if (!is_string($key) || preg_match("#[$invalidCharacters]#", $key)) {
150
- throw new InvalidArgumentException('The provided key is not valid: ' . var_export($key, true));
151
- }
152
-
153
- return true;
154
- }
155
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/auth/src/CacheTrait.php DELETED
@@ -1,83 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2015 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- namespace Google\Auth;
19
-
20
- trait CacheTrait
21
- {
22
- private $maxKeyLength = 64;
23
-
24
- /**
25
- * Gets the cached value if it is present in the cache when that is
26
- * available.
27
- */
28
- private function getCachedValue($k)
29
- {
30
- if (is_null($this->cache)) {
31
- return;
32
- }
33
-
34
- $key = $this->getFullCacheKey($k);
35
- if (is_null($key)) {
36
- return;
37
- }
38
-
39
- $cacheItem = $this->cache->getItem($key);
40
- if ($cacheItem->isHit()) {
41
- return $cacheItem->get();
42
- }
43
- }
44
-
45
- /**
46
- * Saves the value in the cache when that is available.
47
- */
48
- private function setCachedValue($k, $v)
49
- {
50
- if (is_null($this->cache)) {
51
- return;
52
- }
53
-
54
- $key = $this->getFullCacheKey($k);
55
- if (is_null($key)) {
56
- return;
57
- }
58
-
59
- $cacheItem = $this->cache->getItem($key);
60
- $cacheItem->set($v);
61
- $cacheItem->expiresAfter($this->cacheConfig['lifetime']);
62
- return $this->cache->save($cacheItem);
63
- }
64
-
65
- private function getFullCacheKey($key)
66
- {
67
- if (is_null($key)) {
68
- return;
69
- }
70
-
71
- $key = $this->cacheConfig['prefix'] . $key;
72
-
73
- // ensure we do not have illegal characters
74
- $key = preg_replace('|[^a-zA-Z0-9_\.!]|', '', $key);
75
-
76
- // Hash keys if they exceed $maxKeyLength (defaults to 64)
77
- if ($this->maxKeyLength && strlen($key) > $this->maxKeyLength) {
78
- $key = substr(hash('sha256', $key), 0, $this->maxKeyLength);
79
- }
80
-
81
- return $key;
82
- }
83
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/auth/src/Credentials/AppIdentityCredentials.php DELETED
@@ -1,149 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2015 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- namespace Google\Auth\Credentials;
19
-
20
- /*
21
- * The AppIdentityService class is automatically defined on App Engine,
22
- * so including this dependency is not necessary, and will result in a
23
- * PHP fatal error in the App Engine environment.
24
- */
25
- use google\appengine\api\app_identity\AppIdentityService;
26
- use Google\Auth\CredentialsLoader;
27
-
28
- /**
29
- * AppIdentityCredentials supports authorization on Google App Engine.
30
- *
31
- * It can be used to authorize requests using the AuthTokenMiddleware or
32
- * AuthTokenSubscriber, but will only succeed if being run on App Engine:
33
- *
34
- * use Google\Auth\Credentials\AppIdentityCredentials;
35
- * use Google\Auth\Middleware\AuthTokenMiddleware;
36
- * use GuzzleHttp\Client;
37
- * use GuzzleHttp\HandlerStack;
38
- *
39
- * $gae = new AppIdentityCredentials('https://www.googleapis.com/auth/books');
40
- * $middleware = new AuthTokenMiddleware($gae);
41
- * $stack = HandlerStack::create();
42
- * $stack->push($middleware);
43
- *
44
- * $client = new Client([
45
- * 'handler' => $stack,
46
- * 'base_uri' => 'https://www.googleapis.com/books/v1',
47
- * 'auth' => 'google_auth'
48
- * ]);
49
- *
50
- * $res = $client->get('volumes?q=Henry+David+Thoreau&country=US');
51
- */
52
- class AppIdentityCredentials extends CredentialsLoader
53
- {
54
- /**
55
- * Result of fetchAuthToken.
56
- *
57
- * @array
58
- */
59
- protected $lastReceivedToken;
60
-
61
- /**
62
- * Array of OAuth2 scopes to be requested.
63
- */
64
- private $scope;
65
-
66
- public function __construct($scope = array())
67
- {
68
- $this->scope = $scope;
69
- }
70
-
71
- /**
72
- * Determines if this an App Engine instance, by accessing the SERVER_SOFTWARE
73
- * environment variable.
74
- *
75
- * @return true if this an App Engine Instance, false otherwise
76
- */
77
- public static function onAppEngine()
78
- {
79
- return isset($_SERVER['SERVER_SOFTWARE']) &&
80
- strpos($_SERVER['SERVER_SOFTWARE'], 'Google App Engine') !== false;
81
- }
82
-
83
- /**
84
- * Implements FetchAuthTokenInterface#fetchAuthToken.
85
- *
86
- * Fetches the auth tokens using the AppIdentityService if available.
87
- * As the AppIdentityService uses protobufs to fetch the access token,
88
- * the GuzzleHttp\ClientInterface instance passed in will not be used.
89
- *
90
- * @param callable $httpHandler callback which delivers psr7 request
91
- *
92
- * @return array the auth metadata:
93
- * array(2) {
94
- * ["access_token"]=>
95
- * string(3) "xyz"
96
- * ["expiration_time"]=>
97
- * string(10) "1444339905"
98
- * }
99
- *
100
- * @throws \Exception
101
- */
102
- public function fetchAuthToken(callable $httpHandler = null)
103
- {
104
- if (!self::onAppEngine()) {
105
- return array();
106
- }
107
-
108
- if (!class_exists('google\appengine\api\app_identity\AppIdentityService')) {
109
- throw new \Exception(
110
- 'This class must be run in App Engine, or you must include the AppIdentityService '
111
- . 'mock class defined in tests/mocks/AppIdentityService.php'
112
- );
113
- }
114
-
115
- // AppIdentityService expects an array when multiple scopes are supplied
116
- $scope = is_array($this->scope) ? $this->scope : explode(' ', $this->scope);
117
-
118
- $token = AppIdentityService::getAccessToken($scope);
119
- $this->lastReceivedToken = $token;
120
-
121
- return $token;
122
- }
123
-
124
- /**
125
- * @return array|null
126
- */
127
- public function getLastReceivedToken()
128
- {
129
- if ($this->lastReceivedToken) {
130
- return [
131
- 'access_token' => $this->lastReceivedToken['access_token'],
132
- 'expires_at' => $this->lastReceivedToken['expiration_time'],
133
- ];
134
- }
135
-
136
- return null;
137
- }
138
-
139
- /**
140
- * Caching is handled by the underlying AppIdentityService, return empty string
141
- * to prevent caching.
142
- *
143
- * @return string
144
- */
145
- public function getCacheKey()
146
- {
147
- return '';
148
- }
149
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/auth/src/Credentials/GCECredentials.php DELETED
@@ -1,219 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2015 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- namespace Google\Auth\Credentials;
19
-
20
- use Google\Auth\CredentialsLoader;
21
- use Google\Auth\HttpHandler\HttpHandlerFactory;
22
- use GuzzleHttp\Exception\ClientException;
23
- use GuzzleHttp\Exception\RequestException;
24
- use GuzzleHttp\Exception\ServerException;
25
- use GuzzleHttp\Psr7\Request;
26
-
27
- /**
28
- * GCECredentials supports authorization on Google Compute Engine.
29
- *
30
- * It can be used to authorize requests using the AuthTokenMiddleware, but will
31
- * only succeed if being run on GCE:
32
- *
33
- * use Google\Auth\Credentials\GCECredentials;
34
- * use Google\Auth\Middleware\AuthTokenMiddleware;
35
- * use GuzzleHttp\Client;
36
- * use GuzzleHttp\HandlerStack;
37
- *
38
- * $gce = new GCECredentials();
39
- * $middleware = new AuthTokenMiddleware($gce);
40
- * $stack = HandlerStack::create();
41
- * $stack->push($middleware);
42
- *
43
- * $client = new Client([
44
- * 'handler' => $stack,
45
- * 'base_uri' => 'https://www.googleapis.com/taskqueue/v1beta2/projects/',
46
- * 'auth' => 'google_auth'
47
- * ]);
48
- *
49
- * $res = $client->get('myproject/taskqueues/myqueue');
50
- */
51
- class GCECredentials extends CredentialsLoader
52
- {
53
- const cacheKey = 'GOOGLE_AUTH_PHP_GCE';
54
- /**
55
- * The metadata IP address on appengine instances.
56
- *
57
- * The IP is used instead of the domain 'metadata' to avoid slow responses
58
- * when not on Compute Engine.
59
- */
60
- const METADATA_IP = '169.254.169.254';
61
-
62
- /**
63
- * The metadata path of the default token.
64
- */
65
- const TOKEN_URI_PATH = 'v1/instance/service-accounts/default/token';
66
-
67
- /**
68
- * The header whose presence indicates GCE presence.
69
- */
70
- const FLAVOR_HEADER = 'Metadata-Flavor';
71
-
72
- /**
73
- * Flag used to ensure that the onGCE test is only done once;.
74
- *
75
- * @var bool
76
- */
77
- private $hasCheckedOnGce = false;
78
-
79
- /**
80
- * Flag that stores the value of the onGCE check.
81
- *
82
- * @var bool
83
- */
84
- private $isOnGce = false;
85
-
86
- /**
87
- * Result of fetchAuthToken.
88
- */
89
- protected $lastReceivedToken;
90
-
91
- /**
92
- * The full uri for accessing the default token.
93
- *
94
- * @return string
95
- */
96
- public static function getTokenUri()
97
- {
98
- $base = 'http://' . self::METADATA_IP . '/computeMetadata/';
99
-
100
- return $base . self::TOKEN_URI_PATH;
101
- }
102
-
103
- /**
104
- * Determines if this an App Engine Flexible instance, by accessing the
105
- * GAE_VM environment variable.
106
- *
107
- * @return true if this an App Engine Flexible Instance, false otherwise
108
- */
109
- public static function onAppEngineFlexible()
110
- {
111
- return isset($_SERVER['GAE_VM']) && 'true' === $_SERVER['GAE_VM'];
112
- }
113
-
114
- /**
115
- * Determines if this a GCE instance, by accessing the expected metadata
116
- * host.
117
- * If $httpHandler is not specified a the default HttpHandler is used.
118
- *
119
- * @param callable $httpHandler callback which delivers psr7 request
120
- *
121
- * @return true if this a GCEInstance false otherwise
122
- */
123
- public static function onGce(callable $httpHandler = null)
124
- {
125
- if (is_null($httpHandler)) {
126
- $httpHandler = HttpHandlerFactory::build();
127
- }
128
- $checkUri = 'http://' . self::METADATA_IP;
129
- try {
130
- // Comment from: oauth2client/client.py
131
- //
132
- // Note: the explicit `timeout` below is a workaround. The underlying
133
- // issue is that resolving an unknown host on some networks will take
134
- // 20-30 seconds; making this timeout short fixes the issue, but
135
- // could lead to false negatives in the event that we are on GCE, but
136
- // the metadata resolution was particularly slow. The latter case is
137
- // "unlikely".
138
- $resp = $httpHandler(
139
- new Request('GET', $checkUri),
140
- ['timeout' => 0.3]
141
- );
142
-
143
- return $resp->getHeaderLine(self::FLAVOR_HEADER) == 'Google';
144
- } catch (ClientException $e) {
145
- return false;
146
- } catch (ServerException $e) {
147
- return false;
148
- } catch (RequestException $e) {
149
- return false;
150
- }
151
- }
152
-
153
- /**
154
- * Implements FetchAuthTokenInterface#fetchAuthToken.
155
- *
156
- * Fetches the auth tokens from the GCE metadata host if it is available.
157
- * If $httpHandler is not specified a the default HttpHandler is used.
158
- *
159
- * @param callable $httpHandler callback which delivers psr7 request
160
- *
161
- * @return array the response
162
- *
163
- * @throws \Exception
164
- */
165
- public function fetchAuthToken(callable $httpHandler = null)
166
- {
167
- if (is_null($httpHandler)) {
168
- $httpHandler = HttpHandlerFactory::build();
169
- }
170
- if (!$this->hasCheckedOnGce) {
171
- $this->isOnGce = self::onGce($httpHandler);
172
- }
173
- if (!$this->isOnGce) {
174
- return array(); // return an empty array with no access token
175
- }
176
- $resp = $httpHandler(
177
- new Request(
178
- 'GET',
179
- self::getTokenUri(),
180
- [self::FLAVOR_HEADER => 'Google']
181
- )
182
- );
183
- $body = (string)$resp->getBody();
184
-
185
- // Assume it's JSON; if it's not throw an exception
186
- if (null === $json = json_decode($body, true)) {
187
- throw new \Exception('Invalid JSON response');
188
- }
189
-
190
- // store this so we can retrieve it later
191
- $this->lastReceivedToken = $json;
192
- $this->lastReceivedToken['expires_at'] = time() + $json['expires_in'];
193
-
194
- return $json;
195
- }
196
-
197
- /**
198
- * @return string
199
- */
200
- public function getCacheKey()
201
- {
202
- return self::cacheKey;
203
- }
204
-
205
- /**
206
- * @return array|null
207
- */
208
- public function getLastReceivedToken()
209
- {
210
- if ($this->lastReceivedToken) {
211
- return [
212
- 'access_token' => $this->lastReceivedToken['access_token'],
213
- 'expires_at' => $this->lastReceivedToken['expires_at'],
214
- ];
215
- }
216
-
217
- return null;
218
- }
219
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/auth/src/Credentials/IAMCredentials.php DELETED
@@ -1,89 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2015 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- namespace Google\Auth\Credentials;
19
-
20
- /**
21
- * Authenticates requests using IAM credentials.
22
- */
23
- class IAMCredentials
24
- {
25
- const SELECTOR_KEY = 'x-goog-iam-authority-selector';
26
- const TOKEN_KEY = 'x-goog-iam-authorization-token';
27
-
28
- /**
29
- * @var string
30
- */
31
- private $selector;
32
-
33
- /**
34
- * @var string
35
- */
36
- private $token;
37
-
38
- /**
39
- * @param $selector string the IAM selector
40
- * @param $token string the IAM token
41
- */
42
- public function __construct($selector, $token)
43
- {
44
- if (!is_string($selector)) {
45
- throw new \InvalidArgumentException(
46
- 'selector must be a string');
47
- }
48
- if (!is_string($token)) {
49
- throw new \InvalidArgumentException(
50
- 'token must be a string');
51
- }
52
-
53
- $this->selector = $selector;
54
- $this->token = $token;
55
- }
56
-
57
- /**
58
- * export a callback function which updates runtime metadata.
59
- *
60
- * @return array updateMetadata function
61
- */
62
- public function getUpdateMetadataFunc()
63
- {
64
- return array($this, 'updateMetadata');
65
- }
66
-
67
- /**
68
- * Updates metadata with the appropriate header metadata.
69
- *
70
- * @param array $metadata metadata hashmap
71
- * @param string $unusedAuthUri optional auth uri
72
- * @param callable $httpHandler callback which delivers psr7 request
73
- * Note: this param is unused here, only included here for
74
- * consistency with other credentials class
75
- *
76
- * @return array updated metadata hashmap
77
- */
78
- public function updateMetadata(
79
- $metadata,
80
- $unusedAuthUri = null,
81
- callable $httpHandler = null
82
- ) {
83
- $metadata_copy = $metadata;
84
- $metadata_copy[self::SELECTOR_KEY] = $this->selector;
85
- $metadata_copy[self::TOKEN_KEY] = $this->token;
86
-
87
- return $metadata_copy;
88
- }
89
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/auth/src/Credentials/ServiceAccountCredentials.php DELETED
@@ -1,177 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2015 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- namespace Google\Auth\Credentials;
19
-
20
- use Google\Auth\CredentialsLoader;
21
- use Google\Auth\OAuth2;
22
-
23
- /**
24
- * ServiceAccountCredentials supports authorization using a Google service
25
- * account.
26
- *
27
- * (cf https://developers.google.com/accounts/docs/OAuth2ServiceAccount)
28
- *
29
- * It's initialized using the json key file that's downloadable from developer
30
- * console, which should contain a private_key and client_email fields that it
31
- * uses.
32
- *
33
- * Use it with AuthTokenMiddleware to authorize http requests:
34
- *
35
- * use Google\Auth\Credentials\ServiceAccountCredentials;
36
- * use Google\Auth\Middleware\AuthTokenMiddleware;
37
- * use GuzzleHttp\Client;
38
- * use GuzzleHttp\HandlerStack;
39
- *
40
- * $sa = new ServiceAccountCredentials(
41
- * 'https://www.googleapis.com/auth/taskqueue',
42
- * '/path/to/your/json/key_file.json'
43
- * );
44
- * $middleware = new AuthTokenMiddleware($sa);
45
- * $stack = HandlerStack::create();
46
- * $stack->push($middleware);
47
- *
48
- * $client = new Client([
49
- * 'handler' => $stack,
50
- * 'base_uri' => 'https://www.googleapis.com/taskqueue/v1beta2/projects/',
51
- * 'auth' => 'google_auth' // authorize all requests
52
- * ]);
53
- *
54
- * $res = $client->get('myproject/taskqueues/myqueue');
55
- */
56
- class ServiceAccountCredentials extends CredentialsLoader
57
- {
58
- /**
59
- * The OAuth2 instance used to conduct authorization.
60
- *
61
- * @var OAuth2
62
- */
63
- protected $auth;
64
-
65
- /**
66
- * Create a new ServiceAccountCredentials.
67
- *
68
- * @param string|array $scope the scope of the access request, expressed
69
- * either as an Array or as a space-delimited String.
70
- * @param string|array $jsonKey JSON credential file path or JSON credentials
71
- * as an associative array
72
- * @param string $sub an email address account to impersonate, in situations when
73
- * the service account has been delegated domain wide access.
74
- */
75
- public function __construct(
76
- $scope,
77
- $jsonKey,
78
- $sub = null
79
- ) {
80
- if (is_string($jsonKey)) {
81
- if (!file_exists($jsonKey)) {
82
- throw new \InvalidArgumentException('file does not exist');
83
- }
84
- $jsonKeyStream = file_get_contents($jsonKey);
85
- if (!$jsonKey = json_decode($jsonKeyStream, true)) {
86
- throw new \LogicException('invalid json for auth config');
87
- }
88
- }
89
- if (!array_key_exists('client_email', $jsonKey)) {
90
- throw new \InvalidArgumentException(
91
- 'json key is missing the client_email field');
92
- }
93
- if (!array_key_exists('private_key', $jsonKey)) {
94
- throw new \InvalidArgumentException(
95
- 'json key is missing the private_key field');
96
- }
97
- $this->auth = new OAuth2([
98
- 'audience' => self::TOKEN_CREDENTIAL_URI,
99
- 'issuer' => $jsonKey['client_email'],
100
- 'scope' => $scope,
101
- 'signingAlgorithm' => 'RS256',
102
- 'signingKey' => $jsonKey['private_key'],
103
- 'sub' => $sub,
104
- 'tokenCredentialUri' => self::TOKEN_CREDENTIAL_URI,
105
- ]);
106
- }
107
-
108
- /**
109
- * @param callable $httpHandler
110
- *
111
- * @return array
112
- */
113
- public function fetchAuthToken(callable $httpHandler = null)
114
- {
115
- return $this->auth->fetchAuthToken($httpHandler);
116
- }
117
-
118
- /**
119
- * @return string
120
- */
121
- public function getCacheKey()
122
- {
123
- $key = $this->auth->getIssuer() . ':' . $this->auth->getCacheKey();
124
- if ($sub = $this->auth->getSub()) {
125
- $key .= ':' . $sub;
126
- }
127
-
128
- return $key;
129
- }
130
-
131
- /**
132
- * @return array
133
- */
134
- public function getLastReceivedToken()
135
- {
136
- return $this->auth->getLastReceivedToken();
137
- }
138
-
139
- /**
140
- * Updates metadata with the authorization token.
141
- *
142
- * @param array $metadata metadata hashmap
143
- * @param string $authUri optional auth uri
144
- * @param callable $httpHandler callback which delivers psr7 request
145
- *
146
- * @return array updated metadata hashmap
147
- */
148
- public function updateMetadata(
149
- $metadata,
150
- $authUri = null,
151
- callable $httpHandler = null
152
- ) {
153
- // scope exists. use oauth implementation
154
- $scope = $this->auth->getScope();
155
- if (!is_null($scope)) {
156
- return parent::updateMetadata($metadata, $authUri, $httpHandler);
157
- }
158
-
159
- // no scope found. create jwt with the auth uri
160
- $credJson = array(
161
- 'private_key' => $this->auth->getSigningKey(),
162
- 'client_email' => $this->auth->getIssuer(),
163
- );
164
- $jwtCreds = new ServiceAccountJwtAccessCredentials($credJson);
165
-
166
- return $jwtCreds->updateMetadata($metadata, $authUri, $httpHandler);
167
- }
168
-
169
- /**
170
- * @param string $sub an email address account to impersonate, in situations when
171
- * the service account has been delegated domain wide access.
172
- */
173
- public function setSub($sub)
174
- {
175
- $this->auth->setSub($sub);
176
- }
177
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/auth/src/Credentials/ServiceAccountJwtAccessCredentials.php DELETED
@@ -1,131 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2015 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- namespace Google\Auth\Credentials;
19
-
20
- use Google\Auth\CredentialsLoader;
21
- use Google\Auth\OAuth2;
22
-
23
- /**
24
- * Authenticates requests using Google's Service Account credentials via
25
- * JWT Access.
26
- *
27
- * This class allows authorizing requests for service accounts directly
28
- * from credentials from a json key file downloaded from the developer
29
- * console (via 'Generate new Json Key'). It is not part of any OAuth2
30
- * flow, rather it creates a JWT and sends that as a credential.
31
- */
32
- class ServiceAccountJwtAccessCredentials extends CredentialsLoader
33
- {
34
- /**
35
- * The OAuth2 instance used to conduct authorization.
36
- *
37
- * @var OAuth2
38
- */
39
- protected $auth;
40
-
41
- /**
42
- * Create a new ServiceAccountJwtAccessCredentials.
43
- *
44
- * @param string|array $jsonKey JSON credential file path or JSON credentials
45
- * as an associative array
46
- */
47
- public function __construct($jsonKey)
48
- {
49
- if (is_string($jsonKey)) {
50
- if (!file_exists($jsonKey)) {
51
- throw new \InvalidArgumentException('file does not exist');
52
- }
53
- $jsonKeyStream = file_get_contents($jsonKey);
54
- if (!$jsonKey = json_decode($jsonKeyStream, true)) {
55
- throw new \LogicException('invalid json for auth config');
56
- }
57
- }
58
- if (!array_key_exists('client_email', $jsonKey)) {
59
- throw new \InvalidArgumentException(
60
- 'json key is missing the client_email field');
61
- }
62
- if (!array_key_exists('private_key', $jsonKey)) {
63
- throw new \InvalidArgumentException(
64
- 'json key is missing the private_key field');
65
- }
66
- $this->auth = new OAuth2([
67
- 'issuer' => $jsonKey['client_email'],
68
- 'sub' => $jsonKey['client_email'],
69
- 'signingAlgorithm' => 'RS256',
70
- 'signingKey' => $jsonKey['private_key'],
71
- ]);
72
- }
73
-
74
- /**
75
- * Updates metadata with the authorization token.
76
- *
77
- * @param array $metadata metadata hashmap
78
- * @param string $authUri optional auth uri
79
- * @param callable $httpHandler callback which delivers psr7 request
80
- *
81
- * @return array updated metadata hashmap
82
- */
83
- public function updateMetadata(
84
- $metadata,
85
- $authUri = null,
86
- callable $httpHandler = null
87
- ) {
88
- if (empty($authUri)) {
89
- return $metadata;
90
- }
91
-
92
- $this->auth->setAudience($authUri);
93
-
94
- return parent::updateMetadata($metadata, $authUri, $httpHandler);
95
- }
96
-
97
- /**
98
- * Implements FetchAuthTokenInterface#fetchAuthToken.
99
- *
100
- * @param callable $httpHandler
101
- *
102
- * @return array|void
103
- */
104
- public function fetchAuthToken(callable $httpHandler = null)
105
- {
106
- $audience = $this->auth->getAudience();
107
- if (empty($audience)) {
108
- return null;
109
- }
110
-
111
- $access_token = $this->auth->toJwt();
112
-
113
- return array('access_token' => $access_token);
114
- }
115
-
116
- /**
117
- * @return string
118
- */
119
- public function getCacheKey()
120
- {
121
- return $this->auth->getCacheKey();
122
- }
123
-
124
- /**
125
- * @return array
126
- */
127
- public function getLastReceivedToken()
128
- {
129
- return $this->auth->getLastReceivedToken();
130
- }
131
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/auth/src/Credentials/UserRefreshCredentials.php DELETED
@@ -1,110 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2015 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- namespace Google\Auth\Credentials;
19
-
20
- use Google\Auth\CredentialsLoader;
21
- use Google\Auth\OAuth2;
22
-
23
- /**
24
- * Authenticates requests using User Refresh credentials.
25
- *
26
- * This class allows authorizing requests from user refresh tokens.
27
- *
28
- * This the end of the result of a 3LO flow. E.g, the end result of
29
- * 'gcloud auth login' saves a file with these contents in well known
30
- * location
31
- *
32
- * @see [Application Default Credentials](http://goo.gl/mkAHpZ)
33
- */
34
- class UserRefreshCredentials extends CredentialsLoader
35
- {
36
- /**
37
- * The OAuth2 instance used to conduct authorization.
38
- *
39
- * @var OAuth2
40
- */
41
- protected $auth;
42
-
43
- /**
44
- * Create a new UserRefreshCredentials.
45
- *
46
- * @param string|array $scope the scope of the access request, expressed
47
- * either as an Array or as a space-delimited String.
48
- * @param string|array $jsonKey JSON credential file path or JSON credentials
49
- * as an associative array
50
- */
51
- public function __construct(
52
- $scope,
53
- $jsonKey
54
- ) {
55
- if (is_string($jsonKey)) {
56
- if (!file_exists($jsonKey)) {
57
- throw new \InvalidArgumentException('file does not exist');
58
- }
59
- $jsonKeyStream = file_get_contents($jsonKey);
60
- if (!$jsonKey = json_decode($jsonKeyStream, true)) {
61
- throw new \LogicException('invalid json for auth config');
62
- }
63
- }
64
- if (!array_key_exists('client_id', $jsonKey)) {
65
- throw new \InvalidArgumentException(
66
- 'json key is missing the client_id field');
67
- }
68
- if (!array_key_exists('client_secret', $jsonKey)) {
69
- throw new \InvalidArgumentException(
70
- 'json key is missing the client_secret field');
71
- }
72
- if (!array_key_exists('refresh_token', $jsonKey)) {
73
- throw new \InvalidArgumentException(
74
- 'json key is missing the refresh_token field');
75
- }
76
- $this->auth = new OAuth2([
77
- 'clientId' => $jsonKey['client_id'],
78
- 'clientSecret' => $jsonKey['client_secret'],
79
- 'refresh_token' => $jsonKey['refresh_token'],
80
- 'scope' => $scope,
81
- 'tokenCredentialUri' => self::TOKEN_CREDENTIAL_URI,
82
- ]);
83
- }
84
-
85
- /**
86
- * @param callable $httpHandler
87
- *
88
- * @return array
89
- */
90
- public function fetchAuthToken(callable $httpHandler = null)
91
- {
92
- return $this->auth->fetchAuthToken($httpHandler);
93
- }
94
-
95
- /**
96
- * @return string
97
- */
98
- public function getCacheKey()
99
- {
100
- return $this->auth->getClientId() . ':' . $this->auth->getCacheKey();
101
- }
102
-
103
- /**
104
- * @return array
105
- */
106
- public function getLastReceivedToken()
107
- {
108
- return $this->auth->getLastReceivedToken();
109
- }
110
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/auth/src/CredentialsLoader.php DELETED
@@ -1,163 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2015 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- namespace Google\Auth;
19
-
20
- use Google\Auth\Credentials\ServiceAccountCredentials;
21
- use Google\Auth\Credentials\UserRefreshCredentials;
22
-
23
- /**
24
- * CredentialsLoader contains the behaviour used to locate and find default
25
- * credentials files on the file system.
26
- */
27
- abstract class CredentialsLoader implements FetchAuthTokenInterface
28
- {
29
- const TOKEN_CREDENTIAL_URI = 'https://www.googleapis.com/oauth2/v4/token';
30
- const ENV_VAR = 'GOOGLE_APPLICATION_CREDENTIALS';
31
- const WELL_KNOWN_PATH = 'gcloud/application_default_credentials.json';
32
- const NON_WINDOWS_WELL_KNOWN_PATH_BASE = '.config';
33
- const AUTH_METADATA_KEY = 'authorization';
34
-
35
- /**
36
- * @param string $cause
37
- * @return string
38
- */
39
- private static function unableToReadEnv($cause)
40
- {
41
- $msg = 'Unable to read the credential file specified by ';
42
- $msg .= ' GOOGLE_APPLICATION_CREDENTIALS: ';
43
- $msg .= $cause;
44
-
45
- return $msg;
46
- }
47
-
48
- /**
49
- * @return bool
50
- */
51
- private static function isOnWindows()
52
- {
53
- return strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
54
- }
55
-
56
- /**
57
- * Load a JSON key from the path specified in the environment.
58
- *
59
- * Load a JSON key from the path specified in the environment
60
- * variable GOOGLE_APPLICATION_CREDENTIALS. Return null if
61
- * GOOGLE_APPLICATION_CREDENTIALS is not specified.
62
- *
63
- * @return array JSON key | null
64
- */
65
- public static function fromEnv()
66
- {
67
- $path = getenv(self::ENV_VAR);
68
- if (empty($path)) {
69
- return;
70
- }
71
- if (!file_exists($path)) {
72
- $cause = 'file ' . $path . ' does not exist';
73
- throw new \DomainException(self::unableToReadEnv($cause));
74
- }
75
- $jsonKey = file_get_contents($path);
76
- return json_decode($jsonKey, true);
77
- }
78
-
79
- /**
80
- * Load a JSON key from a well known path.
81
- *
82
- * The well known path is OS dependent:
83
- * - windows: %APPDATA%/gcloud/application_default_credentials.json
84
- * - others: $HOME/.config/gcloud/application_default_credentials.json
85
- *
86
- * If the file does not exists, this returns null.
87
- *
88
- * @return array JSON key | null
89
- */
90
- public static function fromWellKnownFile()
91
- {
92
- $rootEnv = self::isOnWindows() ? 'APPDATA' : 'HOME';
93
- $path = [getenv($rootEnv)];
94
- if (!self::isOnWindows()) {
95
- $path[] = self::NON_WINDOWS_WELL_KNOWN_PATH_BASE;
96
- }
97
- $path[] = self::WELL_KNOWN_PATH;
98
- $path = implode(DIRECTORY_SEPARATOR, $path);
99
- if (!file_exists($path)) {
100
- return;
101
- }
102
- $jsonKey = file_get_contents($path);
103
- return json_decode($jsonKey, true);
104
- }
105
-
106
- /**
107
- * Create a new Credentials instance.
108
- *
109
- * @param string|array scope the scope of the access request, expressed
110
- * either as an Array or as a space-delimited String.
111
- * @param array $jsonKey the JSON credentials.
112
- *
113
- * @return ServiceAccountCredentials|UserRefreshCredentials
114
- */
115
- public static function makeCredentials($scope, array $jsonKey)
116
- {
117
- if (!array_key_exists('type', $jsonKey)) {
118
- throw new \InvalidArgumentException('json key is missing the type field');
119
- }
120
-
121
- if ($jsonKey['type'] == 'service_account') {
122
- return new ServiceAccountCredentials($scope, $jsonKey);
123
- } elseif ($jsonKey['type'] == 'authorized_user') {
124
- return new UserRefreshCredentials($scope, $jsonKey);
125
- } else {
126
- throw new \InvalidArgumentException('invalid value in the type field');
127
- }
128
- }
129
-
130
- /**
131
- * export a callback function which updates runtime metadata.
132
- *
133
- * @return array updateMetadata function
134
- */
135
- public function getUpdateMetadataFunc()
136
- {
137
- return array($this, 'updateMetadata');
138
- }
139
-
140
- /**
141
- * Updates metadata with the authorization token.
142
- *
143
- * @param array $metadata metadata hashmap
144
- * @param string $authUri optional auth uri
145
- * @param callable $httpHandler callback which delivers psr7 request
146
- *
147
- * @return array updated metadata hashmap
148
- */
149
- public function updateMetadata(
150
- $metadata,
151
- $authUri = null,
152
- callable $httpHandler = null
153
- ) {
154
- $result = $this->fetchAuthToken($httpHandler);
155
- if (!isset($result['access_token'])) {
156
- return $metadata;
157
- }
158
- $metadata_copy = $metadata;
159
- $metadata_copy[self::AUTH_METADATA_KEY] = array('Bearer ' . $result['access_token']);
160
-
161
- return $metadata_copy;
162
- }
163
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/auth/src/FetchAuthTokenCache.php DELETED
@@ -1,108 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2010 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- namespace Google\Auth;
19
-
20
- use Psr\Cache\CacheItemPoolInterface;
21
-
22
- /**
23
- * A class to implement caching for any object implementing
24
- * FetchAuthTokenInterface
25
- */
26
- class FetchAuthTokenCache implements FetchAuthTokenInterface
27
- {
28
- use CacheTrait;
29
-
30
- /**
31
- * @var FetchAuthTokenInterface
32
- */
33
- private $fetcher;
34
-
35
- /**
36
- * @var array
37
- */
38
- private $cacheConfig;
39
-
40
- /**
41
- * @var CacheItemPoolInterface
42
- */
43
- private $cache;
44
-
45
- public function __construct(
46
- FetchAuthTokenInterface $fetcher,
47
- array $cacheConfig = null,
48
- CacheItemPoolInterface $cache
49
- ) {
50
- $this->fetcher = $fetcher;
51
- $this->cache = $cache;
52
- $this->cacheConfig = array_merge([
53
- 'lifetime' => 1500,
54
- 'prefix' => '',
55
- ], (array) $cacheConfig);
56
- }
57
-
58
- /**
59
- * Implements FetchAuthTokenInterface#fetchAuthToken.
60
- *
61
- * Checks the cache for a valid auth token and fetches the auth tokens
62
- * from the supplied fetcher.
63
- *
64
- * @param callable $httpHandler callback which delivers psr7 request
65
- *
66
- * @return array the response
67
- *
68
- * @throws \Exception
69
- */
70
- public function fetchAuthToken(callable $httpHandler = null)
71
- {
72
- // Use the cached value if its available.
73
- //
74
- // TODO: correct caching; update the call to setCachedValue to set the expiry
75
- // to the value returned with the auth token.
76
- //
77
- // TODO: correct caching; enable the cache to be cleared.
78
- $cacheKey = $this->fetcher->getCacheKey();
79
- $cached = $this->getCachedValue($cacheKey);
80
- if (!empty($cached)) {
81
- return ['access_token' => $cached];
82
- }
83
-
84
- $auth_token = $this->fetcher->fetchAuthToken($httpHandler);
85
-
86
- if (isset($auth_token['access_token'])) {
87
- $this->setCachedValue($cacheKey, $auth_token['access_token']);
88
- }
89
-
90
- return $auth_token;
91
- }
92
-
93
- /**
94
- * @return string
95
- */
96
- public function getCacheKey()
97
- {
98
- return $this->getFullCacheKey($this->fetcher->getCacheKey());
99
- }
100
-
101
- /**
102
- * @return array|null
103
- */
104
- public function getLastReceivedToken()
105
- {
106
- return $this->fetcher->getLastReceivedToken();
107
- }
108
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/auth/src/FetchAuthTokenInterface.php DELETED
@@ -1,55 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2015 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- namespace Google\Auth;
19
-
20
- /**
21
- * An interface implemented by objects that can fetch auth tokens.
22
- */
23
- interface FetchAuthTokenInterface
24
- {
25
- /**
26
- * Fetches the auth tokens based on the current state.
27
- *
28
- * @param callable $httpHandler callback which delivers psr7 request
29
- *
30
- * @return array a hash of auth tokens
31
- */
32
- public function fetchAuthToken(callable $httpHandler = null);
33
-
34
- /**
35
- * Obtains a key that can used to cache the results of #fetchAuthToken.
36
- *
37
- * If the value is empty, the auth token is not cached.
38
- *
39
- * @return string a key that may be used to cache the auth token.
40
- */
41
- public function getCacheKey();
42
-
43
- /**
44
- * Returns an associative array with the token and
45
- * expiration time.
46
- *
47
- * @return null|array {
48
- * The last received access token.
49
- *
50
- * @var string $access_token The access token string.
51
- * @var int $expires_at The time the token expires as a UNIX timestamp.
52
- * }
53
- */
54
- public function getLastReceivedToken();
55
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/auth/src/HttpHandler/Guzzle5HttpHandler.php DELETED
@@ -1,68 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright 2015 Google Inc. All Rights Reserved.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- namespace Google\Auth\HttpHandler;
18
-
19
- use GuzzleHttp\ClientInterface;
20
- use GuzzleHttp\Psr7\Response;
21
- use Psr\Http\Message\RequestInterface;
22
- use Psr\Http\Message\ResponseInterface;
23
-
24
- class Guzzle5HttpHandler
25
- {
26
- /**
27
- * @var ClientInterface
28
- */
29
- private $client;
30
-
31
- /**
32
- * @param ClientInterface $client
33
- */
34
- public function __construct(ClientInterface $client)
35
- {
36
- $this->client = $client;
37
- }
38
-
39
- /**
40
- * Accepts a PSR-7 Request and an array of options and returns a PSR-7 response.
41
- *
42
- * @param RequestInterface $request
43
- * @param array $options
44
- *
45
- * @return ResponseInterface
46
- */
47
- public function __invoke(RequestInterface $request, array $options = [])
48
- {
49
- $request = $this->client->createRequest(
50
- $request->getMethod(),
51
- $request->getUri(),
52
- array_merge([
53
- 'headers' => $request->getHeaders(),
54
- 'body' => $request->getBody(),
55
- ], $options)
56
- );
57
-
58
- $response = $this->client->send($request);
59
-
60
- return new Response(
61
- $response->getStatusCode(),
62
- $response->getHeaders() ?: [],
63
- $response->getBody(),
64
- $response->getProtocolVersion(),
65
- $response->getReasonPhrase()
66
- );
67
- }
68
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/auth/src/HttpHandler/Guzzle6HttpHandler.php DELETED
@@ -1,36 +0,0 @@
1
- <?php
2
-
3
- namespace Google\Auth\HttpHandler;
4
-
5
- use GuzzleHttp\ClientInterface;
6
- use Psr\Http\Message\RequestInterface;
7
- use Psr\Http\Message\ResponseInterface;
8
-
9
- class Guzzle6HttpHandler
10
- {
11
- /**
12
- * @var ClientInterface
13
- */
14
- private $client;
15
-
16
- /**
17
- * @param ClientInterface $client
18
- */
19
- public function __construct(ClientInterface $client)
20
- {
21
- $this->client = $client;
22
- }
23
-
24
- /**
25
- * Accepts a PSR-7 request and an array of options and returns a PSR-7 response.
26
- *
27
- * @param RequestInterface $request
28
- * @param array $options
29
- *
30
- * @return ResponseInterface
31
- */
32
- public function __invoke(RequestInterface $request, array $options = [])
33
- {
34
- return $this->client->send($request, $options);
35
- }
36
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/auth/src/HttpHandler/HttpHandlerFactory.php DELETED
@@ -1,47 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright 2015 Google Inc. All Rights Reserved.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- namespace Google\Auth\HttpHandler;
18
-
19
- use GuzzleHttp\Client;
20
- use GuzzleHttp\ClientInterface;
21
-
22
- class HttpHandlerFactory
23
- {
24
- /**
25
- * Builds out a default http handler for the installed version of guzzle.
26
- *
27
- * @param ClientInterface $client
28
- *
29
- * @return Guzzle5HttpHandler|Guzzle6HttpHandler
30
- *
31
- * @throws \Exception
32
- */
33
- public static function build(ClientInterface $client = null)
34
- {
35
- $version = ClientInterface::VERSION;
36
- $client = $client ?: new Client();
37
-
38
- switch ($version[0]) {
39
- case '5':
40
- return new Guzzle5HttpHandler($client);
41
- case '6':
42
- return new Guzzle6HttpHandler($client);
43
- default:
44
- throw new \Exception('Version not supported');
45
- }
46
- }
47
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/auth/src/Middleware/AuthTokenMiddleware.php DELETED
@@ -1,126 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2015 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- namespace Google\Auth\Middleware;
19
-
20
- use Google\Auth\FetchAuthTokenInterface;
21
- use Psr\Http\Message\RequestInterface;
22
-
23
- /**
24
- * AuthTokenMiddleware is a Guzzle Middleware that adds an Authorization header
25
- * provided by an object implementing FetchAuthTokenInterface.
26
- *
27
- * The FetchAuthTokenInterface#fetchAuthToken is used to obtain a hash; one of
28
- * the values value in that hash is added as the authorization header.
29
- *
30
- * Requests will be accessed with the authorization header:
31
- *
32
- * 'authorization' 'Bearer <value of auth_token>'
33
- */
34
- class AuthTokenMiddleware
35
- {
36
- /**
37
- * @var callback
38
- */
39
- private $httpHandler;
40
-
41
- /**
42
- * @var FetchAuthTokenInterface
43
- */
44
- private $fetcher;
45
-
46
- /**
47
- * @var callable
48
- */
49
- private $tokenCallback;
50
-
51
- /**
52
- * Creates a new AuthTokenMiddleware.
53
- *
54
- * @param FetchAuthTokenInterface $fetcher is used to fetch the auth token
55
- * @param callable $httpHandler (optional) callback which delivers psr7 request
56
- * @param callable $tokenCallback (optional) function to be called when a new token is fetched.
57
- */
58
- public function __construct(
59
- FetchAuthTokenInterface $fetcher,
60
- callable $httpHandler = null,
61
- callable $tokenCallback = null
62
- ) {
63
- $this->fetcher = $fetcher;
64
- $this->httpHandler = $httpHandler;
65
- $this->tokenCallback = $tokenCallback;
66
- }
67
-
68
- /**
69
- * Updates the request with an Authorization header when auth is 'google_auth'.
70
- *
71
- * use Google\Auth\Middleware\AuthTokenMiddleware;
72
- * use Google\Auth\OAuth2;
73
- * use GuzzleHttp\Client;
74
- * use GuzzleHttp\HandlerStack;
75
- *
76
- * $config = [..<oauth config param>.];
77
- * $oauth2 = new OAuth2($config)
78
- * $middleware = new AuthTokenMiddleware($oauth2);
79
- * $stack = HandlerStack::create();
80
- * $stack->push($middleware);
81
- *
82
- * $client = new Client([
83
- * 'handler' => $stack,
84
- * 'base_uri' => 'https://www.googleapis.com/taskqueue/v1beta2/projects/',
85
- * 'auth' => 'google_auth' // authorize all requests
86
- * ]);
87
- *
88
- * $res = $client->get('myproject/taskqueues/myqueue');
89
- *
90
- * @param callable $handler
91
- *
92
- * @return \Closure
93
- */
94
- public function __invoke(callable $handler)
95
- {
96
- return function (RequestInterface $request, array $options) use ($handler) {
97
- // Requests using "auth"="google_auth" will be authorized.
98
- if (!isset($options['auth']) || $options['auth'] !== 'google_auth') {
99
- return $handler($request, $options);
100
- }
101
-
102
- $request = $request->withHeader('authorization', 'Bearer ' . $this->fetchToken());
103
-
104
- return $handler($request, $options);
105
- };
106
- }
107
-
108
- /**
109
- * Call fetcher to fetch the token.
110
- *
111
- * @return string
112
- */
113
- private function fetchToken()
114
- {
115
- $auth_tokens = $this->fetcher->fetchAuthToken($this->httpHandler);
116
-
117
- if (array_key_exists('access_token', $auth_tokens)) {
118
- // notify the callback if applicable
119
- if ($this->tokenCallback) {
120
- call_user_func($this->tokenCallback, $this->fetcher->getCacheKey(), $auth_tokens['access_token']);
121
- }
122
-
123
- return $auth_tokens['access_token'];
124
- }
125
- }
126
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/auth/src/Middleware/ScopedAccessTokenMiddleware.php DELETED
@@ -1,175 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2015 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- namespace Google\Auth\Middleware;
19
-
20
- use Google\Auth\CacheTrait;
21
- use Psr\Cache\CacheItemPoolInterface;
22
- use Psr\Http\Message\RequestInterface;
23
-
24
- /**
25
- * ScopedAccessTokenMiddleware is a Guzzle Middleware that adds an Authorization
26
- * header provided by a closure.
27
- *
28
- * The closure returns an access token, taking the scope, either a single
29
- * string or an array of strings, as its value. If provided, a cache will be
30
- * used to preserve the access token for a given lifetime.
31
- *
32
- * Requests will be accessed with the authorization header:
33
- *
34
- * 'authorization' 'Bearer <value of auth_token>'
35
- */
36
- class ScopedAccessTokenMiddleware
37
- {
38
- use CacheTrait;
39
-
40
- const DEFAULT_CACHE_LIFETIME = 1500;
41
-
42
- /**
43
- * @var CacheItemPoolInterface
44
- */
45
- private $cache;
46
-
47
- /**
48
- * @var array configuration
49
- */
50
- private $cacheConfig;
51
-
52
- /**
53
- * @var callable
54
- */
55
- private $tokenFunc;
56
-
57
- /**
58
- * @var array|string
59
- */
60
- private $scopes;
61
-
62
- /**
63
- * Creates a new ScopedAccessTokenMiddleware.
64
- *
65
- * @param callable $tokenFunc a token generator function
66
- * @param array|string $scopes the token authentication scopes
67
- * @param array $cacheConfig configuration for the cache when it's present
68
- * @param CacheItemPoolInterface $cache an implementation of CacheItemPoolInterface
69
- */
70
- public function __construct(
71
- callable $tokenFunc,
72
- $scopes,
73
- array $cacheConfig = null,
74
- CacheItemPoolInterface $cache = null
75
- ) {
76
- $this->tokenFunc = $tokenFunc;
77
- if (!(is_string($scopes) || is_array($scopes))) {
78
- throw new \InvalidArgumentException(
79
- 'wants scope should be string or array');
80
- }
81
- $this->scopes = $scopes;
82
-
83
- if (!is_null($cache)) {
84
- $this->cache = $cache;
85
- $this->cacheConfig = array_merge([
86
- 'lifetime' => self::DEFAULT_CACHE_LIFETIME,
87
- 'prefix' => '',
88
- ], $cacheConfig);
89
- }
90
- }
91
-
92
- /**
93
- * Updates the request with an Authorization header when auth is 'scoped'.
94
- *
95
- * E.g this could be used to authenticate using the AppEngine
96
- * AppIdentityService.
97
- *
98
- * use google\appengine\api\app_identity\AppIdentityService;
99
- * use Google\Auth\Middleware\ScopedAccessTokenMiddleware;
100
- * use GuzzleHttp\Client;
101
- * use GuzzleHttp\HandlerStack;
102
- *
103
- * $scope = 'https://www.googleapis.com/auth/taskqueue'
104
- * $middleware = new ScopedAccessTokenMiddleware(
105
- * 'AppIdentityService::getAccessToken',
106
- * $scope,
107
- * [ 'prefix' => 'Google\Auth\ScopedAccessToken::' ],
108
- * $cache = new Memcache()
109
- * );
110
- * $stack = HandlerStack::create();
111
- * $stack->push($middleware);
112
- *
113
- * $client = new Client([
114
- * 'handler' => $stack,
115
- * 'base_url' => 'https://www.googleapis.com/taskqueue/v1beta2/projects/',
116
- * 'auth' => 'google_auth' // authorize all requests
117
- * ]);
118
- *
119
- * $res = $client->get('myproject/taskqueues/myqueue');
120
- *
121
- * @param callable $handler
122
- *
123
- * @return \Closure
124
- */
125
- public function __invoke(callable $handler)
126
- {
127
- return function (RequestInterface $request, array $options) use ($handler) {
128
- // Requests using "auth"="scoped" will be authorized.
129
- if (!isset($options['auth']) || $options['auth'] !== 'scoped') {
130
- return $handler($request, $options);
131
- }
132
-
133
- $request = $request->withHeader('authorization', 'Bearer ' . $this->fetchToken());
134
-
135
- return $handler($request, $options);
136
- };
137
- }
138
-
139
- /**
140
- * @return string
141
- */
142
- private function getCacheKey()
143
- {
144
- $key = null;
145
-
146
- if (is_string($this->scopes)) {
147
- $key .= $this->scopes;
148
- } elseif (is_array($this->scopes)) {
149
- $key .= implode(':', $this->scopes);
150
- }
151
-
152
- return $key;
153
- }
154
-
155
- /**
156
- * Determine if token is available in the cache, if not call tokenFunc to
157
- * fetch it.
158
- *
159
- * @return string
160
- */
161
- private function fetchToken()
162
- {
163
- $cacheKey = $this->getCacheKey();
164
- $cached = $this->getCachedValue($cacheKey);
165
-
166
- if (!empty($cached)) {
167
- return $cached;
168
- }
169
-
170
- $token = call_user_func($this->tokenFunc, $this->scopes);
171
- $this->setCachedValue($cacheKey, $token);
172
-
173
- return $token;
174
- }
175
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/auth/src/Middleware/SimpleMiddleware.php DELETED
@@ -1,93 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2015 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- namespace Google\Auth\Middleware;
19
-
20
- use GuzzleHttp\Psr7;
21
- use Psr\Http\Message\RequestInterface;
22
-
23
- /**
24
- * SimpleMiddleware is a Guzzle Middleware that implements Google's Simple API
25
- * access.
26
- *
27
- * Requests are accessed using the Simple API access developer key.
28
- */
29
- class SimpleMiddleware
30
- {
31
- /**
32
- * @var array
33
- */
34
- private $config;
35
-
36
- /**
37
- * Create a new Simple plugin.
38
- *
39
- * The configuration array expects one option
40
- * - key: required, otherwise InvalidArgumentException is thrown
41
- *
42
- * @param array $config Configuration array
43
- */
44
- public function __construct(array $config)
45
- {
46
- if (!isset($config['key'])) {
47
- throw new \InvalidArgumentException('requires a key to have been set');
48
- }
49
-
50
- $this->config = array_merge(['key' => null], $config);
51
- }
52
-
53
- /**
54
- * Updates the request query with the developer key if auth is set to simple.
55
- *
56
- * use Google\Auth\Middleware\SimpleMiddleware;
57
- * use GuzzleHttp\Client;
58
- * use GuzzleHttp\HandlerStack;
59
- *
60
- * $my_key = 'is not the same as yours';
61
- * $middleware = new SimpleMiddleware(['key' => $my_key]);
62
- * $stack = HandlerStack::create();
63
- * $stack->push($middleware);
64
- *
65
- * $client = new Client([
66
- * 'handler' => $stack,
67
- * 'base_uri' => 'https://www.googleapis.com/discovery/v1/',
68
- * 'auth' => 'simple'
69
- * ]);
70
- *
71
- * $res = $client->get('drive/v2/rest');
72
- *
73
- * @param callable $handler
74
- *
75
- * @return \Closure
76
- */
77
- public function __invoke(callable $handler)
78
- {
79
- return function (RequestInterface $request, array $options) use ($handler) {
80
- // Requests using "auth"="scoped" will be authorized.
81
- if (!isset($options['auth']) || $options['auth'] !== 'simple') {
82
- return $handler($request, $options);
83
- }
84
-
85
- $query = Psr7\parse_query($request->getUri()->getQuery());
86
- $params = array_merge($query, $this->config);
87
- $uri = $request->getUri()->withQuery(Psr7\build_query($params));
88
- $request = $request->withUri($uri);
89
-
90
- return $handler($request, $options);
91
- };
92
- }
93
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/auth/src/OAuth2.php DELETED
@@ -1,1306 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2015 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- namespace Google\Auth;
19
-
20
- use Google\Auth\HttpHandler\HttpHandlerFactory;
21
- use GuzzleHttp\Psr7;
22
- use GuzzleHttp\Psr7\Request;
23
- use InvalidArgumentException;
24
- use Psr\Http\Message\RequestInterface;
25
- use Psr\Http\Message\ResponseInterface;
26
- use Psr\Http\Message\UriInterface;
27
-
28
- /**
29
- * OAuth2 supports authentication by OAuth2 2-legged flows.
30
- *
31
- * It primary supports
32
- * - service account authorization
33
- * - authorization where a user already has an access token
34
- */
35
- class OAuth2 implements FetchAuthTokenInterface
36
- {
37
- const DEFAULT_EXPIRY_SECONDS = 3600; // 1 hour
38
- const DEFAULT_SKEW_SECONDS = 60; // 1 minute
39
- const JWT_URN = 'urn:ietf:params:oauth:grant-type:jwt-bearer';
40
-
41
- /**
42
- * TODO: determine known methods from the keys of JWT::methods.
43
- */
44
- public static $knownSigningAlgorithms = array(
45
- 'HS256',
46
- 'HS512',
47
- 'HS384',
48
- 'RS256',
49
- );
50
-
51
- /**
52
- * The well known grant types.
53
- *
54
- * @var array
55
- */
56
- public static $knownGrantTypes = array(
57
- 'authorization_code',
58
- 'refresh_token',
59
- 'password',
60
- 'client_credentials',
61
- );
62
-
63
- /**
64
- * - authorizationUri
65
- * The authorization server's HTTP endpoint capable of
66
- * authenticating the end-user and obtaining authorization.
67
- *
68
- * @var UriInterface
69
- */
70
- private $authorizationUri;
71
-
72
- /**
73
- * - tokenCredentialUri
74
- * The authorization server's HTTP endpoint capable of issuing
75
- * tokens and refreshing expired tokens.
76
- *
77
- * @var UriInterface
78
- */
79
- private $tokenCredentialUri;
80
-
81
- /**
82
- * The redirection URI used in the initial request.
83
- *
84
- * @var string
85
- */
86
- private $redirectUri;
87
-
88
- /**
89
- * A unique identifier issued to the client to identify itself to the
90
- * authorization server.
91
- *
92
- * @var string
93
- */
94
- private $clientId;
95
-
96
- /**
97
- * A shared symmetric secret issued by the authorization server, which is
98
- * used to authenticate the client.
99
- *
100
- * @var string
101
- */
102
- private $clientSecret;
103
-
104
- /**
105
- * The resource owner's username.
106
- *
107
- * @var string
108
- */
109
- private $username;
110
-
111
- /**
112
- * The resource owner's password.
113
- *
114
- * @var string
115
- */
116
- private $password;
117
-
118
- /**
119
- * The scope of the access request, expressed either as an Array or as a
120
- * space-delimited string.
121
- *
122
- * @var string
123
- */
124
- private $scope;
125
-
126
- /**
127
- * An arbitrary string designed to allow the client to maintain state.
128
- *
129
- * @var string
130
- */
131
- private $state;
132
-
133
- /**
134
- * The authorization code issued to this client.
135
- *
136
- * Only used by the authorization code access grant type.
137
- *
138
- * @var string
139
- */
140
- private $code;
141
-
142
- /**
143
- * The issuer ID when using assertion profile.
144
- *
145
- * @var string
146
- */
147
- private $issuer;
148
-
149
- /**
150
- * The target audience for assertions.
151
- *
152
- * @var string
153
- */
154
- private $audience;
155
-
156
- /**
157
- * The target sub when issuing assertions.
158
- *
159
- * @var string
160
- */
161
- private $sub;
162
-
163
- /**
164
- * The number of seconds assertions are valid for.
165
- *
166
- * @var int
167
- */
168
- private $expiry;
169
-
170
- /**
171
- * The signing key when using assertion profile.
172
- *
173
- * @var string
174
- */
175
- private $signingKey;
176
-
177
- /**
178
- * The signing algorithm when using an assertion profile.
179
- *
180
- * @var string
181
- */
182
- private $signingAlgorithm;
183
-
184
- /**
185
- * The refresh token associated with the access token to be refreshed.
186
- *
187
- * @var string
188
- */
189
- private $refreshToken;
190
-
191
- /**
192
- * The current access token.
193
- *
194
- * @var string
195
- */
196
- private $accessToken;
197
-
198
- /**
199
- * The current ID token.
200
- *
201
- * @var string
202
- */
203
- private $idToken;
204
-
205
- /**
206
- * The lifetime in seconds of the current access token.
207
- *
208
- * @var int
209
- */
210
- private $expiresIn;
211
-
212
- /**
213
- * The expiration time of the access token as a number of seconds since the
214
- * unix epoch.
215
- *
216
- * @var int
217
- */
218
- private $expiresAt;
219
-
220
- /**
221
- * The issue time of the access token as a number of seconds since the unix
222
- * epoch.
223
- *
224
- * @var int
225
- */
226
- private $issuedAt;
227
-
228
- /**
229
- * The current grant type.
230
- *
231
- * @var string
232
- */
233
- private $grantType;
234
-
235
- /**
236
- * When using an extension grant type, this is the set of parameters used by
237
- * that extension.
238
- */
239
- private $extensionParams;
240
-
241
- /**
242
- * Create a new OAuthCredentials.
243
- *
244
- * The configuration array accepts various options
245
- *
246
- * - authorizationUri
247
- * The authorization server's HTTP endpoint capable of
248
- * authenticating the end-user and obtaining authorization.
249
- *
250
- * - tokenCredentialUri
251
- * The authorization server's HTTP endpoint capable of issuing
252
- * tokens and refreshing expired tokens.
253
- *
254
- * - clientId
255
- * A unique identifier issued to the client to identify itself to the
256
- * authorization server.
257
- *
258
- * - clientSecret
259
- * A shared symmetric secret issued by the authorization server,
260
- * which is used to authenticate the client.
261
- *
262
- * - scope
263
- * The scope of the access request, expressed either as an Array
264
- * or as a space-delimited String.
265
- *
266
- * - state
267
- * An arbitrary string designed to allow the client to maintain state.
268
- *
269
- * - redirectUri
270
- * The redirection URI used in the initial request.
271
- *
272
- * - username
273
- * The resource owner's username.
274
- *
275
- * - password
276
- * The resource owner's password.
277
- *
278
- * - issuer
279
- * Issuer ID when using assertion profile
280
- *
281
- * - audience
282
- * Target audience for assertions
283
- *
284
- * - expiry
285
- * Number of seconds assertions are valid for
286
- *
287
- * - signingKey
288
- * Signing key when using assertion profile
289
- *
290
- * - refreshToken
291
- * The refresh token associated with the access token
292
- * to be refreshed.
293
- *
294
- * - accessToken
295
- * The current access token for this client.
296
- *
297
- * - idToken
298
- * The current ID token for this client.
299
- *
300
- * - extensionParams
301
- * When using an extension grant type, this is the set of parameters used
302
- * by that extension.
303
- *
304
- * @param array $config Configuration array
305
- */
306
- public function __construct(array $config)
307
- {
308
- $opts = array_merge([
309
- 'expiry' => self::DEFAULT_EXPIRY_SECONDS,
310
- 'extensionParams' => [],
311
- 'authorizationUri' => null,
312
- 'redirectUri' => null,
313
- 'tokenCredentialUri' => null,
314
- 'state' => null,
315
- 'username' => null,
316
- 'password' => null,
317
- 'clientId' => null,
318
- 'clientSecret' => null,
319
- 'issuer' => null,
320
- 'sub' => null,
321
- 'audience' => null,
322
- 'signingKey' => null,
323
- 'signingAlgorithm' => null,
324
- 'scope' => null,
325
- ], $config);
326
-
327
- $this->setAuthorizationUri($opts['authorizationUri']);
328
- $this->setRedirectUri($opts['redirectUri']);
329
- $this->setTokenCredentialUri($opts['tokenCredentialUri']);
330
- $this->setState($opts['state']);
331
- $this->setUsername($opts['username']);
332
- $this->setPassword($opts['password']);
333
- $this->setClientId($opts['clientId']);
334
- $this->setClientSecret($opts['clientSecret']);
335
- $this->setIssuer($opts['issuer']);
336
- $this->setSub($opts['sub']);
337
- $this->setExpiry($opts['expiry']);
338
- $this->setAudience($opts['audience']);
339
- $this->setSigningKey($opts['signingKey']);
340
- $this->setSigningAlgorithm($opts['signingAlgorithm']);
341
- $this->setScope($opts['scope']);
342
- $this->setExtensionParams($opts['extensionParams']);
343
- $this->updateToken($opts);
344
- }
345
-
346
- /**
347
- * Verifies the idToken if present.
348
- *
349
- * - if none is present, return null
350
- * - if present, but invalid, raises DomainException.
351
- * - otherwise returns the payload in the idtoken as a PHP object.
352
- *
353
- * if $publicKey is null, the key is decoded without being verified.
354
- *
355
- * @param string $publicKey The public key to use to authenticate the token
356
- * @param array $allowed_algs List of supported verification algorithms
357
- *
358
- * @return null|object
359
- */
360
- public function verifyIdToken($publicKey = null, $allowed_algs = array())
361
- {
362
- $idToken = $this->getIdToken();
363
- if (is_null($idToken)) {
364
- return null;
365
- }
366
-
367
- $resp = $this->jwtDecode($idToken, $publicKey, $allowed_algs);
368
- if (!property_exists($resp, 'aud')) {
369
- throw new \DomainException('No audience found the id token');
370
- }
371
- if ($resp->aud != $this->getAudience()) {
372
- throw new \DomainException('Wrong audience present in the id token');
373
- }
374
-
375
- return $resp;
376
- }
377
-
378
- /**
379
- * Obtains the encoded jwt from the instance data.
380
- *
381
- * @param array $config array optional configuration parameters
382
- *
383
- * @return string
384
- */
385
- public function toJwt(array $config = [])
386
- {
387
- if (is_null($this->getSigningKey())) {
388
- throw new \DomainException('No signing key available');
389
- }
390
- if (is_null($this->getSigningAlgorithm())) {
391
- throw new \DomainException('No signing algorithm specified');
392
- }
393
- $now = time();
394
-
395
- $opts = array_merge([
396
- 'skew' => self::DEFAULT_SKEW_SECONDS,
397
- ], $config);
398
-
399
- $assertion = [
400
- 'iss' => $this->getIssuer(),
401
- 'aud' => $this->getAudience(),
402
- 'exp' => ($now + $this->getExpiry()),
403
- 'iat' => ($now - $opts['skew']),
404
- ];
405
- foreach ($assertion as $k => $v) {
406
- if (is_null($v)) {
407
- throw new \DomainException($k . ' should not be null');
408
- }
409
- }
410
- if (!(is_null($this->getScope()))) {
411
- $assertion['scope'] = $this->getScope();
412
- }
413
- if (!(is_null($this->getSub()))) {
414
- $assertion['sub'] = $this->getSub();
415
- }
416
-
417
- return $this->jwtEncode($assertion, $this->getSigningKey(),
418
- $this->getSigningAlgorithm());
419
- }
420
-
421
- /**
422
- * Generates a request for token credentials.
423
- *
424
- * @return RequestInterface the authorization Url.
425
- */
426
- public function generateCredentialsRequest()
427
- {
428
- $uri = $this->getTokenCredentialUri();
429
- if (is_null($uri)) {
430
- throw new \DomainException('No token credential URI was set.');
431
- }
432
-
433
- $grantType = $this->getGrantType();
434
- $params = array('grant_type' => $grantType);
435
- switch ($grantType) {
436
- case 'authorization_code':
437
- $params['code'] = $this->getCode();
438
- $params['redirect_uri'] = $this->getRedirectUri();
439
- $this->addClientCredentials($params);
440
- break;
441
- case 'password':
442
- $params['username'] = $this->getUsername();
443
- $params['password'] = $this->getPassword();
444
- $this->addClientCredentials($params);
445
- break;
446
- case 'refresh_token':
447
- $params['refresh_token'] = $this->getRefreshToken();
448
- $this->addClientCredentials($params);
449
- break;
450
- case self::JWT_URN:
451
- $params['assertion'] = $this->toJwt();
452
- break;
453
- default:
454
- if (!is_null($this->getRedirectUri())) {
455
- # Grant type was supposed to be 'authorization_code', as there
456
- # is a redirect URI.
457
- throw new \DomainException('Missing authorization code');
458
- }
459
- unset($params['grant_type']);
460
- if (!is_null($grantType)) {
461
- $params['grant_type'] = $grantType;
462
- }
463
- $params = array_merge($params, $this->getExtensionParams());
464
- }
465
-
466
- $headers = [
467
- 'Cache-Control' => 'no-store',
468
- 'Content-Type' => 'application/x-www-form-urlencoded',
469
- ];
470
-
471
- return new Request(
472
- 'POST',
473
- $uri,
474
- $headers,
475
- Psr7\build_query($params)
476
- );
477
- }
478
-
479
- /**
480
- * Fetches the auth tokens based on the current state.
481
- *
482
- * @param callable $httpHandler callback which delivers psr7 request
483
- *
484
- * @return array the response
485
- */
486
- public function fetchAuthToken(callable $httpHandler = null)
487
- {
488
- if (is_null($httpHandler)) {
489
- $httpHandler = HttpHandlerFactory::build();
490
- }
491
-
492
- $response = $httpHandler($this->generateCredentialsRequest());
493
- $credentials = $this->parseTokenResponse($response);
494
- $this->updateToken($credentials);
495
-
496
- return $credentials;
497
- }
498
-
499
- /**
500
- * Obtains a key that can used to cache the results of #fetchAuthToken.
501
- *
502
- * The key is derived from the scopes.
503
- *
504
- * @return string a key that may be used to cache the auth token.
505
- */
506
- public function getCacheKey()
507
- {
508
- if (is_string($this->scope)) {
509
- return $this->scope;
510
- } elseif (is_array($this->scope)) {
511
- return implode(':', $this->scope);
512
- }
513
-
514
- // If scope has not set, return null to indicate no caching.
515
- return null;
516
- }
517
-
518
- /**
519
- * Parses the fetched tokens.
520
- *
521
- * @param ResponseInterface $resp the response.
522
- *
523
- * @return array the tokens parsed from the response body.
524
- *
525
- * @throws \Exception
526
- */
527
- public function parseTokenResponse(ResponseInterface $resp)
528
- {
529
- $body = (string)$resp->getBody();
530
- if ($resp->hasHeader('Content-Type') &&
531
- $resp->getHeaderLine('Content-Type') == 'application/x-www-form-urlencoded'
532
- ) {
533
- $res = array();
534
- parse_str($body, $res);
535
-
536
- return $res;
537
- } else {
538
- // Assume it's JSON; if it's not throw an exception
539
- if (null === $res = json_decode($body, true)) {
540
- throw new \Exception('Invalid JSON response');
541
- }
542
-
543
- return $res;
544
- }
545
- }
546
-
547
- /**
548
- * Updates an OAuth 2.0 client.
549
- *
550
- * @example
551
- * client.updateToken([
552
- * 'refresh_token' => 'n4E9O119d',
553
- * 'access_token' => 'FJQbwq9',
554
- * 'expires_in' => 3600
555
- * ])
556
- *
557
- * @param array $config
558
- * The configuration parameters related to the token.
559
- *
560
- * - refresh_token
561
- * The refresh token associated with the access token
562
- * to be refreshed.
563
- *
564
- * - access_token
565
- * The current access token for this client.
566
- *
567
- * - id_token
568
- * The current ID token for this client.
569
- *
570
- * - expires_in
571
- * The time in seconds until access token expiration.
572
- *
573
- * - expires_at
574
- * The time as an integer number of seconds since the Epoch
575
- *
576
- * - issued_at
577
- * The timestamp that the token was issued at.
578
- */
579
- public function updateToken(array $config)
580
- {
581
- $opts = array_merge([
582
- 'extensionParams' => [],
583
- 'access_token' => null,
584
- 'id_token' => null,
585
- 'expires_in' => null,
586
- 'expires_at' => null,
587
- 'issued_at' => null,
588
- ], $config);
589
-
590
- $this->setExpiresAt($opts['expires_at']);
591
- $this->setExpiresIn($opts['expires_in']);
592
- // By default, the token is issued at `Time.now` when `expiresIn` is set,
593
- // but this can be used to supply a more precise time.
594
- if (!is_null($opts['issued_at'])) {
595
- $this->setIssuedAt($opts['issued_at']);
596
- }
597
-
598
- $this->setAccessToken($opts['access_token']);
599
- $this->setIdToken($opts['id_token']);
600
- // The refresh token should only be updated if a value is explicitly
601
- // passed in, as some access token responses do not include a refresh
602
- // token.
603
- if (array_key_exists('refresh_token', $opts)) {
604
- $this->setRefreshToken($opts['refresh_token']);
605
- }
606
- }
607
-
608
- /**
609
- * Builds the authorization Uri that the user should be redirected to.
610
- *
611
- * @param array $config configuration options that customize the return url
612
- *
613
- * @return UriInterface the authorization Url.
614
- *
615
- * @throws InvalidArgumentException
616
- */
617
- public function buildFullAuthorizationUri(array $config = [])
618
- {
619
- if (is_null($this->getAuthorizationUri())) {
620
- throw new InvalidArgumentException(
621
- 'requires an authorizationUri to have been set');
622
- }
623
-
624
- $params = array_merge([
625
- 'response_type' => 'code',
626
- 'access_type' => 'offline',
627
- 'client_id' => $this->clientId,
628
- 'redirect_uri' => $this->redirectUri,
629
- 'state' => $this->state,
630
- 'scope' => $this->getScope(),
631
- ], $config);
632
-
633
- // Validate the auth_params
634
- if (is_null($params['client_id'])) {
635
- throw new InvalidArgumentException(
636
- 'missing the required client identifier');
637
- }
638
- if (is_null($params['redirect_uri'])) {
639
- throw new InvalidArgumentException('missing the required redirect URI');
640
- }
641
- if (!empty($params['prompt']) && !empty($params['approval_prompt'])) {
642
- throw new InvalidArgumentException(
643
- 'prompt and approval_prompt are mutually exclusive');
644
- }
645
-
646
- // Construct the uri object; return it if it is valid.
647
- $result = clone $this->authorizationUri;
648
- $existingParams = Psr7\parse_query($result->getQuery());
649
-
650
- $result = $result->withQuery(
651
- Psr7\build_query(array_merge($existingParams, $params))
652
- );
653
-
654
- if ($result->getScheme() != 'https') {
655
- throw new InvalidArgumentException(
656
- 'Authorization endpoint must be protected by TLS');
657
- }
658
-
659
- return $result;
660
- }
661
-
662
- /**
663
- * Sets the authorization server's HTTP endpoint capable of authenticating
664
- * the end-user and obtaining authorization.
665
- *
666
- * @param string $uri
667
- */
668
- public function setAuthorizationUri($uri)
669
- {
670
- $this->authorizationUri = $this->coerceUri($uri);
671
- }
672
-
673
- /**
674
- * Gets the authorization server's HTTP endpoint capable of authenticating
675
- * the end-user and obtaining authorization.
676
- *
677
- * @return UriInterface
678
- */
679
- public function getAuthorizationUri()
680
- {
681
- return $this->authorizationUri;
682
- }
683
-
684
- /**
685
- * Gets the authorization server's HTTP endpoint capable of issuing tokens
686
- * and refreshing expired tokens.
687
- *
688
- * @return string
689
- */
690
- public function getTokenCredentialUri()
691
- {
692
- return $this->tokenCredentialUri;
693
- }
694
-
695
- /**
696
- * Sets the authorization server's HTTP endpoint capable of issuing tokens
697
- * and refreshing expired tokens.
698
- *
699
- * @param string $uri
700
- */
701
- public function setTokenCredentialUri($uri)
702
- {
703
- $this->tokenCredentialUri = $this->coerceUri($uri);
704
- }
705
-
706
- /**
707
- * Gets the redirection URI used in the initial request.
708
- *
709
- * @return string
710
- */
711
- public function getRedirectUri()
712
- {
713
- return $this->redirectUri;
714
- }
715
-
716
- /**
717
- * Sets the redirection URI used in the initial request.
718
- *
719
- * @param string $uri
720
- */
721
- public function setRedirectUri($uri)
722
- {
723
- if (is_null($uri)) {
724
- $this->redirectUri = null;
725
-
726
- return;
727
- }
728
- // redirect URI must be absolute
729
- if (!$this->isAbsoluteUri($uri)) {
730
- // "postmessage" is a reserved URI string in Google-land
731
- // @see https://developers.google.com/identity/sign-in/web/server-side-flow
732
- if ('postmessage' !== (string)$uri) {
733
- throw new InvalidArgumentException(
734
- 'Redirect URI must be absolute');
735
- }
736
- }
737
- $this->redirectUri = (string)$uri;
738
- }
739
-
740
- /**
741
- * Gets the scope of the access requests as a space-delimited String.
742
- *
743
- * @return string
744
- */
745
- public function getScope()
746
- {
747
- if (is_null($this->scope)) {
748
- return $this->scope;
749
- }
750
-
751
- return implode(' ', $this->scope);
752
- }
753
-
754
- /**
755
- * Sets the scope of the access request, expressed either as an Array or as
756
- * a space-delimited String.
757
- *
758
- * @param string|array $scope
759
- *
760
- * @throws InvalidArgumentException
761
- */
762
- public function setScope($scope)
763
- {
764
- if (is_null($scope)) {
765
- $this->scope = null;
766
- } elseif (is_string($scope)) {
767
- $this->scope = explode(' ', $scope);
768
- } elseif (is_array($scope)) {
769
- foreach ($scope as $s) {
770
- $pos = strpos($s, ' ');
771
- if ($pos !== false) {
772
- throw new InvalidArgumentException(
773
- 'array scope values should not contain spaces');
774
- }
775
- }
776
- $this->scope = $scope;
777
- } else {
778
- throw new InvalidArgumentException(
779
- 'scopes should be a string or array of strings');
780
- }
781
- }
782
-
783
- /**
784
- * Gets the current grant type.
785
- *
786
- * @return string
787
- */
788
- public function getGrantType()
789
- {
790
- if (!is_null($this->grantType)) {
791
- return $this->grantType;
792
- }
793
-
794
- // Returns the inferred grant type, based on the current object instance
795
- // state.
796
- if (!is_null($this->code)) {
797
- return 'authorization_code';
798
- } elseif (!is_null($this->refreshToken)) {
799
- return 'refresh_token';
800
- } elseif (!is_null($this->username) && !is_null($this->password)) {
801
- return 'password';
802
- } elseif (!is_null($this->issuer) && !is_null($this->signingKey)) {
803
- return self::JWT_URN;
804
- } else {
805
- return null;
806
- }
807
- }
808
-
809
- /**
810
- * Sets the current grant type.
811
- *
812
- * @param $grantType
813
- *
814
- * @throws InvalidArgumentException
815
- */
816
- public function setGrantType($grantType)
817
- {
818
- if (in_array($grantType, self::$knownGrantTypes)) {
819
- $this->grantType = $grantType;
820
- } else {
821
- // validate URI
822
- if (!$this->isAbsoluteUri($grantType)) {
823
- throw new InvalidArgumentException(
824
- 'invalid grant type');
825
- }
826
- $this->grantType = (string)$grantType;
827
- }
828
- }
829
-
830
- /**
831
- * Gets an arbitrary string designed to allow the client to maintain state.
832
- *
833
- * @return string
834
- */
835
- public function getState()
836
- {
837
- return $this->state;
838
- }
839
-
840
- /**
841
- * Sets an arbitrary string designed to allow the client to maintain state.
842
- *
843
- * @param string $state
844
- */
845
- public function setState($state)
846
- {
847
- $this->state = $state;
848
- }
849
-
850
- /**
851
- * Gets the authorization code issued to this client.
852
- */
853
- public function getCode()
854
- {
855
- return $this->code;
856
- }
857
-
858
- /**
859
- * Sets the authorization code issued to this client.
860
- *
861
- * @param string $code
862
- */
863
- public function setCode($code)
864
- {
865
- $this->code = $code;
866
- }
867
-
868
- /**
869
- * Gets the resource owner's username.
870
- */
871
- public function getUsername()
872
- {
873
- return $this->username;
874
- }
875
-
876
- /**
877
- * Sets the resource owner's username.
878
- *
879
- * @param string $username
880
- */
881
- public function setUsername($username)
882
- {
883
- $this->username = $username;
884
- }
885
-
886
- /**
887
- * Gets the resource owner's password.
888
- */
889
- public function getPassword()
890
- {
891
- return $this->password;
892
- }
893
-
894
- /**
895
- * Sets the resource owner's password.
896
- *
897
- * @param $password
898
- */
899
- public function setPassword($password)
900
- {
901
- $this->password = $password;
902
- }
903
-
904
- /**
905
- * Sets a unique identifier issued to the client to identify itself to the
906
- * authorization server.
907
- */
908
- public function getClientId()
909
- {
910
- return $this->clientId;
911
- }
912
-
913
- /**
914
- * Sets a unique identifier issued to the client to identify itself to the
915
- * authorization server.
916
- *
917
- * @param $clientId
918
- */
919
- public function setClientId($clientId)
920
- {
921
- $this->clientId = $clientId;
922
- }
923
-
924
- /**
925
- * Gets a shared symmetric secret issued by the authorization server, which
926
- * is used to authenticate the client.
927
- */
928
- public function getClientSecret()
929
- {
930
- return $this->clientSecret;
931
- }
932
-
933
- /**
934
- * Sets a shared symmetric secret issued by the authorization server, which
935
- * is used to authenticate the client.
936
- *
937
- * @param $clientSecret
938
- */
939
- public function setClientSecret($clientSecret)
940
- {
941
- $this->clientSecret = $clientSecret;
942
- }
943
-
944
- /**
945
- * Gets the Issuer ID when using assertion profile.
946
- */
947
- public function getIssuer()
948
- {
949
- return $this->issuer;
950
- }
951
-
952
- /**
953
- * Sets the Issuer ID when using assertion profile.
954
- *
955
- * @param string $issuer
956
- */
957
- public function setIssuer($issuer)
958
- {
959
- $this->issuer = $issuer;
960
- }
961
-
962
- /**
963
- * Gets the target sub when issuing assertions.
964
- */
965
- public function getSub()
966
- {
967
- return $this->sub;
968
- }
969
-
970
- /**
971
- * Sets the target sub when issuing assertions.
972
- *
973
- * @param string $sub
974
- */
975
- public function setSub($sub)
976
- {
977
- $this->sub = $sub;
978
- }
979
-
980
- /**
981
- * Gets the target audience when issuing assertions.
982
- */
983
- public function getAudience()
984
- {
985
- return $this->audience;
986
- }
987
-
988
- /**
989
- * Sets the target audience when issuing assertions.
990
- *
991
- * @param string $audience
992
- */
993
- public function setAudience($audience)
994
- {
995
- $this->audience = $audience;
996
- }
997
-
998
- /**
999
- * Gets the signing key when using an assertion profile.
1000
- */
1001
- public function getSigningKey()
1002
- {
1003
- return $this->signingKey;
1004
- }
1005
-
1006
- /**
1007
- * Sets the signing key when using an assertion profile.
1008
- *
1009
- * @param string $signingKey
1010
- */
1011
- public function setSigningKey($signingKey)
1012
- {
1013
- $this->signingKey = $signingKey;
1014
- }
1015
-
1016
- /**
1017
- * Gets the signing algorithm when using an assertion profile.
1018
- *
1019
- * @return string
1020
- */
1021
- public function getSigningAlgorithm()
1022
- {
1023
- return $this->signingAlgorithm;
1024
- }
1025
-
1026
- /**
1027
- * Sets the signing algorithm when using an assertion profile.
1028
- *
1029
- * @param string $signingAlgorithm
1030
- */
1031
- public function setSigningAlgorithm($signingAlgorithm)
1032
- {
1033
- if (is_null($signingAlgorithm)) {
1034
- $this->signingAlgorithm = null;
1035
- } elseif (!in_array($signingAlgorithm, self::$knownSigningAlgorithms)) {
1036
- throw new InvalidArgumentException('unknown signing algorithm');
1037
- } else {
1038
- $this->signingAlgorithm = $signingAlgorithm;
1039
- }
1040
- }
1041
-
1042
- /**
1043
- * Gets the set of parameters used by extension when using an extension
1044
- * grant type.
1045
- */
1046
- public function getExtensionParams()
1047
- {
1048
- return $this->extensionParams;
1049
- }
1050
-
1051
- /**
1052
- * Sets the set of parameters used by extension when using an extension
1053
- * grant type.
1054
- *
1055
- * @param $extensionParams
1056
- */
1057
- public function setExtensionParams($extensionParams)
1058
- {
1059
- $this->extensionParams = $extensionParams;
1060
- }
1061
-
1062
- /**
1063
- * Gets the number of seconds assertions are valid for.
1064
- */
1065
- public function getExpiry()
1066
- {
1067
- return $this->expiry;
1068
- }
1069
-
1070
- /**
1071
- * Sets the number of seconds assertions are valid for.
1072
- *
1073
- * @param int $expiry
1074
- */
1075
- public function setExpiry($expiry)
1076
- {
1077
- $this->expiry = $expiry;
1078
- }
1079
-
1080
- /**
1081
- * Gets the lifetime of the access token in seconds.
1082
- */
1083
- public function getExpiresIn()
1084
- {
1085
- return $this->expiresIn;
1086
- }
1087
-
1088
- /**
1089
- * Sets the lifetime of the access token in seconds.
1090
- *
1091
- * @param int $expiresIn
1092
- */
1093
- public function setExpiresIn($expiresIn)
1094
- {
1095
- if (is_null($expiresIn)) {
1096
- $this->expiresIn = null;
1097
- $this->issuedAt = null;
1098
- } else {
1099
- $this->issuedAt = time();
1100
- $this->expiresIn = (int)$expiresIn;
1101
- }
1102
- }
1103
-
1104
- /**
1105
- * Gets the time the current access token expires at.
1106
- *
1107
- * @return int
1108
- */
1109
- public function getExpiresAt()
1110
- {
1111
- if (!is_null($this->expiresAt)) {
1112
- return $this->expiresAt;
1113
- } elseif (!is_null($this->issuedAt) && !is_null($this->expiresIn)) {
1114
- return $this->issuedAt + $this->expiresIn;
1115
- }
1116
-
1117
- return null;
1118
- }
1119
-
1120
- /**
1121
- * Returns true if the acccess token has expired.
1122
- *
1123
- * @return bool
1124
- */
1125
- public function isExpired()
1126
- {
1127
- $expiration = $this->getExpiresAt();
1128
- $now = time();
1129
-
1130
- return !is_null($expiration) && $now >= $expiration;
1131
- }
1132
-
1133
- /**
1134
- * Sets the time the current access token expires at.
1135
- *
1136
- * @param int $expiresAt
1137
- */
1138
- public function setExpiresAt($expiresAt)
1139
- {
1140
- $this->expiresAt = $expiresAt;
1141
- }
1142
-
1143
- /**
1144
- * Gets the time the current access token was issued at.
1145
- */
1146
- public function getIssuedAt()
1147
- {
1148
- return $this->issuedAt;
1149
- }
1150
-
1151
- /**
1152
- * Sets the time the current access token was issued at.
1153
- *
1154
- * @param int $issuedAt
1155
- */
1156
- public function setIssuedAt($issuedAt)
1157
- {
1158
- $this->issuedAt = $issuedAt;
1159
- }
1160
-
1161
- /**
1162
- * Gets the current access token.
1163
- */
1164
- public function getAccessToken()
1165
- {
1166
- return $this->accessToken;
1167
- }
1168
-
1169
- /**
1170
- * Sets the current access token.
1171
- *
1172
- * @param string $accessToken
1173
- */
1174
- public function setAccessToken($accessToken)
1175
- {
1176
- $this->accessToken = $accessToken;
1177
- }
1178
-
1179
- /**
1180
- * Gets the current ID token.
1181
- */
1182
- public function getIdToken()
1183
- {
1184
- return $this->idToken;
1185
- }
1186
-
1187
- /**
1188
- * Sets the current ID token.
1189
- *
1190
- * @param $idToken
1191
- */
1192
- public function setIdToken($idToken)
1193
- {
1194
- $this->idToken = $idToken;
1195
- }
1196
-
1197
- /**
1198
- * Gets the refresh token associated with the current access token.
1199
- */
1200
- public function getRefreshToken()
1201
- {
1202
- return $this->refreshToken;
1203
- }
1204
-
1205
- /**
1206
- * Sets the refresh token associated with the current access token.
1207
- *
1208
- * @param $refreshToken
1209
- */
1210
- public function setRefreshToken($refreshToken)
1211
- {
1212
- $this->refreshToken = $refreshToken;
1213
- }
1214
-
1215
- /**
1216
- * The expiration of the last received token.
1217
- *
1218
- * @return array
1219
- */
1220
- public function getLastReceivedToken()
1221
- {
1222
- if ($token = $this->getAccessToken()) {
1223
- return [
1224
- 'access_token' => $token,
1225
- 'expires_at' => $this->getExpiresAt(),
1226
- ];
1227
- }
1228
-
1229
- return null;
1230
- }
1231
-
1232
- /**
1233
- * @todo handle uri as array
1234
- *
1235
- * @param string $uri
1236
- *
1237
- * @return null|UriInterface
1238
- */
1239
- private function coerceUri($uri)
1240
- {
1241
- if (is_null($uri)) {
1242
- return;
1243
- }
1244
-
1245
- return Psr7\uri_for($uri);
1246
- }
1247
-
1248
- /**
1249
- * @param string $idToken
1250
- * @param string|array|null $publicKey
1251
- * @param array $allowedAlgs
1252
- *
1253
- * @return object
1254
- */
1255
- private function jwtDecode($idToken, $publicKey, $allowedAlgs)
1256
- {
1257
- if (class_exists('Firebase\JWT\JWT')) {
1258
- return \Firebase\JWT\JWT::decode($idToken, $publicKey, $allowedAlgs);
1259
- }
1260
-
1261
- return \JWT::decode($idToken, $publicKey, $allowedAlgs);
1262
- }
1263
-
1264
- private function jwtEncode($assertion, $signingKey, $signingAlgorithm)
1265
- {
1266
- if (class_exists('Firebase\JWT\JWT')) {
1267
- return \Firebase\JWT\JWT::encode($assertion, $signingKey,
1268
- $signingAlgorithm);
1269
- }
1270
-
1271
- return \JWT::encode($assertion, $signingKey, $signingAlgorithm);
1272
- }
1273
-
1274
- /**
1275
- * Determines if the URI is absolute based on its scheme and host or path
1276
- * (RFC 3986).
1277
- *
1278
- * @param string $uri
1279
- *
1280
- * @return bool
1281
- */
1282
- private function isAbsoluteUri($uri)
1283
- {
1284
- $uri = $this->coerceUri($uri);
1285
-
1286
- return $uri->getScheme() && ($uri->getHost() || $uri->getPath());
1287
- }
1288
-
1289
- /**
1290
- * @param array $params
1291
- *
1292
- * @return array
1293
- */
1294
- private function addClientCredentials(&$params)
1295
- {
1296
- $clientId = $this->getClientId();
1297
- $clientSecret = $this->getClientSecret();
1298
-
1299
- if ($clientId && $clientSecret) {
1300
- $params['client_id'] = $clientId;
1301
- $params['client_secret'] = $clientSecret;
1302
- }
1303
-
1304
- return $params;
1305
- }
1306
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/auth/src/Subscriber/AuthTokenSubscriber.php DELETED
@@ -1,118 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2015 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- namespace Google\Auth\Subscriber;
19
-
20
- use Google\Auth\FetchAuthTokenInterface;
21
- use GuzzleHttp\Event\BeforeEvent;
22
- use GuzzleHttp\Event\RequestEvents;
23
- use GuzzleHttp\Event\SubscriberInterface;
24
-
25
- /**
26
- * AuthTokenSubscriber is a Guzzle Subscriber that adds an Authorization header
27
- * provided by an object implementing FetchAuthTokenInterface.
28
- *
29
- * The FetchAuthTokenInterface#fetchAuthToken is used to obtain a hash; one of
30
- * the values value in that hash is added as the authorization header.
31
- *
32
- * Requests will be accessed with the authorization header:
33
- *
34
- * 'authorization' 'Bearer <value of auth_token>'
35
- */
36
- class AuthTokenSubscriber implements SubscriberInterface
37
- {
38
- /**
39
- * @var callable
40
- */
41
- private $httpHandler;
42
-
43
- /**
44
- * @var FetchAuthTokenInterface
45
- */
46
- private $fetcher;
47
-
48
- /**
49
- * @var callable
50
- */
51
- private $tokenCallback;
52
-
53
- /**
54
- * Creates a new AuthTokenSubscriber.
55
- *
56
- * @param FetchAuthTokenInterface $fetcher is used to fetch the auth token
57
- * @param callable $httpHandler (optional) http client to fetch the token.
58
- * @param callable $tokenCallback (optional) function to be called when a new token is fetched.
59
- */
60
- public function __construct(
61
- FetchAuthTokenInterface $fetcher,
62
- callable $httpHandler = null,
63
- callable $tokenCallback = null
64
- ) {
65
- $this->fetcher = $fetcher;
66
- $this->httpHandler = $httpHandler;
67
- $this->tokenCallback = $tokenCallback;
68
- }
69
-
70
- /**
71
- * @return array
72
- */
73
- public function getEvents()
74
- {
75
- return ['before' => ['onBefore', RequestEvents::SIGN_REQUEST]];
76
- }
77
-
78
- /**
79
- * Updates the request with an Authorization header when auth is 'fetched_auth_token'.
80
- *
81
- * use GuzzleHttp\Client;
82
- * use Google\Auth\OAuth2;
83
- * use Google\Auth\Subscriber\AuthTokenSubscriber;
84
- *
85
- * $config = [..<oauth config param>.];
86
- * $oauth2 = new OAuth2($config)
87
- * $subscriber = new AuthTokenSubscriber($oauth2);
88
- *
89
- * $client = new Client([
90
- * 'base_url' => 'https://www.googleapis.com/taskqueue/v1beta2/projects/',
91
- * 'defaults' => ['auth' => 'google_auth']
92
- * ]);
93
- * $client->getEmitter()->attach($subscriber);
94
- *
95
- * $res = $client->get('myproject/taskqueues/myqueue');
96
- *
97
- * @param BeforeEvent $event
98
- */
99
- public function onBefore(BeforeEvent $event)
100
- {
101
- // Requests using "auth"="google_auth" will be authorized.
102
- $request = $event->getRequest();
103
- if ($request->getConfig()['auth'] != 'google_auth') {
104
- return;
105
- }
106
-
107
- // Fetch the auth token.
108
- $auth_tokens = $this->fetcher->fetchAuthToken($this->httpHandler);
109
- if (array_key_exists('access_token', $auth_tokens)) {
110
- $request->setHeader('authorization', 'Bearer ' . $auth_tokens['access_token']);
111
-
112
- // notify the callback if applicable
113
- if ($this->tokenCallback) {
114
- call_user_func($this->tokenCallback, $this->fetcher->getCacheKey(), $auth_tokens['access_token']);
115
- }
116
- }
117
- }
118
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/auth/src/Subscriber/ScopedAccessTokenSubscriber.php DELETED
@@ -1,177 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2015 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- namespace Google\Auth\Subscriber;
19
-
20
- use Google\Auth\CacheTrait;
21
- use GuzzleHttp\Event\BeforeEvent;
22
- use GuzzleHttp\Event\RequestEvents;
23
- use GuzzleHttp\Event\SubscriberInterface;
24
- use Psr\Cache\CacheItemPoolInterface;
25
-
26
- /**
27
- * ScopedAccessTokenSubscriber is a Guzzle Subscriber that adds an Authorization
28
- * header provided by a closure.
29
- *
30
- * The closure returns an access token, taking the scope, either a single
31
- * string or an array of strings, as its value. If provided, a cache will be
32
- * used to preserve the access token for a given lifetime.
33
- *
34
- * Requests will be accessed with the authorization header:
35
- *
36
- * 'authorization' 'Bearer <access token obtained from the closure>'
37
- */
38
- class ScopedAccessTokenSubscriber implements SubscriberInterface
39
- {
40
- use CacheTrait;
41
-
42
- const DEFAULT_CACHE_LIFETIME = 1500;
43
-
44
- /**
45
- * @var CacheItemPoolInterface
46
- */
47
- private $cache;
48
-
49
- /**
50
- * @var callable The access token generator function
51
- */
52
- private $tokenFunc;
53
-
54
- /**
55
- * @var array|string The scopes used to generate the token
56
- */
57
- private $scopes;
58
-
59
- /**
60
- * @var array
61
- */
62
- private $cacheConfig;
63
-
64
- /**
65
- * Creates a new ScopedAccessTokenSubscriber.
66
- *
67
- * @param callable $tokenFunc a token generator function
68
- * @param array|string $scopes the token authentication scopes
69
- * @param array $cacheConfig configuration for the cache when it's present
70
- * @param CacheItemPoolInterface $cache an implementation of CacheItemPoolInterface
71
- */
72
- public function __construct(
73
- callable $tokenFunc,
74
- $scopes,
75
- array $cacheConfig = null,
76
- CacheItemPoolInterface $cache = null
77
- ) {
78
- $this->tokenFunc = $tokenFunc;
79
- if (!(is_string($scopes) || is_array($scopes))) {
80
- throw new \InvalidArgumentException(
81
- 'wants scope should be string or array');
82
- }
83
- $this->scopes = $scopes;
84
-
85
- if (!is_null($cache)) {
86
- $this->cache = $cache;
87
- $this->cacheConfig = array_merge([
88
- 'lifetime' => self::DEFAULT_CACHE_LIFETIME,
89
- 'prefix' => '',
90
- ], $cacheConfig);
91
- }
92
- }
93
-
94
- /**
95
- * @return array
96
- */
97
- public function getEvents()
98
- {
99
- return ['before' => ['onBefore', RequestEvents::SIGN_REQUEST]];
100
- }
101
-
102
- /**
103
- * Updates the request with an Authorization header when auth is 'scoped'.
104
- *
105
- * E.g this could be used to authenticate using the AppEngine
106
- * AppIdentityService.
107
- *
108
- * use google\appengine\api\app_identity\AppIdentityService;
109
- * use Google\Auth\Subscriber\ScopedAccessTokenSubscriber;
110
- * use GuzzleHttp\Client;
111
- *
112
- * $scope = 'https://www.googleapis.com/auth/taskqueue'
113
- * $subscriber = new ScopedAccessToken(
114
- * 'AppIdentityService::getAccessToken',
115
- * $scope,
116
- * ['prefix' => 'Google\Auth\ScopedAccessToken::'],
117
- * $cache = new Memcache()
118
- * );
119
- *
120
- * $client = new Client([
121
- * 'base_url' => 'https://www.googleapis.com/taskqueue/v1beta2/projects/',
122
- * 'defaults' => ['auth' => 'scoped']
123
- * ]);
124
- * $client->getEmitter()->attach($subscriber);
125
- *
126
- * $res = $client->get('myproject/taskqueues/myqueue');
127
- *
128
- * @param BeforeEvent $event
129
- */
130
- public function onBefore(BeforeEvent $event)
131
- {
132
- // Requests using "auth"="scoped" will be authorized.
133
- $request = $event->getRequest();
134
- if ($request->getConfig()['auth'] != 'scoped') {
135
- return;
136
- }
137
- $auth_header = 'Bearer ' . $this->fetchToken();
138
- $request->setHeader('authorization', $auth_header);
139
- }
140
-
141
- /**
142
- * @return string
143
- */
144
- private function getCacheKey()
145
- {
146
- $key = null;
147
-
148
- if (is_string($this->scopes)) {
149
- $key .= $this->scopes;
150
- } elseif (is_array($this->scopes)) {
151
- $key .= implode(':', $this->scopes);
152
- }
153
-
154
- return $key;
155
- }
156
-
157
- /**
158
- * Determine if token is available in the cache, if not call tokenFunc to
159
- * fetch it.
160
- *
161
- * @return string
162
- */
163
- private function fetchToken()
164
- {
165
- $cacheKey = $this->getCacheKey();
166
- $cached = $this->getCachedValue($cacheKey);
167
-
168
- if (!empty($cached)) {
169
- return $cached;
170
- }
171
-
172
- $token = call_user_func($this->tokenFunc, $this->scopes);
173
- $this->setCachedValue($cacheKey, $token);
174
-
175
- return $token;
176
- }
177
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/google/auth/src/Subscriber/SimpleSubscriber.php DELETED
@@ -1,90 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2015 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- namespace Google\Auth\Subscriber;
19
-
20
- use GuzzleHttp\Event\BeforeEvent;
21
- use GuzzleHttp\Event\RequestEvents;
22
- use GuzzleHttp\Event\SubscriberInterface;
23
-
24
- /**
25
- * SimpleSubscriber is a Guzzle Subscriber that implements Google's Simple API
26
- * access.
27
- *
28
- * Requests are accessed using the Simple API access developer key.
29
- */
30
- class SimpleSubscriber implements SubscriberInterface
31
- {
32
- /**
33
- * @var array
34
- */
35
- private $config;
36
-
37
- /**
38
- * Create a new Simple plugin.
39
- *
40
- * The configuration array expects one option
41
- * - key: required, otherwise InvalidArgumentException is thrown
42
- *
43
- * @param array $config Configuration array
44
- */
45
- public function __construct(array $config)
46
- {
47
- if (!isset($config['key'])) {
48
- throw new \InvalidArgumentException('requires a key to have been set');
49
- }
50
-
51
- $this->config = array_merge([], $config);
52
- }
53
-
54
- /**
55
- * @return array
56
- */
57
- public function getEvents()
58
- {
59
- return ['before' => ['onBefore', RequestEvents::SIGN_REQUEST]];
60
- }
61
-
62
- /**
63
- * Updates the request query with the developer key if auth is set to simple.
64
- *
65
- * use Google\Auth\Subscriber\SimpleSubscriber;
66
- * use GuzzleHttp\Client;
67
- *
68
- * $my_key = 'is not the same as yours';
69
- * $subscriber = new SimpleSubscriber(['key' => $my_key]);
70
- *
71
- * $client = new Client([
72
- * 'base_url' => 'https://www.googleapis.com/discovery/v1/',
73
- * 'defaults' => ['auth' => 'simple']
74
- * ]);
75
- * $client->getEmitter()->attach($subscriber);
76
- *
77
- * $res = $client->get('drive/v2/rest');
78
- *
79
- * @param BeforeEvent $event
80
- */
81
- public function onBefore(BeforeEvent $event)
82
- {
83
- // Requests using "auth"="simple" with the developer key.
84
- $request = $event->getRequest();
85
- if ($request->getConfig()['auth'] != 'simple') {
86
- return;
87
- }
88
- $request->getQuery()->overwriteWith($this->config);
89
- }
90
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/.travis.yml DELETED
@@ -1,41 +0,0 @@
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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/CHANGELOG.md DELETED
@@ -1,1060 +0,0 @@
1
- # CHANGELOG
2
-
3
- ## 5.3.1 - 2016-07-18
4
-
5
- * Address HTTP_PROXY security vulnerability, CVE-2016-5385:
6
- https://httpoxy.org/
7
- * Event name fix: https://github.com/guzzle/guzzle/commit/fcae91ff31de41e312fe113ec3acbcda31b2622e
8
- * Response header case sensitivity fix: https://github.com/guzzle/guzzle/commit/043eeadf20ee40ddc6712faee4d3957a91f2b041
9
-
10
- ## 5.3.0 - 2015-05-19
11
-
12
- * Mock now supports `save_to`
13
- * Marked `AbstractRequestEvent::getTransaction()` as public.
14
- * Fixed a bug in which multiple headers using different casing would overwrite
15
- previous headers in the associative array.
16
- * Added `Utils::getDefaultHandler()`
17
- * Marked `GuzzleHttp\Client::getDefaultUserAgent` as deprecated.
18
- * URL scheme is now always lowercased.
19
-
20
- ## 5.2.0 - 2015-01-27
21
-
22
- * Added `AppliesHeadersInterface` to make applying headers to a request based
23
- on the body more generic and not specific to `PostBodyInterface`.
24
- * Reduced the number of stack frames needed to send requests.
25
- * Nested futures are now resolved in the client rather than the RequestFsm
26
- * Finishing state transitions is now handled in the RequestFsm rather than the
27
- RingBridge.
28
- * Added a guard in the Pool class to not use recursion for request retries.
29
-
30
- ## 5.1.0 - 2014-12-19
31
-
32
- * Pool class no longer uses recursion when a request is intercepted.
33
- * The size of a Pool can now be dynamically adjusted using a callback.
34
- See https://github.com/guzzle/guzzle/pull/943.
35
- * Setting a request option to `null` when creating a request with a client will
36
- ensure that the option is not set. This allows you to overwrite default
37
- request options on a per-request basis.
38
- See https://github.com/guzzle/guzzle/pull/937.
39
- * Added the ability to limit which protocols are allowed for redirects by
40
- specifying a `protocols` array in the `allow_redirects` request option.
41
- * Nested futures due to retries are now resolved when waiting for synchronous
42
- responses. See https://github.com/guzzle/guzzle/pull/947.
43
- * `"0"` is now an allowed URI path. See
44
- https://github.com/guzzle/guzzle/pull/935.
45
- * `Query` no longer typehints on the `$query` argument in the constructor,
46
- allowing for strings and arrays.
47
- * Exceptions thrown in the `end` event are now correctly wrapped with Guzzle
48
- specific exceptions if necessary.
49
-
50
- ## 5.0.3 - 2014-11-03
51
-
52
- This change updates query strings so that they are treated as un-encoded values
53
- by default where the value represents an un-encoded value to send over the
54
- wire. A Query object then encodes the value before sending over the wire. This
55
- means that even value query string values (e.g., ":") are url encoded. This
56
- makes the Query class match PHP's http_build_query function. However, if you
57
- want to send requests over the wire using valid query string characters that do
58
- not need to be encoded, then you can provide a string to Url::setQuery() and
59
- pass true as the second argument to specify that the query string is a raw
60
- string that should not be parsed or encoded (unless a call to getQuery() is
61
- subsequently made, forcing the query-string to be converted into a Query
62
- object).
63
-
64
- ## 5.0.2 - 2014-10-30
65
-
66
- * Added a trailing `\r\n` to multipart/form-data payloads. See
67
- https://github.com/guzzle/guzzle/pull/871
68
- * Added a `GuzzleHttp\Pool::send()` convenience method to match the docs.
69
- * Status codes are now returned as integers. See
70
- https://github.com/guzzle/guzzle/issues/881
71
- * No longer overwriting an existing `application/x-www-form-urlencoded` header
72
- when sending POST requests, allowing for customized headers. See
73
- https://github.com/guzzle/guzzle/issues/877
74
- * Improved path URL serialization.
75
-
76
- * No longer double percent-encoding characters in the path or query string if
77
- they are already encoded.
78
- * Now properly encoding the supplied path to a URL object, instead of only
79
- encoding ' ' and '?'.
80
- * Note: This has been changed in 5.0.3 to now encode query string values by
81
- default unless the `rawString` argument is provided when setting the query
82
- string on a URL: Now allowing many more characters to be present in the
83
- query string without being percent encoded. See http://tools.ietf.org/html/rfc3986#appendix-A
84
-
85
- ## 5.0.1 - 2014-10-16
86
-
87
- Bugfix release.
88
-
89
- * Fixed an issue where connection errors still returned response object in
90
- error and end events event though the response is unusable. This has been
91
- corrected so that a response is not returned in the `getResponse` method of
92
- these events if the response did not complete. https://github.com/guzzle/guzzle/issues/867
93
- * Fixed an issue where transfer statistics were not being populated in the
94
- RingBridge. https://github.com/guzzle/guzzle/issues/866
95
-
96
- ## 5.0.0 - 2014-10-12
97
-
98
- Adding support for non-blocking responses and some minor API cleanup.
99
-
100
- ### New Features
101
-
102
- * Added support for non-blocking responses based on `guzzlehttp/guzzle-ring`.
103
- * Added a public API for creating a default HTTP adapter.
104
- * Updated the redirect plugin to be non-blocking so that redirects are sent
105
- concurrently. Other plugins like this can now be updated to be non-blocking.
106
- * Added a "progress" event so that you can get upload and download progress
107
- events.
108
- * Added `GuzzleHttp\Pool` which implements FutureInterface and transfers
109
- requests concurrently using a capped pool size as efficiently as possible.
110
- * Added `hasListeners()` to EmitterInterface.
111
- * Removed `GuzzleHttp\ClientInterface::sendAll` and marked
112
- `GuzzleHttp\Client::sendAll` as deprecated (it's still there, just not the
113
- recommended way).
114
-
115
- ### Breaking changes
116
-
117
- The breaking changes in this release are relatively minor. The biggest thing to
118
- look out for is that request and response objects no longer implement fluent
119
- interfaces.
120
-
121
- * Removed the fluent interfaces (i.e., `return $this`) from requests,
122
- responses, `GuzzleHttp\Collection`, `GuzzleHttp\Url`,
123
- `GuzzleHttp\Query`, `GuzzleHttp\Post\PostBody`, and
124
- `GuzzleHttp\Cookie\SetCookie`. This blog post provides a good outline of
125
- why I did this: http://ocramius.github.io/blog/fluent-interfaces-are-evil/.
126
- This also makes the Guzzle message interfaces compatible with the current
127
- PSR-7 message proposal.
128
- * Removed "functions.php", so that Guzzle is truly PSR-4 compliant. Except
129
- for the HTTP request functions from function.php, these functions are now
130
- implemented in `GuzzleHttp\Utils` using camelCase. `GuzzleHttp\json_decode`
131
- moved to `GuzzleHttp\Utils::jsonDecode`. `GuzzleHttp\get_path` moved to
132
- `GuzzleHttp\Utils::getPath`. `GuzzleHttp\set_path` moved to
133
- `GuzzleHttp\Utils::setPath`. `GuzzleHttp\batch` should now be
134
- `GuzzleHttp\Pool::batch`, which returns an `objectStorage`. Using functions.php
135
- caused problems for many users: they aren't PSR-4 compliant, require an
136
- explicit include, and needed an if-guard to ensure that the functions are not
137
- declared multiple times.
138
- * Rewrote adapter layer.
139
- * Removing all classes from `GuzzleHttp\Adapter`, these are now
140
- implemented as callables that are stored in `GuzzleHttp\Ring\Client`.
141
- * Removed the concept of "parallel adapters". Sending requests serially or
142
- concurrently is now handled using a single adapter.
143
- * Moved `GuzzleHttp\Adapter\Transaction` to `GuzzleHttp\Transaction`. The
144
- Transaction object now exposes the request, response, and client as public
145
- properties. The getters and setters have been removed.
146
- * Removed the "headers" event. This event was only useful for changing the
147
- body a response once the headers of the response were known. You can implement
148
- a similar behavior in a number of ways. One example might be to use a
149
- FnStream that has access to the transaction being sent. For example, when the
150
- first byte is written, you could check if the response headers match your
151
- expectations, and if so, change the actual stream body that is being
152
- written to.
153
- * Removed the `asArray` parameter from
154
- `GuzzleHttp\Message\MessageInterface::getHeader`. If you want to get a header
155
- value as an array, then use the newly added `getHeaderAsArray()` method of
156
- `MessageInterface`. This change makes the Guzzle interfaces compatible with
157
- the PSR-7 interfaces.
158
- * `GuzzleHttp\Message\MessageFactory` no longer allows subclasses to add
159
- custom request options using double-dispatch (this was an implementation
160
- detail). Instead, you should now provide an associative array to the
161
- constructor which is a mapping of the request option name mapping to a
162
- function that applies the option value to a request.
163
- * Removed the concept of "throwImmediately" from exceptions and error events.
164
- This control mechanism was used to stop a transfer of concurrent requests
165
- from completing. This can now be handled by throwing the exception or by
166
- cancelling a pool of requests or each outstanding future request individually.
167
- * Updated to "GuzzleHttp\Streams" 3.0.
168
- * `GuzzleHttp\Stream\StreamInterface::getContents()` no longer accepts a
169
- `maxLen` parameter. This update makes the Guzzle streams project
170
- compatible with the current PSR-7 proposal.
171
- * `GuzzleHttp\Stream\Stream::__construct`,
172
- `GuzzleHttp\Stream\Stream::factory`, and
173
- `GuzzleHttp\Stream\Utils::create` no longer accept a size in the second
174
- argument. They now accept an associative array of options, including the
175
- "size" key and "metadata" key which can be used to provide custom metadata.
176
-
177
- ## 4.2.2 - 2014-09-08
178
-
179
- * Fixed a memory leak in the CurlAdapter when reusing cURL handles.
180
- * No longer using `request_fulluri` in stream adapter proxies.
181
- * Relative redirects are now based on the last response, not the first response.
182
-
183
- ## 4.2.1 - 2014-08-19
184
-
185
- * Ensuring that the StreamAdapter does not always add a Content-Type header
186
- * Adding automated github releases with a phar and zip
187
-
188
- ## 4.2.0 - 2014-08-17
189
-
190
- * Now merging in default options using a case-insensitive comparison.
191
- Closes https://github.com/guzzle/guzzle/issues/767
192
- * Added the ability to automatically decode `Content-Encoding` response bodies
193
- using the `decode_content` request option. This is set to `true` by default
194
- to decode the response body if it comes over the wire with a
195
- `Content-Encoding`. Set this value to `false` to disable decoding the
196
- response content, and pass a string to provide a request `Accept-Encoding`
197
- header and turn on automatic response decoding. This feature now allows you
198
- to pass an `Accept-Encoding` header in the headers of a request but still
199
- disable automatic response decoding.
200
- Closes https://github.com/guzzle/guzzle/issues/764
201
- * Added the ability to throw an exception immediately when transferring
202
- requests in parallel. Closes https://github.com/guzzle/guzzle/issues/760
203
- * Updating guzzlehttp/streams dependency to ~2.1
204
- * No longer utilizing the now deprecated namespaced methods from the stream
205
- package.
206
-
207
- ## 4.1.8 - 2014-08-14
208
-
209
- * Fixed an issue in the CurlFactory that caused setting the `stream=false`
210
- request option to throw an exception.
211
- See: https://github.com/guzzle/guzzle/issues/769
212
- * TransactionIterator now calls rewind on the inner iterator.
213
- See: https://github.com/guzzle/guzzle/pull/765
214
- * You can now set the `Content-Type` header to `multipart/form-data`
215
- when creating POST requests to force multipart bodies.
216
- See https://github.com/guzzle/guzzle/issues/768
217
-
218
- ## 4.1.7 - 2014-08-07
219
-
220
- * Fixed an error in the HistoryPlugin that caused the same request and response
221
- to be logged multiple times when an HTTP protocol error occurs.
222
- * Ensuring that cURL does not add a default Content-Type when no Content-Type
223
- has been supplied by the user. This prevents the adapter layer from modifying
224
- the request that is sent over the wire after any listeners may have already
225
- put the request in a desired state (e.g., signed the request).
226
- * Throwing an exception when you attempt to send requests that have the
227
- "stream" set to true in parallel using the MultiAdapter.
228
- * Only calling curl_multi_select when there are active cURL handles. This was
229
- previously changed and caused performance problems on some systems due to PHP
230
- always selecting until the maximum select timeout.
231
- * Fixed a bug where multipart/form-data POST fields were not correctly
232
- aggregated (e.g., values with "&").
233
-
234
- ## 4.1.6 - 2014-08-03
235
-
236
- * Added helper methods to make it easier to represent messages as strings,
237
- including getting the start line and getting headers as a string.
238
-
239
- ## 4.1.5 - 2014-08-02
240
-
241
- * Automatically retrying cURL "Connection died, retrying a fresh connect"
242
- errors when possible.
243
- * cURL implementation cleanup
244
- * Allowing multiple event subscriber listeners to be registered per event by
245
- passing an array of arrays of listener configuration.
246
-
247
- ## 4.1.4 - 2014-07-22
248
-
249
- * Fixed a bug that caused multi-part POST requests with more than one field to
250
- serialize incorrectly.
251
- * Paths can now be set to "0"
252
- * `ResponseInterface::xml` now accepts a `libxml_options` option and added a
253
- missing default argument that was required when parsing XML response bodies.
254
- * A `save_to` stream is now created lazily, which means that files are not
255
- created on disk unless a request succeeds.
256
-
257
- ## 4.1.3 - 2014-07-15
258
-
259
- * Various fixes to multipart/form-data POST uploads
260
- * Wrapping function.php in an if-statement to ensure Guzzle can be used
261
- globally and in a Composer install
262
- * Fixed an issue with generating and merging in events to an event array
263
- * POST headers are only applied before sending a request to allow you to change
264
- the query aggregator used before uploading
265
- * Added much more robust query string parsing
266
- * Fixed various parsing and normalization issues with URLs
267
- * Fixing an issue where multi-valued headers were not being utilized correctly
268
- in the StreamAdapter
269
-
270
- ## 4.1.2 - 2014-06-18
271
-
272
- * Added support for sending payloads with GET requests
273
-
274
- ## 4.1.1 - 2014-06-08
275
-
276
- * Fixed an issue related to using custom message factory options in subclasses
277
- * Fixed an issue with nested form fields in a multi-part POST
278
- * Fixed an issue with using the `json` request option for POST requests
279
- * Added `ToArrayInterface` to `GuzzleHttp\Cookie\CookieJar`
280
-
281
- ## 4.1.0 - 2014-05-27
282
-
283
- * Added a `json` request option to easily serialize JSON payloads.
284
- * Added a `GuzzleHttp\json_decode()` wrapper to safely parse JSON.
285
- * Added `setPort()` and `getPort()` to `GuzzleHttp\Message\RequestInterface`.
286
- * Added the ability to provide an emitter to a client in the client constructor.
287
- * Added the ability to persist a cookie session using $_SESSION.
288
- * Added a trait that can be used to add event listeners to an iterator.
289
- * Removed request method constants from RequestInterface.
290
- * Fixed warning when invalid request start-lines are received.
291
- * Updated MessageFactory to work with custom request option methods.
292
- * Updated cacert bundle to latest build.
293
-
294
- 4.0.2 (2014-04-16)
295
- ------------------
296
-
297
- * Proxy requests using the StreamAdapter now properly use request_fulluri (#632)
298
- * Added the ability to set scalars as POST fields (#628)
299
-
300
- ## 4.0.1 - 2014-04-04
301
-
302
- * The HTTP status code of a response is now set as the exception code of
303
- RequestException objects.
304
- * 303 redirects will now correctly switch from POST to GET requests.
305
- * The default parallel adapter of a client now correctly uses the MultiAdapter.
306
- * HasDataTrait now initializes the internal data array as an empty array so
307
- that the toArray() method always returns an array.
308
-
309
- ## 4.0.0 - 2014-03-29
310
-
311
- * For more information on the 4.0 transition, see:
312
- http://mtdowling.com/blog/2014/03/15/guzzle-4-rc/
313
- * For information on changes and upgrading, see:
314
- https://github.com/guzzle/guzzle/blob/master/UPGRADING.md#3x-to-40
315
- * Added `GuzzleHttp\batch()` as a convenience function for sending requests in
316
- parallel without needing to write asynchronous code.
317
- * Restructured how events are added to `GuzzleHttp\ClientInterface::sendAll()`.
318
- You can now pass a callable or an array of associative arrays where each
319
- associative array contains the "fn", "priority", and "once" keys.
320
-
321
- ## 4.0.0.rc-2 - 2014-03-25
322
-
323
- * Removed `getConfig()` and `setConfig()` from clients to avoid confusion
324
- around whether things like base_url, message_factory, etc. should be able to
325
- be retrieved or modified.
326
- * Added `getDefaultOption()` and `setDefaultOption()` to ClientInterface
327
- * functions.php functions were renamed using snake_case to match PHP idioms
328
- * Added support for `HTTP_PROXY`, `HTTPS_PROXY`, and
329
- `GUZZLE_CURL_SELECT_TIMEOUT` environment variables
330
- * Added the ability to specify custom `sendAll()` event priorities
331
- * Added the ability to specify custom stream context options to the stream
332
- adapter.
333
- * Added a functions.php function for `get_path()` and `set_path()`
334
- * CurlAdapter and MultiAdapter now use a callable to generate curl resources
335
- * MockAdapter now properly reads a body and emits a `headers` event
336
- * Updated Url class to check if a scheme and host are set before adding ":"
337
- and "//". This allows empty Url (e.g., "") to be serialized as "".
338
- * Parsing invalid XML no longer emits warnings
339
- * Curl classes now properly throw AdapterExceptions
340
- * Various performance optimizations
341
- * Streams are created with the faster `Stream\create()` function
342
- * Marked deprecation_proxy() as internal
343
- * Test server is now a collection of static methods on a class
344
-
345
- ## 4.0.0-rc.1 - 2014-03-15
346
-
347
- * See https://github.com/guzzle/guzzle/blob/master/UPGRADING.md#3x-to-40
348
-
349
- ## 3.8.1 - 2014-01-28
350
-
351
- * Bug: Always using GET requests when redirecting from a 303 response
352
- * Bug: CURLOPT_SSL_VERIFYHOST is now correctly set to false when setting `$certificateAuthority` to false in
353
- `Guzzle\Http\ClientInterface::setSslVerification()`
354
- * Bug: RedirectPlugin now uses strict RFC 3986 compliance when combining a base URL with a relative URL
355
- * Bug: The body of a request can now be set to `"0"`
356
- * Sending PHP stream requests no longer forces `HTTP/1.0`
357
- * Adding more information to ExceptionCollection exceptions so that users have more context, including a stack trace of
358
- each sub-exception
359
- * Updated the `$ref` attribute in service descriptions to merge over any existing parameters of a schema (rather than
360
- clobbering everything).
361
- * Merging URLs will now use the query string object from the relative URL (thus allowing custom query aggregators)
362
- * Query strings are now parsed in a way that they do no convert empty keys with no value to have a dangling `=`.
363
- For example `foo&bar=baz` is now correctly parsed and recognized as `foo&bar=baz` rather than `foo=&bar=baz`.
364
- * Now properly escaping the regular expression delimiter when matching Cookie domains.
365
- * Network access is now disabled when loading XML documents
366
-
367
- ## 3.8.0 - 2013-12-05
368
-
369
- * Added the ability to define a POST name for a file
370
- * JSON response parsing now properly walks additionalProperties
371
- * cURL error code 18 is now retried automatically in the BackoffPlugin
372
- * Fixed a cURL error when URLs contain fragments
373
- * Fixed an issue in the BackoffPlugin retry event where it was trying to access all exceptions as if they were
374
- CurlExceptions
375
- * CURLOPT_PROGRESS function fix for PHP 5.5 (69fcc1e)
376
- * Added the ability for Guzzle to work with older versions of cURL that do not support `CURLOPT_TIMEOUT_MS`
377
- * Fixed a bug that was encountered when parsing empty header parameters
378
- * UriTemplate now has a `setRegex()` method to match the docs
379
- * The `debug` request parameter now checks if it is truthy rather than if it exists
380
- * Setting the `debug` request parameter to true shows verbose cURL output instead of using the LogPlugin
381
- * Added the ability to combine URLs using strict RFC 3986 compliance
382
- * Command objects can now return the validation errors encountered by the command
383
- * Various fixes to cache revalidation (#437 and 29797e5)
384
- * Various fixes to the AsyncPlugin
385
- * Cleaned up build scripts
386
-
387
- ## 3.7.4 - 2013-10-02
388
-
389
- * Bug fix: 0 is now an allowed value in a description parameter that has a default value (#430)
390
- * Bug fix: SchemaFormatter now returns an integer when formatting to a Unix timestamp
391
- (see https://github.com/aws/aws-sdk-php/issues/147)
392
- * Bug fix: Cleaned up and fixed URL dot segment removal to properly resolve internal dots
393
- * Minimum PHP version is now properly specified as 5.3.3 (up from 5.3.2) (#420)
394
- * Updated the bundled cacert.pem (#419)
395
- * OauthPlugin now supports adding authentication to headers or query string (#425)
396
-
397
- ## 3.7.3 - 2013-09-08
398
-
399
- * Added the ability to get the exception associated with a request/command when using `MultiTransferException` and
400
- `CommandTransferException`.
401
- * Setting `additionalParameters` of a response to false is now honored when parsing responses with a service description
402
- * Schemas are only injected into response models when explicitly configured.
403
- * No longer guessing Content-Type based on the path of a request. Content-Type is now only guessed based on the path of
404
- an EntityBody.
405
- * Bug fix: ChunkedIterator can now properly chunk a \Traversable as well as an \Iterator.
406
- * Bug fix: FilterIterator now relies on `\Iterator` instead of `\Traversable`.
407
- * Bug fix: Gracefully handling malformed responses in RequestMediator::writeResponseBody()
408
- * Bug fix: Replaced call to canCache with canCacheRequest in the CallbackCanCacheStrategy of the CachePlugin
409
- * Bug fix: Visiting XML attributes first before visiting XML children when serializing requests
410
- * Bug fix: Properly parsing headers that contain commas contained in quotes
411
- * Bug fix: mimetype guessing based on a filename is now case-insensitive
412
-
413
- ## 3.7.2 - 2013-08-02
414
-
415
- * Bug fix: Properly URL encoding paths when using the PHP-only version of the UriTemplate expander
416
- See https://github.com/guzzle/guzzle/issues/371
417
- * Bug fix: Cookie domains are now matched correctly according to RFC 6265
418
- See https://github.com/guzzle/guzzle/issues/377
419
- * Bug fix: GET parameters are now used when calculating an OAuth signature
420
- * Bug fix: Fixed an issue with cache revalidation where the If-None-Match header was being double quoted
421
- * `Guzzle\Common\AbstractHasDispatcher::dispatch()` now returns the event that was dispatched
422
- * `Guzzle\Http\QueryString::factory()` now guesses the most appropriate query aggregator to used based on the input.
423
- See https://github.com/guzzle/guzzle/issues/379
424
- * Added a way to add custom domain objects to service description parsing using the `operation.parse_class` event. See
425
- https://github.com/guzzle/guzzle/pull/380
426
- * cURL multi cleanup and optimizations
427
-
428
- ## 3.7.1 - 2013-07-05
429
-
430
- * Bug fix: Setting default options on a client now works
431
- * Bug fix: Setting options on HEAD requests now works. See #352
432
- * Bug fix: Moving stream factory before send event to before building the stream. See #353
433
- * Bug fix: Cookies no longer match on IP addresses per RFC 6265
434
- * Bug fix: Correctly parsing header parameters that are in `<>` and quotes
435
- * Added `cert` and `ssl_key` as request options
436
- * `Host` header can now diverge from the host part of a URL if the header is set manually
437
- * `Guzzle\Service\Command\LocationVisitor\Request\XmlVisitor` was rewritten to change from using SimpleXML to XMLWriter
438
- * OAuth parameters are only added via the plugin if they aren't already set
439
- * Exceptions are now thrown when a URL cannot be parsed
440
- * Returning `false` if `Guzzle\Http\EntityBody::getContentMd5()` fails
441
- * Not setting a `Content-MD5` on a command if calculating the Content-MD5 fails via the CommandContentMd5Plugin
442
-
443
- ## 3.7.0 - 2013-06-10
444
-
445
- * See UPGRADING.md for more information on how to upgrade.
446
- * Requests now support the ability to specify an array of $options when creating a request to more easily modify a
447
- request. You can pass a 'request.options' configuration setting to a client to apply default request options to
448
- every request created by a client (e.g. default query string variables, headers, curl options, etc.).
449
- * Added a static facade class that allows you to use Guzzle with static methods and mount the class to `\Guzzle`.
450
- See `Guzzle\Http\StaticClient::mount`.
451
- * Added `command.request_options` to `Guzzle\Service\Command\AbstractCommand` to pass request options to requests
452
- created by a command (e.g. custom headers, query string variables, timeout settings, etc.).
453
- * Stream size in `Guzzle\Stream\PhpStreamRequestFactory` will now be set if Content-Length is returned in the
454
- headers of a response
455
- * Added `Guzzle\Common\Collection::setPath($path, $value)` to set a value into an array using a nested key
456
- (e.g. `$collection->setPath('foo/baz/bar', 'test'); echo $collection['foo']['bar']['bar'];`)
457
- * ServiceBuilders now support storing and retrieving arbitrary data
458
- * CachePlugin can now purge all resources for a given URI
459
- * CachePlugin can automatically purge matching cached items when a non-idempotent request is sent to a resource
460
- * CachePlugin now uses the Vary header to determine if a resource is a cache hit
461
- * `Guzzle\Http\Message\Response` now implements `\Serializable`
462
- * Added `Guzzle\Cache\CacheAdapterFactory::fromCache()` to more easily create cache adapters
463
- * `Guzzle\Service\ClientInterface::execute()` now accepts an array, single command, or Traversable
464
- * Fixed a bug in `Guzzle\Http\Message\Header\Link::addLink()`
465
- * Better handling of calculating the size of a stream in `Guzzle\Stream\Stream` using fstat() and caching the size
466
- * `Guzzle\Common\Exception\ExceptionCollection` now creates a more readable exception message
467
- * Fixing BC break: Added back the MonologLogAdapter implementation rather than extending from PsrLog so that older
468
- Symfony users can still use the old version of Monolog.
469
- * Fixing BC break: Added the implementation back in for `Guzzle\Http\Message\AbstractMessage::getTokenizedHeader()`.
470
- Now triggering an E_USER_DEPRECATED warning when used. Use `$message->getHeader()->parseParams()`.
471
- * Several performance improvements to `Guzzle\Common\Collection`
472
- * Added an `$options` argument to the end of the following methods of `Guzzle\Http\ClientInterface`:
473
- createRequest, head, delete, put, patch, post, options, prepareRequest
474
- * Added an `$options` argument to the end of `Guzzle\Http\Message\Request\RequestFactoryInterface::createRequest()`
475
- * Added an `applyOptions()` method to `Guzzle\Http\Message\Request\RequestFactoryInterface`
476
- * Changed `Guzzle\Http\ClientInterface::get($uri = null, $headers = null, $body = null)` to
477
- `Guzzle\Http\ClientInterface::get($uri = null, $headers = null, $options = array())`. You can still pass in a
478
- resource, string, or EntityBody into the $options parameter to specify the download location of the response.
479
- * Changed `Guzzle\Common\Collection::__construct($data)` to no longer accepts a null value for `$data` but a
480
- default `array()`
481
- * Added `Guzzle\Stream\StreamInterface::isRepeatable`
482
- * Removed `Guzzle\Http\ClientInterface::setDefaultHeaders(). Use
483
- $client->getConfig()->setPath('request.options/headers/{header_name}', 'value')`. or
484
- $client->getConfig()->setPath('request.options/headers', array('header_name' => 'value'))`.
485
- * Removed `Guzzle\Http\ClientInterface::getDefaultHeaders(). Use $client->getConfig()->getPath('request.options/headers')`.
486
- * Removed `Guzzle\Http\ClientInterface::expandTemplate()`
487
- * Removed `Guzzle\Http\ClientInterface::setRequestFactory()`
488
- * Removed `Guzzle\Http\ClientInterface::getCurlMulti()`
489
- * Removed `Guzzle\Http\Message\RequestInterface::canCache`
490
- * Removed `Guzzle\Http\Message\RequestInterface::setIsRedirect`
491
- * Removed `Guzzle\Http\Message\RequestInterface::isRedirect`
492
- * Made `Guzzle\Http\Client::expandTemplate` and `getUriTemplate` protected methods.
493
- * You can now enable E_USER_DEPRECATED warnings to see if you are using a deprecated method by setting
494
- `Guzzle\Common\Version::$emitWarnings` to true.
495
- * Marked `Guzzle\Http\Message\Request::isResponseBodyRepeatable()` as deprecated. Use
496
- `$request->getResponseBody()->isRepeatable()` instead.
497
- * Marked `Guzzle\Http\Message\Request::canCache()` as deprecated. Use
498
- `Guzzle\Plugin\Cache\DefaultCanCacheStrategy->canCacheRequest()` instead.
499
- * Marked `Guzzle\Http\Message\Request::canCache()` as deprecated. Use
500
- `Guzzle\Plugin\Cache\DefaultCanCacheStrategy->canCacheRequest()` instead.
501
- * Marked `Guzzle\Http\Message\Request::setIsRedirect()` as deprecated. Use the HistoryPlugin instead.
502
- * Marked `Guzzle\Http\Message\Request::isRedirect()` as deprecated. Use the HistoryPlugin instead.
503
- * Marked `Guzzle\Cache\CacheAdapterFactory::factory()` as deprecated
504
- * Marked 'command.headers', 'command.response_body' and 'command.on_complete' as deprecated for AbstractCommand.
505
- These will work through Guzzle 4.0
506
- * Marked 'request.params' for `Guzzle\Http\Client` as deprecated. Use [request.options][params].
507
- * Marked `Guzzle\Service\Client::enableMagicMethods()` as deprecated. Magic methods can no longer be disabled on a Guzzle\Service\Client.
508
- * Marked `Guzzle\Service\Client::getDefaultHeaders()` as deprecated. Use $client->getConfig()->getPath('request.options/headers')`.
509
- * Marked `Guzzle\Service\Client::setDefaultHeaders()` as deprecated. Use $client->getConfig()->setPath('request.options/headers/{header_name}', 'value')`.
510
- * Marked `Guzzle\Parser\Url\UrlParser` as deprecated. Just use PHP's `parse_url()` and percent encode your UTF-8.
511
- * Marked `Guzzle\Common\Collection::inject()` as deprecated.
512
- * Marked `Guzzle\Plugin\CurlAuth\CurlAuthPlugin` as deprecated. Use `$client->getConfig()->setPath('request.options/auth', array('user', 'pass', 'Basic|Digest');`
513
- * CacheKeyProviderInterface and DefaultCacheKeyProvider are no longer used. All of this logic is handled in a
514
- CacheStorageInterface. These two objects and interface will be removed in a future version.
515
- * Always setting X-cache headers on cached responses
516
- * Default cache TTLs are now handled by the CacheStorageInterface of a CachePlugin
517
- * `CacheStorageInterface::cache($key, Response $response, $ttl = null)` has changed to `cache(RequestInterface
518
- $request, Response $response);`
519
- * `CacheStorageInterface::fetch($key)` has changed to `fetch(RequestInterface $request);`
520
- * `CacheStorageInterface::delete($key)` has changed to `delete(RequestInterface $request);`
521
- * Added `CacheStorageInterface::purge($url)`
522
- * `DefaultRevalidation::__construct(CacheKeyProviderInterface $cacheKey, CacheStorageInterface $cache, CachePlugin
523
- $plugin)` has changed to `DefaultRevalidation::__construct(CacheStorageInterface $cache,
524
- CanCacheStrategyInterface $canCache = null)`
525
- * Added `RevalidationInterface::shouldRevalidate(RequestInterface $request, Response $response)`
526
-
527
- ## 3.6.0 - 2013-05-29
528
-
529
- * ServiceDescription now implements ToArrayInterface
530
- * Added command.hidden_params to blacklist certain headers from being treated as additionalParameters
531
- * Guzzle can now correctly parse incomplete URLs
532
- * Mixed casing of headers are now forced to be a single consistent casing across all values for that header.
533
- * Messages internally use a HeaderCollection object to delegate handling case-insensitive header resolution
534
- * Removed the whole changedHeader() function system of messages because all header changes now go through addHeader().
535
- * Specific header implementations can be created for complex headers. When a message creates a header, it uses a
536
- HeaderFactory which can map specific headers to specific header classes. There is now a Link header and
537
- CacheControl header implementation.
538
- * Removed from interface: Guzzle\Http\ClientInterface::setUriTemplate
539
- * Removed from interface: Guzzle\Http\ClientInterface::setCurlMulti()
540
- * Removed Guzzle\Http\Message\Request::receivedRequestHeader() and implemented this functionality in
541
- Guzzle\Http\Curl\RequestMediator
542
- * Removed the optional $asString parameter from MessageInterface::getHeader(). Just cast the header to a string.
543
- * Removed the optional $tryChunkedTransfer option from Guzzle\Http\Message\EntityEnclosingRequestInterface
544
- * Removed the $asObjects argument from Guzzle\Http\Message\MessageInterface::getHeaders()
545
- * Removed Guzzle\Parser\ParserRegister::get(). Use getParser()
546
- * Removed Guzzle\Parser\ParserRegister::set(). Use registerParser().
547
- * All response header helper functions return a string rather than mixing Header objects and strings inconsistently
548
- * Removed cURL blacklist support. This is no longer necessary now that Expect, Accept, etc. are managed by Guzzle
549
- directly via interfaces
550
- * Removed the injecting of a request object onto a response object. The methods to get and set a request still exist
551
- but are a no-op until removed.
552
- * Most classes that used to require a `Guzzle\Service\Command\CommandInterface` typehint now request a
553
- `Guzzle\Service\Command\ArrayCommandInterface`.
554
- * Added `Guzzle\Http\Message\RequestInterface::startResponse()` to the RequestInterface to handle injecting a response
555
- on a request while the request is still being transferred
556
- * The ability to case-insensitively search for header values
557
- * Guzzle\Http\Message\Header::hasExactHeader
558
- * Guzzle\Http\Message\Header::raw. Use getAll()
559
- * Deprecated cache control specific methods on Guzzle\Http\Message\AbstractMessage. Use the CacheControl header object
560
- instead.
561
- * `Guzzle\Service\Command\CommandInterface` now extends from ToArrayInterface and ArrayAccess
562
- * Added the ability to cast Model objects to a string to view debug information.
563
-
564
- ## 3.5.0 - 2013-05-13
565
-
566
- * Bug: Fixed a regression so that request responses are parsed only once per oncomplete event rather than multiple times
567
- * Bug: Better cleanup of one-time events across the board (when an event is meant to fire once, it will now remove
568
- itself from the EventDispatcher)
569
- * Bug: `Guzzle\Log\MessageFormatter` now properly writes "total_time" and "connect_time" values
570
- * Bug: Cloning an EntityEnclosingRequest now clones the EntityBody too
571
- * Bug: Fixed an undefined index error when parsing nested JSON responses with a sentAs parameter that reference a
572
- non-existent key
573
- * Bug: All __call() method arguments are now required (helps with mocking frameworks)
574
- * Deprecating Response::getRequest() and now using a shallow clone of a request object to remove a circular reference
575
- to help with refcount based garbage collection of resources created by sending a request
576
- * Deprecating ZF1 cache and log adapters. These will be removed in the next major version.
577
- * Deprecating `Response::getPreviousResponse()` (method signature still exists, but it'sdeprecated). Use the
578
- HistoryPlugin for a history.
579
- * Added a `responseBody` alias for the `response_body` location
580
- * Refactored internals to no longer rely on Response::getRequest()
581
- * HistoryPlugin can now be cast to a string
582
- * HistoryPlugin now logs transactions rather than requests and responses to more accurately keep track of the requests
583
- and responses that are sent over the wire
584
- * Added `getEffectiveUrl()` and `getRedirectCount()` to Response objects
585
-
586
- ## 3.4.3 - 2013-04-30
587
-
588
- * Bug fix: Fixing bug introduced in 3.4.2 where redirect responses are duplicated on the final redirected response
589
- * Added a check to re-extract the temp cacert bundle from the phar before sending each request
590
-
591
- ## 3.4.2 - 2013-04-29
592
-
593
- * Bug fix: Stream objects now work correctly with "a" and "a+" modes
594
- * Bug fix: Removing `Transfer-Encoding: chunked` header when a Content-Length is present
595
- * Bug fix: AsyncPlugin no longer forces HEAD requests
596
- * Bug fix: DateTime timezones are now properly handled when using the service description schema formatter
597
- * Bug fix: CachePlugin now properly handles stale-if-error directives when a request to the origin server fails
598
- * Setting a response on a request will write to the custom request body from the response body if one is specified
599
- * LogPlugin now writes to php://output when STDERR is undefined
600
- * Added the ability to set multiple POST files for the same key in a single call
601
- * application/x-www-form-urlencoded POSTs now use the utf-8 charset by default
602
- * Added the ability to queue CurlExceptions to the MockPlugin
603
- * Cleaned up how manual responses are queued on requests (removed "queued_response" and now using request.before_send)
604
- * Configuration loading now allows remote files
605
-
606
- ## 3.4.1 - 2013-04-16
607
-
608
- * Large refactoring to how CurlMulti handles work. There is now a proxy that sits in front of a pool of CurlMulti
609
- handles. This greatly simplifies the implementation, fixes a couple bugs, and provides a small performance boost.
610
- * Exceptions are now properly grouped when sending requests in parallel
611
- * Redirects are now properly aggregated when a multi transaction fails
612
- * Redirects now set the response on the original object even in the event of a failure
613
- * Bug fix: Model names are now properly set even when using $refs
614
- * Added support for PHP 5.5's CurlFile to prevent warnings with the deprecated @ syntax
615
- * Added support for oauth_callback in OAuth signatures
616
- * Added support for oauth_verifier in OAuth signatures
617
- * Added support to attempt to retrieve a command first literally, then ucfirst, the with inflection
618
-
619
- ## 3.4.0 - 2013-04-11
620
-
621
- * Bug fix: URLs are now resolved correctly based on http://tools.ietf.org/html/rfc3986#section-5.2. #289
622
- * Bug fix: Absolute URLs with a path in a service description will now properly override the base URL. #289
623
- * Bug fix: Parsing a query string with a single PHP array value will now result in an array. #263
624
- * Bug fix: Better normalization of the User-Agent header to prevent duplicate headers. #264.
625
- * Bug fix: Added `number` type to service descriptions.
626
- * Bug fix: empty parameters are removed from an OAuth signature
627
- * Bug fix: Revalidating a cache entry prefers the Last-Modified over the Date header
628
- * Bug fix: Fixed "array to string" error when validating a union of types in a service description
629
- * Bug fix: Removed code that attempted to determine the size of a stream when data is written to the stream
630
- * Bug fix: Not including an `oauth_token` if the value is null in the OauthPlugin.
631
- * Bug fix: Now correctly aggregating successful requests and failed requests in CurlMulti when a redirect occurs.
632
- * The new default CURLOPT_TIMEOUT setting has been increased to 150 seconds so that Guzzle works on poor connections.
633
- * Added a feature to EntityEnclosingRequest::setBody() that will automatically set the Content-Type of the request if
634
- the Content-Type can be determined based on the entity body or the path of the request.
635
- * Added the ability to overwrite configuration settings in a client when grabbing a throwaway client from a builder.
636
- * Added support for a PSR-3 LogAdapter.
637
- * Added a `command.after_prepare` event
638
- * Added `oauth_callback` parameter to the OauthPlugin
639
- * Added the ability to create a custom stream class when using a stream factory
640
- * Added a CachingEntityBody decorator
641
- * Added support for `additionalParameters` in service descriptions to define how custom parameters are serialized.
642
- * The bundled SSL certificate is now provided in the phar file and extracted when running Guzzle from a phar.
643
- * You can now send any EntityEnclosingRequest with POST fields or POST files and cURL will handle creating bodies
644
- * POST requests using a custom entity body are now treated exactly like PUT requests but with a custom cURL method. This
645
- means that the redirect behavior of POST requests with custom bodies will not be the same as POST requests that use
646
- POST fields or files (the latter is only used when emulating a form POST in the browser).
647
- * Lots of cleanup to CurlHandle::factory and RequestFactory::createRequest
648
-
649
- ## 3.3.1 - 2013-03-10
650
-
651
- * Added the ability to create PHP streaming responses from HTTP requests
652
- * Bug fix: Running any filters when parsing response headers with service descriptions
653
- * Bug fix: OauthPlugin fixes to allow for multi-dimensional array signing, and sorting parameters before signing
654
- * Bug fix: Removed the adding of default empty arrays and false Booleans to responses in order to be consistent across
655
- response location visitors.
656
- * Bug fix: Removed the possibility of creating configuration files with circular dependencies
657
- * RequestFactory::create() now uses the key of a POST file when setting the POST file name
658
- * Added xmlAllowEmpty to serialize an XML body even if no XML specific parameters are set
659
-
660
- ## 3.3.0 - 2013-03-03
661
-
662
- * A large number of performance optimizations have been made
663
- * Bug fix: Added 'wb' as a valid write mode for streams
664
- * Bug fix: `Guzzle\Http\Message\Response::json()` now allows scalar values to be returned
665
- * Bug fix: Fixed bug in `Guzzle\Http\Message\Response` where wrapping quotes were stripped from `getEtag()`
666
- * BC: Removed `Guzzle\Http\Utils` class
667
- * BC: Setting a service description on a client will no longer modify the client's command factories.
668
- * BC: Emitting IO events from a RequestMediator is now a parameter that must be set in a request's curl options using
669
- the 'emit_io' key. This was previously set under a request's parameters using 'curl.emit_io'
670
- * BC: `Guzzle\Stream\Stream::getWrapper()` and `Guzzle\Stream\Stream::getSteamType()` are no longer converted to
671
- lowercase
672
- * Operation parameter objects are now lazy loaded internally
673
- * Added ErrorResponsePlugin that can throw errors for responses defined in service description operations' errorResponses
674
- * Added support for instantiating responseType=class responseClass classes. Classes must implement
675
- `Guzzle\Service\Command\ResponseClassInterface`
676
- * Added support for additionalProperties for top-level parameters in responseType=model responseClasses. These
677
- additional properties also support locations and can be used to parse JSON responses where the outermost part of the
678
- JSON is an array
679
- * Added support for nested renaming of JSON models (rename sentAs to name)
680
- * CachePlugin
681
- * Added support for stale-if-error so that the CachePlugin can now serve stale content from the cache on error
682
- * Debug headers can now added to cached response in the CachePlugin
683
-
684
- ## 3.2.0 - 2013-02-14
685
-
686
- * CurlMulti is no longer reused globally. A new multi object is created per-client. This helps to isolate clients.
687
- * URLs with no path no longer contain a "/" by default
688
- * Guzzle\Http\QueryString does no longer manages the leading "?". This is now handled in Guzzle\Http\Url.
689
- * BadResponseException no longer includes the full request and response message
690
- * Adding setData() to Guzzle\Service\Description\ServiceDescriptionInterface
691
- * Adding getResponseBody() to Guzzle\Http\Message\RequestInterface
692
- * Various updates to classes to use ServiceDescriptionInterface type hints rather than ServiceDescription
693
- * Header values can now be normalized into distinct values when multiple headers are combined with a comma separated list
694
- * xmlEncoding can now be customized for the XML declaration of a XML service description operation
695
- * Guzzle\Http\QueryString now uses Guzzle\Http\QueryAggregator\QueryAggregatorInterface objects to add custom value
696
- aggregation and no longer uses callbacks
697
- * The URL encoding implementation of Guzzle\Http\QueryString can now be customized
698
- * Bug fix: Filters were not always invoked for array service description parameters
699
- * Bug fix: Redirects now use a target response body rather than a temporary response body
700
- * Bug fix: The default exponential backoff BackoffPlugin was not giving when the request threshold was exceeded
701
- * Bug fix: Guzzle now takes the first found value when grabbing Cache-Control directives
702
-
703
- ## 3.1.2 - 2013-01-27
704
-
705
- * Refactored how operation responses are parsed. Visitors now include a before() method responsible for parsing the
706
- response body. For example, the XmlVisitor now parses the XML response into an array in the before() method.
707
- * Fixed an issue where cURL would not automatically decompress responses when the Accept-Encoding header was sent
708
- * CURLOPT_SSL_VERIFYHOST is never set to 1 because it is deprecated (see 5e0ff2ef20f839e19d1eeb298f90ba3598784444)
709
- * Fixed a bug where redirect responses were not chained correctly using getPreviousResponse()
710
- * Setting default headers on a client after setting the user-agent will not erase the user-agent setting
711
-
712
- ## 3.1.1 - 2013-01-20
713
-
714
- * Adding wildcard support to Guzzle\Common\Collection::getPath()
715
- * Adding alias support to ServiceBuilder configs
716
- * Adding Guzzle\Service\Resource\CompositeResourceIteratorFactory and cleaning up factory interface
717
-
718
- ## 3.1.0 - 2013-01-12
719
-
720
- * BC: CurlException now extends from RequestException rather than BadResponseException
721
- * BC: Renamed Guzzle\Plugin\Cache\CanCacheStrategyInterface::canCache() to canCacheRequest() and added CanCacheResponse()
722
- * Added getData to ServiceDescriptionInterface
723
- * Added context array to RequestInterface::setState()
724
- * Bug: Removing hard dependency on the BackoffPlugin from Guzzle\Http
725
- * Bug: Adding required content-type when JSON request visitor adds JSON to a command
726
- * Bug: Fixing the serialization of a service description with custom data
727
- * Made it easier to deal with exceptions thrown when transferring commands or requests in parallel by providing
728
- an array of successful and failed responses
729
- * Moved getPath from Guzzle\Service\Resource\Model to Guzzle\Common\Collection
730
- * Added Guzzle\Http\IoEmittingEntityBody
731
- * Moved command filtration from validators to location visitors
732
- * Added `extends` attributes to service description parameters
733
- * Added getModels to ServiceDescriptionInterface
734
-
735
- ## 3.0.7 - 2012-12-19
736
-
737
- * Fixing phar detection when forcing a cacert to system if null or true
738
- * Allowing filename to be passed to `Guzzle\Http\Message\Request::setResponseBody()`
739
- * Cleaning up `Guzzle\Common\Collection::inject` method
740
- * Adding a response_body location to service descriptions
741
-
742
- ## 3.0.6 - 2012-12-09
743
-
744
- * CurlMulti performance improvements
745
- * Adding setErrorResponses() to Operation
746
- * composer.json tweaks
747
-
748
- ## 3.0.5 - 2012-11-18
749
-
750
- * Bug: Fixing an infinite recursion bug caused from revalidating with the CachePlugin
751
- * Bug: Response body can now be a string containing "0"
752
- * Bug: Using Guzzle inside of a phar uses system by default but now allows for a custom cacert
753
- * Bug: QueryString::fromString now properly parses query string parameters that contain equal signs
754
- * Added support for XML attributes in service description responses
755
- * DefaultRequestSerializer now supports array URI parameter values for URI template expansion
756
- * Added better mimetype guessing to requests and post files
757
-
758
- ## 3.0.4 - 2012-11-11
759
-
760
- * Bug: Fixed a bug when adding multiple cookies to a request to use the correct glue value
761
- * Bug: Cookies can now be added that have a name, domain, or value set to "0"
762
- * Bug: Using the system cacert bundle when using the Phar
763
- * Added json and xml methods to Response to make it easier to parse JSON and XML response data into data structures
764
- * Enhanced cookie jar de-duplication
765
- * Added the ability to enable strict cookie jars that throw exceptions when invalid cookies are added
766
- * Added setStream to StreamInterface to actually make it possible to implement custom rewind behavior for entity bodies
767
- * Added the ability to create any sort of hash for a stream rather than just an MD5 hash
768
-
769
- ## 3.0.3 - 2012-11-04
770
-
771
- * Implementing redirects in PHP rather than cURL
772
- * Added PECL URI template extension and using as default parser if available
773
- * Bug: Fixed Content-Length parsing of Response factory
774
- * Adding rewind() method to entity bodies and streams. Allows for custom rewinding of non-repeatable streams.
775
- * Adding ToArrayInterface throughout library
776
- * Fixing OauthPlugin to create unique nonce values per request
777
-
778
- ## 3.0.2 - 2012-10-25
779
-
780
- * Magic methods are enabled by default on clients
781
- * Magic methods return the result of a command
782
- * Service clients no longer require a base_url option in the factory
783
- * Bug: Fixed an issue with URI templates where null template variables were being expanded
784
-
785
- ## 3.0.1 - 2012-10-22
786
-
787
- * Models can now be used like regular collection objects by calling filter, map, etc.
788
- * Models no longer require a Parameter structure or initial data in the constructor
789
- * Added a custom AppendIterator to get around a PHP bug with the `\AppendIterator`
790
-
791
- ## 3.0.0 - 2012-10-15
792
-
793
- * Rewrote service description format to be based on Swagger
794
- * Now based on JSON schema
795
- * Added nested input structures and nested response models
796
- * Support for JSON and XML input and output models
797
- * Renamed `commands` to `operations`
798
- * Removed dot class notation
799
- * Removed custom types
800
- * Broke the project into smaller top-level namespaces to be more component friendly
801
- * Removed support for XML configs and descriptions. Use arrays or JSON files.
802
- * Removed the Validation component and Inspector
803
- * Moved all cookie code to Guzzle\Plugin\Cookie
804
- * Magic methods on a Guzzle\Service\Client now return the command un-executed.
805
- * Calling getResult() or getResponse() on a command will lazily execute the command if needed.
806
- * Now shipping with cURL's CA certs and using it by default
807
- * Added previousResponse() method to response objects
808
- * No longer sending Accept and Accept-Encoding headers on every request
809
- * Only sending an Expect header by default when a payload is greater than 1MB
810
- * Added/moved client options:
811
- * curl.blacklist to curl.option.blacklist
812
- * Added ssl.certificate_authority
813
- * Added a Guzzle\Iterator component
814
- * Moved plugins from Guzzle\Http\Plugin to Guzzle\Plugin
815
- * Added a more robust backoff retry strategy (replaced the ExponentialBackoffPlugin)
816
- * Added a more robust caching plugin
817
- * Added setBody to response objects
818
- * Updating LogPlugin to use a more flexible MessageFormatter
819
- * Added a completely revamped build process
820
- * Cleaning up Collection class and removing default values from the get method
821
- * Fixed ZF2 cache adapters
822
-
823
- ## 2.8.8 - 2012-10-15
824
-
825
- * Bug: Fixed a cookie issue that caused dot prefixed domains to not match where popular browsers did
826
-
827
- ## 2.8.7 - 2012-09-30
828
-
829
- * Bug: Fixed config file aliases for JSON includes
830
- * Bug: Fixed cookie bug on a request object by using CookieParser to parse cookies on requests
831
- * Bug: Removing the path to a file when sending a Content-Disposition header on a POST upload
832
- * Bug: Hardening request and response parsing to account for missing parts
833
- * Bug: Fixed PEAR packaging
834
- * Bug: Fixed Request::getInfo
835
- * Bug: Fixed cases where CURLM_CALL_MULTI_PERFORM return codes were causing curl transactions to fail
836
- * Adding the ability for the namespace Iterator factory to look in multiple directories
837
- * Added more getters/setters/removers from service descriptions
838
- * Added the ability to remove POST fields from OAuth signatures
839
- * OAuth plugin now supports 2-legged OAuth
840
-
841
- ## 2.8.6 - 2012-09-05
842
-
843
- * Added the ability to modify and build service descriptions
844
- * Added the use of visitors to apply parameters to locations in service descriptions using the dynamic command
845
- * Added a `json` parameter location
846
- * Now allowing dot notation for classes in the CacheAdapterFactory
847
- * Using the union of two arrays rather than an array_merge when extending service builder services and service params
848
- * Ensuring that a service is a string before doing strpos() checks on it when substituting services for references
849
- in service builder config files.
850
- * Services defined in two different config files that include one another will by default replace the previously
851
- defined service, but you can now create services that extend themselves and merge their settings over the previous
852
- * The JsonLoader now supports aliasing filenames with different filenames. This allows you to alias something like
853
- '_default' with a default JSON configuration file.
854
-
855
- ## 2.8.5 - 2012-08-29
856
-
857
- * Bug: Suppressed empty arrays from URI templates
858
- * Bug: Added the missing $options argument from ServiceDescription::factory to enable caching
859
- * Added support for HTTP responses that do not contain a reason phrase in the start-line
860
- * AbstractCommand commands are now invokable
861
- * Added a way to get the data used when signing an Oauth request before a request is sent
862
-
863
- ## 2.8.4 - 2012-08-15
864
-
865
- * Bug: Custom delay time calculations are no longer ignored in the ExponentialBackoffPlugin
866
- * 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.
867
- * Added a StreamInterface, EntityBodyInterface, and added ftell() to Guzzle\Common\Stream
868
- * Added an AbstractEntityBodyDecorator and a ReadLimitEntityBody decorator to transfer only a subset of a decorated stream
869
- * Stream and EntityBody objects will now return the file position to the previous position after a read required operation (e.g. getContentMd5())
870
- * Added additional response status codes
871
- * Removed SSL information from the default User-Agent header
872
- * DELETE requests can now send an entity body
873
- * Added an EventDispatcher to the ExponentialBackoffPlugin and added an ExponentialBackoffLogger to log backoff retries
874
- * Added the ability of the MockPlugin to consume mocked request bodies
875
- * LogPlugin now exposes request and response objects in the extras array
876
-
877
- ## 2.8.3 - 2012-07-30
878
-
879
- * Bug: Fixed a case where empty POST requests were sent as GET requests
880
- * Bug: Fixed a bug in ExponentialBackoffPlugin that caused fatal errors when retrying an EntityEnclosingRequest that does not have a body
881
- * Bug: Setting the response body of a request to null after completing a request, not when setting the state of a request to new
882
- * Added multiple inheritance to service description commands
883
- * Added an ApiCommandInterface and added `getParamNames()` and `hasParam()`
884
- * Removed the default 2mb size cutoff from the Md5ValidatorPlugin so that it now defaults to validating everything
885
- * Changed CurlMulti::perform to pass a smaller timeout to CurlMulti::executeHandles
886
-
887
- ## 2.8.2 - 2012-07-24
888
-
889
- * Bug: Query string values set to 0 are no longer dropped from the query string
890
- * Bug: A Collection object is no longer created each time a call is made to `Guzzle\Service\Command\AbstractCommand::getRequestHeaders()`
891
- * Bug: `+` is now treated as an encoded space when parsing query strings
892
- * QueryString and Collection performance improvements
893
- * Allowing dot notation for class paths in filters attribute of a service descriptions
894
-
895
- ## 2.8.1 - 2012-07-16
896
-
897
- * Loosening Event Dispatcher dependency
898
- * POST redirects can now be customized using CURLOPT_POSTREDIR
899
-
900
- ## 2.8.0 - 2012-07-15
901
-
902
- * BC: Guzzle\Http\Query
903
- * Query strings with empty variables will always show an equal sign unless the variable is set to QueryString::BLANK (e.g. ?acl= vs ?acl)
904
- * Changed isEncodingValues() and isEncodingFields() to isUrlEncoding()
905
- * Changed setEncodeValues(bool) and setEncodeFields(bool) to useUrlEncoding(bool)
906
- * Changed the aggregation functions of QueryString to be static methods
907
- * Can now use fromString() with querystrings that have a leading ?
908
- * cURL configuration values can be specified in service descriptions using `curl.` prefixed parameters
909
- * Content-Length is set to 0 before emitting the request.before_send event when sending an empty request body
910
- * Cookies are no longer URL decoded by default
911
- * Bug: URI template variables set to null are no longer expanded
912
-
913
- ## 2.7.2 - 2012-07-02
914
-
915
- * BC: Moving things to get ready for subtree splits. Moving Inflection into Common. Moving Guzzle\Http\Parser to Guzzle\Parser.
916
- * BC: Removing Guzzle\Common\Batch\Batch::count() and replacing it with isEmpty()
917
- * CachePlugin now allows for a custom request parameter function to check if a request can be cached
918
- * Bug fix: CachePlugin now only caches GET and HEAD requests by default
919
- * Bug fix: Using header glue when transferring headers over the wire
920
- * Allowing deeply nested arrays for composite variables in URI templates
921
- * Batch divisors can now return iterators or arrays
922
-
923
- ## 2.7.1 - 2012-06-26
924
-
925
- * Minor patch to update version number in UA string
926
- * Updating build process
927
-
928
- ## 2.7.0 - 2012-06-25
929
-
930
- * BC: Inflection classes moved to Guzzle\Inflection. No longer static methods. Can now inject custom inflectors into classes.
931
- * BC: Removed magic setX methods from commands
932
- * BC: Magic methods mapped to service description commands are now inflected in the command factory rather than the client __call() method
933
- * Verbose cURL options are no longer enabled by default. Set curl.debug to true on a client to enable.
934
- * Bug: Now allowing colons in a response start-line (e.g. HTTP/1.1 503 Service Unavailable: Back-end server is at capacity)
935
- * Guzzle\Service\Resource\ResourceIteratorApplyBatched now internally uses the Guzzle\Common\Batch namespace
936
- * Added Guzzle\Service\Plugin namespace and a PluginCollectionPlugin
937
- * Added the ability to set POST fields and files in a service description
938
- * Guzzle\Http\EntityBody::factory() now accepts objects with a __toString() method
939
- * Adding a command.before_prepare event to clients
940
- * Added BatchClosureTransfer and BatchClosureDivisor
941
- * BatchTransferException now includes references to the batch divisor and transfer strategies
942
- * Fixed some tests so that they pass more reliably
943
- * Added Guzzle\Common\Log\ArrayLogAdapter
944
-
945
- ## 2.6.6 - 2012-06-10
946
-
947
- * BC: Removing Guzzle\Http\Plugin\BatchQueuePlugin
948
- * BC: Removing Guzzle\Service\Command\CommandSet
949
- * Adding generic batching system (replaces the batch queue plugin and command set)
950
- * Updating ZF cache and log adapters and now using ZF's composer repository
951
- * Bug: Setting the name of each ApiParam when creating through an ApiCommand
952
- * Adding result_type, result_doc, deprecated, and doc_url to service descriptions
953
- * Bug: Changed the default cookie header casing back to 'Cookie'
954
-
955
- ## 2.6.5 - 2012-06-03
956
-
957
- * BC: Renaming Guzzle\Http\Message\RequestInterface::getResourceUri() to getResource()
958
- * BC: Removing unused AUTH_BASIC and AUTH_DIGEST constants from
959
- * BC: Guzzle\Http\Cookie is now used to manage Set-Cookie data, not Cookie data
960
- * BC: Renaming methods in the CookieJarInterface
961
- * Moving almost all cookie logic out of the CookiePlugin and into the Cookie or CookieJar implementations
962
- * Making the default glue for HTTP headers ';' instead of ','
963
- * Adding a removeValue to Guzzle\Http\Message\Header
964
- * Adding getCookies() to request interface.
965
- * Making it easier to add event subscribers to HasDispatcherInterface classes. Can now directly call addSubscriber()
966
-
967
- ## 2.6.4 - 2012-05-30
968
-
969
- * BC: Cleaning up how POST files are stored in EntityEnclosingRequest objects. Adding PostFile class.
970
- * BC: Moving ApiCommand specific functionality from the Inspector and on to the ApiCommand
971
- * Bug: Fixing magic method command calls on clients
972
- * Bug: Email constraint only validates strings
973
- * Bug: Aggregate POST fields when POST files are present in curl handle
974
- * Bug: Fixing default User-Agent header
975
- * Bug: Only appending or prepending parameters in commands if they are specified
976
- * Bug: Not requiring response reason phrases or status codes to match a predefined list of codes
977
- * Allowing the use of dot notation for class namespaces when using instance_of constraint
978
- * Added any_match validation constraint
979
- * Added an AsyncPlugin
980
- * Passing request object to the calculateWait method of the ExponentialBackoffPlugin
981
- * Allowing the result of a command object to be changed
982
- * Parsing location and type sub values when instantiating a service description rather than over and over at runtime
983
-
984
- ## 2.6.3 - 2012-05-23
985
-
986
- * [BC] Guzzle\Common\FromConfigInterface no longer requires any config options.
987
- * [BC] Refactoring how POST files are stored on an EntityEnclosingRequest. They are now separate from POST fields.
988
- * You can now use an array of data when creating PUT request bodies in the request factory.
989
- * Removing the requirement that HTTPS requests needed a Cache-Control: public directive to be cacheable.
990
- * [Http] Adding support for Content-Type in multipart POST uploads per upload
991
- * [Http] Added support for uploading multiple files using the same name (foo[0], foo[1])
992
- * Adding more POST data operations for easier manipulation of POST data.
993
- * You can now set empty POST fields.
994
- * The body of a request is only shown on EntityEnclosingRequest objects that do not use POST files.
995
- * Split the Guzzle\Service\Inspector::validateConfig method into two methods. One to initialize when a command is created, and one to validate.
996
- * CS updates
997
-
998
- ## 2.6.2 - 2012-05-19
999
-
1000
- * [Http] Better handling of nested scope requests in CurlMulti. Requests are now always prepares in the send() method rather than the addRequest() method.
1001
-
1002
- ## 2.6.1 - 2012-05-19
1003
-
1004
- * [BC] Removing 'path' support in service descriptions. Use 'uri'.
1005
- * [BC] Guzzle\Service\Inspector::parseDocBlock is now protected. Adding getApiParamsForClass() with cache.
1006
- * [BC] Removing Guzzle\Common\NullObject. Use https://github.com/mtdowling/NullObject if you need it.
1007
- * [BC] Removing Guzzle\Common\XmlElement.
1008
- * All commands, both dynamic and concrete, have ApiCommand objects.
1009
- * Adding a fix for CurlMulti so that if all of the connections encounter some sort of curl error, then the loop exits.
1010
- * Adding checks to EntityEnclosingRequest so that empty POST files and fields are ignored.
1011
- * Making the method signature of Guzzle\Service\Builder\ServiceBuilder::factory more flexible.
1012
-
1013
- ## 2.6.0 - 2012-05-15
1014
-
1015
- * [BC] Moving Guzzle\Service\Builder to Guzzle\Service\Builder\ServiceBuilder
1016
- * [BC] Executing a Command returns the result of the command rather than the command
1017
- * [BC] Moving all HTTP parsing logic to Guzzle\Http\Parsers. Allows for faster C implementations if needed.
1018
- * [BC] Changing the Guzzle\Http\Message\Response::setProtocol() method to accept a protocol and version in separate args.
1019
- * [BC] Moving ResourceIterator* to Guzzle\Service\Resource
1020
- * [BC] Completely refactored ResourceIterators to iterate over a cloned command object
1021
- * [BC] Moved Guzzle\Http\UriTemplate to Guzzle\Http\Parser\UriTemplate\UriTemplate
1022
- * [BC] Guzzle\Guzzle is now deprecated
1023
- * Moving Guzzle\Common\Guzzle::inject to Guzzle\Common\Collection::inject
1024
- * Adding Guzzle\Version class to give version information about Guzzle
1025
- * Adding Guzzle\Http\Utils class to provide getDefaultUserAgent() and getHttpDate()
1026
- * Adding Guzzle\Curl\CurlVersion to manage caching curl_version() data
1027
- * ServiceDescription and ServiceBuilder are now cacheable using similar configs
1028
- * Changing the format of XML and JSON service builder configs. Backwards compatible.
1029
- * Cleaned up Cookie parsing
1030
- * Trimming the default Guzzle User-Agent header
1031
- * Adding a setOnComplete() method to Commands that is called when a command completes
1032
- * Keeping track of requests that were mocked in the MockPlugin
1033
- * Fixed a caching bug in the CacheAdapterFactory
1034
- * Inspector objects can be injected into a Command object
1035
- * Refactoring a lot of code and tests to be case insensitive when dealing with headers
1036
- * Adding Guzzle\Http\Message\HeaderComparison for easy comparison of HTTP headers using a DSL
1037
- * Adding the ability to set global option overrides to service builder configs
1038
- * Adding the ability to include other service builder config files from within XML and JSON files
1039
- * Moving the parseQuery method out of Url and on to QueryString::fromString() as a static factory method.
1040
-
1041
- ## 2.5.0 - 2012-05-08
1042
-
1043
- * Major performance improvements
1044
- * [BC] Simplifying Guzzle\Common\Collection. Please check to see if you are using features that are now deprecated.
1045
- * [BC] Using a custom validation system that allows a flyweight implementation for much faster validation. No longer using Symfony2 Validation component.
1046
- * [BC] No longer supporting "{{ }}" for injecting into command or UriTemplates. Use "{}"
1047
- * Added the ability to passed parameters to all requests created by a client
1048
- * Added callback functionality to the ExponentialBackoffPlugin
1049
- * Using microtime in ExponentialBackoffPlugin to allow more granular backoff strategies.
1050
- * Rewinding request stream bodies when retrying requests
1051
- * Exception is thrown when JSON response body cannot be decoded
1052
- * Added configurable magic method calls to clients and commands. This is off by default.
1053
- * Fixed a defect that added a hash to every parsed URL part
1054
- * Fixed duplicate none generation for OauthPlugin.
1055
- * Emitting an event each time a client is generated by a ServiceBuilder
1056
- * Using an ApiParams object instead of a Collection for parameters of an ApiCommand
1057
- * cache.* request parameters should be renamed to params.cache.*
1058
- * Added the ability to set arbitrary curl options on requests (disable_wire, progress, etc.). See CurlHandle.
1059
- * Added the ability to disable type validation of service descriptions
1060
- * ServiceDescriptions and ServiceBuilders are now Serializable
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/LICENSE DELETED
@@ -1,19 +0,0 @@
1
- Copyright (c) 2011-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.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/README.md DELETED
@@ -1,70 +0,0 @@
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/.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/UPGRADING.md DELETED
@@ -1,1050 +0,0 @@
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.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/composer.json DELETED
@@ -1,33 +0,0 @@
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
- "phpunit/phpunit": "^4.0"
22
- },
23
- "autoload": {
24
- "psr-4": {
25
- "GuzzleHttp\\": "src/"
26
- }
27
- },
28
- "autoload-dev": {
29
- "psr-4": {
30
- "GuzzleHttp\\Tests\\": "tests/"
31
- }
32
- }
33
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/BatchResults.php DELETED
@@ -1,148 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Client.php DELETED
@@ -1,355 +0,0 @@
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
- // We can only trust the HTTP_PROXY environment variable in a CLI
204
- // process due to the fact that PHP has no reliable mechanism to
205
- // get environment variables that start with "HTTP_".
206
- if (php_sapi_name() == 'cli' && getenv('HTTP_PROXY')) {
207
- $settings['proxy']['http'] = getenv('HTTP_PROXY');
208
- }
209
-
210
- if ($proxy = getenv('HTTPS_PROXY')) {
211
- $settings['proxy']['https'] = $proxy;
212
- }
213
-
214
- return $settings;
215
- }
216
-
217
- /**
218
- * Expand a URI template and inherit from the base URL if it's relative
219
- *
220
- * @param string|array $url URL or an array of the URI template to expand
221
- * followed by a hash of template varnames.
222
- * @return string
223
- * @throws \InvalidArgumentException
224
- */
225
- private function buildUrl($url)
226
- {
227
- // URI template (absolute or relative)
228
- if (!is_array($url)) {
229
- return strpos($url, '://')
230
- ? (string) $url
231
- : (string) $this->baseUrl->combine($url);
232
- }
233
-
234
- if (!isset($url[1])) {
235
- throw new \InvalidArgumentException('You must provide a hash of '
236
- . 'varname options in the second element of a URL array.');
237
- }
238
-
239
- // Absolute URL
240
- if (strpos($url[0], '://')) {
241
- return Utils::uriTemplate($url[0], $url[1]);
242
- }
243
-
244
- // Combine the relative URL with the base URL
245
- return (string) $this->baseUrl->combine(
246
- Utils::uriTemplate($url[0], $url[1])
247
- );
248
- }
249
-
250
- private function configureBaseUrl(&$config)
251
- {
252
- if (!isset($config['base_url'])) {
253
- $this->baseUrl = new Url('', '');
254
- } elseif (!is_array($config['base_url'])) {
255
- $this->baseUrl = Url::fromString($config['base_url']);
256
- } elseif (count($config['base_url']) < 2) {
257
- throw new \InvalidArgumentException('You must provide a hash of '
258
- . 'varname options in the second element of a base_url array.');
259
- } else {
260
- $this->baseUrl = Url::fromString(
261
- Utils::uriTemplate(
262
- $config['base_url'][0],
263
- $config['base_url'][1]
264
- )
265
- );
266
- $config['base_url'] = (string) $this->baseUrl;
267
- }
268
- }
269
-
270
- private function configureDefaults($config)
271
- {
272
- if (!isset($config['defaults'])) {
273
- $this->defaults = $this->getDefaultOptions();
274
- } else {
275
- $this->defaults = array_replace(
276
- $this->getDefaultOptions(),
277
- $config['defaults']
278
- );
279
- }
280
-
281
- // Add the default user-agent header
282
- if (!isset($this->defaults['headers'])) {
283
- $this->defaults['headers'] = [
284
- 'User-Agent' => Utils::getDefaultUserAgent()
285
- ];
286
- } elseif (!Core::hasHeader($this->defaults, 'User-Agent')) {
287
- // Add the User-Agent header if one was not already set
288
- $this->defaults['headers']['User-Agent'] = Utils::getDefaultUserAgent();
289
- }
290
- }
291
-
292
- /**
293
- * Merges default options into the array passed by reference.
294
- *
295
- * @param array $options Options to modify by reference
296
- *
297
- * @return array
298
- */
299
- private function mergeDefaults($options)
300
- {
301
- $defaults = $this->defaults;
302
-
303
- // Case-insensitively merge in default headers if both defaults and
304
- // options have headers specified.
305
- if (!empty($defaults['headers']) && !empty($options['headers'])) {
306
- // Create a set of lowercased keys that are present.
307
- $lkeys = [];
308
- foreach (array_keys($options['headers']) as $k) {
309
- $lkeys[strtolower($k)] = true;
310
- }
311
- // Merge in lowercase default keys when not present in above set.
312
- foreach ($defaults['headers'] as $key => $value) {
313
- if (!isset($lkeys[strtolower($key)])) {
314
- $options['headers'][$key] = $value;
315
- }
316
- }
317
- // No longer need to merge in headers.
318
- unset($defaults['headers']);
319
- }
320
-
321
- $result = array_replace_recursive($defaults, $options);
322
- foreach ($options as $k => $v) {
323
- if ($v === null) {
324
- unset($result[$k]);
325
- }
326
- }
327
-
328
- return $result;
329
- }
330
-
331
- /**
332
- * @deprecated Use {@see GuzzleHttp\Pool} instead.
333
- * @see GuzzleHttp\Pool
334
- */
335
- public function sendAll($requests, array $options = [])
336
- {
337
- Pool::send($this, $requests, $options);
338
- }
339
-
340
- /**
341
- * @deprecated Use GuzzleHttp\Utils::getDefaultHandler
342
- */
343
- public static function getDefaultHandler()
344
- {
345
- return Utils::getDefaultHandler();
346
- }
347
-
348
- /**
349
- * @deprecated Use GuzzleHttp\Utils::getDefaultUserAgent
350
- */
351
- public static function getDefaultUserAgent()
352
- {
353
- return Utils::getDefaultUserAgent();
354
- }
355
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/ClientInterface.php DELETED
@@ -1,150 +0,0 @@
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.1';
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Collection.php DELETED
@@ -1,236 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php DELETED
@@ -1,248 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php DELETED
@@ -1,75 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php DELETED
@@ -1,86 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php DELETED
@@ -1,66 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php DELETED
@@ -1,373 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Event/AbstractEvent.php DELETED
@@ -1,20 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Event/AbstractRequestEvent.php DELETED
@@ -1,61 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Event/AbstractRetryableEvent.php DELETED
@@ -1,40 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Event/AbstractTransferEvent.php DELETED
@@ -1,63 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Event/BeforeEvent.php DELETED
@@ -1,26 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Event/CompleteEvent.php DELETED
@@ -1,14 +0,0 @@
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 {}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Event/Emitter.php DELETED
@@ -1,145 +0,0 @@
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
- ) use (&$onceListener, $eventName, $listener, $priority) {
48
- $this->removeListener($eventName, $onceListener);
49
- $listener($event, $eventName);
50
- };
51
-
52
- $this->on($eventName, $onceListener, $priority);
53
- }
54
-
55
- public function removeListener($eventName, callable $listener)
56
- {
57
- if (empty($this->listeners[$eventName])) {
58
- return;
59
- }
60
-
61
- foreach ($this->listeners[$eventName] as $priority => $listeners) {
62
- if (false !== ($key = array_search($listener, $listeners, true))) {
63
- unset(
64
- $this->listeners[$eventName][$priority][$key],
65
- $this->sorted[$eventName]
66
- );
67
- }
68
- }
69
- }
70
-
71
- public function listeners($eventName = null)
72
- {
73
- // Return all events in a sorted priority order
74
- if ($eventName === null) {
75
- foreach (array_keys($this->listeners) as $eventName) {
76
- if (empty($this->sorted[$eventName])) {
77
- $this->listeners($eventName);
78
- }
79
- }
80
- return $this->sorted;
81
- }
82
-
83
- // Return the listeners for a specific event, sorted in priority order
84
- if (empty($this->sorted[$eventName])) {
85
- $this->sorted[$eventName] = [];
86
- if (isset($this->listeners[$eventName])) {
87
- krsort($this->listeners[$eventName], SORT_NUMERIC);
88
- foreach ($this->listeners[$eventName] as $listeners) {
89
- foreach ($listeners as $listener) {
90
- $this->sorted[$eventName][] = $listener;
91
- }
92
- }
93
- }
94
- }
95
-
96
- return $this->sorted[$eventName];
97
- }
98
-
99
- public function hasListeners($eventName)
100
- {
101
- return !empty($this->listeners[$eventName]);
102
- }
103
-
104
- public function emit($eventName, EventInterface $event)
105
- {
106
- if (isset($this->listeners[$eventName])) {
107
- foreach ($this->listeners($eventName) as $listener) {
108
- $listener($event, $eventName);
109
- if ($event->isPropagationStopped()) {
110
- break;
111
- }
112
- }
113
- }
114
-
115
- return $event;
116
- }
117
-
118
- public function attach(SubscriberInterface $subscriber)
119
- {
120
- foreach ($subscriber->getEvents() as $eventName => $listeners) {
121
- if (is_array($listeners[0])) {
122
- foreach ($listeners as $listener) {
123
- $this->on(
124
- $eventName,
125
- [$subscriber, $listener[0]],
126
- isset($listener[1]) ? $listener[1] : 0
127
- );
128
- }
129
- } else {
130
- $this->on(
131
- $eventName,
132
- [$subscriber, $listeners[0]],
133
- isset($listeners[1]) ? $listeners[1] : 0
134
- );
135
- }
136
- }
137
- }
138
-
139
- public function detach(SubscriberInterface $subscriber)
140
- {
141
- foreach ($subscriber->getEvents() as $eventName => $listener) {
142
- $this->removeListener($eventName, [$subscriber, $listener[0]]);
143
- }
144
- }
145
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Event/EmitterInterface.php DELETED
@@ -1,96 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Event/EndEvent.php DELETED
@@ -1,28 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Event/ErrorEvent.php DELETED
@@ -1,27 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Event/EventInterface.php DELETED
@@ -1,23 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Event/HasEmitterInterface.php DELETED
@@ -1,15 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Event/HasEmitterTrait.php DELETED
@@ -1,20 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Event/ListenerAttacherTrait.php DELETED
@@ -1,88 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Event/ProgressEvent.php DELETED
@@ -1,51 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Event/RequestEvents.php DELETED
@@ -1,56 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Event/SubscriberInterface.php DELETED
@@ -1,34 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Exception/BadResponseException.php DELETED
@@ -1,7 +0,0 @@
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 {}
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Exception/ClientException.php DELETED
@@ -1,7 +0,0 @@
1
- <?php
2
- namespace GuzzleHttp\Exception;
3
-
4
- /**
5
- * Exception when a client error is encountered (4xx codes)
6
- */
7
- class ClientException extends BadResponseException {}
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Exception/ConnectException.php DELETED
@@ -1,4 +0,0 @@
1
- <?php
2
- namespace GuzzleHttp\Exception;
3
-
4
- class ConnectException extends RequestException {}
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Exception/CouldNotRewindStreamException.php DELETED
@@ -1,4 +0,0 @@
1
- <?php
2
- namespace GuzzleHttp\Exception;
3
-
4
- class CouldNotRewindStreamException extends RequestException {}
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Exception/ParseException.php DELETED
@@ -1,31 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php DELETED
@@ -1,121 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Exception/ServerException.php DELETED
@@ -1,7 +0,0 @@
1
- <?php
2
- namespace GuzzleHttp\Exception;
3
-
4
- /**
5
- * Exception when a server error is encountered (5xx codes)
6
- */
7
- class ServerException extends BadResponseException {}
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Exception/StateException.php DELETED
@@ -1,4 +0,0 @@
1
- <?php
2
- namespace GuzzleHttp\Exception;
3
-
4
- class StateException extends TransferException {};
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Exception/TooManyRedirectsException.php DELETED
@@ -1,4 +0,0 @@
1
- <?php
2
- namespace GuzzleHttp\Exception;
3
-
4
- class TooManyRedirectsException extends RequestException {}
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Exception/TransferException.php DELETED
@@ -1,4 +0,0 @@
1
- <?php
2
- namespace GuzzleHttp\Exception;
3
-
4
- class TransferException extends \RuntimeException {}
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Exception/XmlParseException.php DELETED
@@ -1,34 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/HasDataTrait.php DELETED
@@ -1,75 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Message/AbstractMessage.php DELETED
@@ -1,253 +0,0 @@
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->addHeader($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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Message/AppliesHeadersInterface.php DELETED
@@ -1,24 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Message/FutureResponse.php DELETED
@@ -1,158 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Message/MessageFactory.php DELETED
@@ -1,364 +0,0 @@
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 (strtoupper($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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Message/MessageFactoryInterface.php DELETED
@@ -1,71 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Message/MessageInterface.php DELETED
@@ -1,136 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Message/MessageParser.php DELETED
@@ -1,171 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Message/Request.php DELETED
@@ -1,195 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Message/RequestInterface.php DELETED
@@ -1,136 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Message/Response.php DELETED
@@ -1,208 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Message/ResponseInterface.php DELETED
@@ -1,111 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Mimetypes.php DELETED
@@ -1,963 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Pool.php DELETED
@@ -1,333 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Post/MultipartBody.php DELETED
@@ -1,109 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Post/PostBody.php DELETED
@@ -1,287 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Post/PostBodyInterface.php DELETED
@@ -1,109 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Post/PostFile.php DELETED
@@ -1,135 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Post/PostFileInterface.php DELETED
@@ -1,41 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Query.php DELETED
@@ -1,204 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/QueryParser.php DELETED
@@ -1,163 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/RequestFsm.php DELETED
@@ -1,153 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/RingBridge.php DELETED
@@ -1,165 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Subscriber/Cookie.php DELETED
@@ -1,58 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Subscriber/History.php DELETED
@@ -1,172 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Subscriber/HttpError.php DELETED
@@ -1,36 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Subscriber/Mock.php DELETED
@@ -1,147 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Subscriber/Prepare.php DELETED
@@ -1,130 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Subscriber/Redirect.php DELETED
@@ -1,176 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/ToArrayInterface.php DELETED
@@ -1,15 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Transaction.php DELETED
@@ -1,103 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/UriTemplate.php DELETED
@@ -1,241 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Url.php DELETED
@@ -1,595 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/guzzle/src/Utils.php DELETED
@@ -1,211 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/psr7/.gitignore DELETED
@@ -1,11 +0,0 @@
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
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/psr7/.travis.yml DELETED
@@ -1,20 +0,0 @@
1
- language: php
2
-
3
- php:
4
- - 5.4
5
- - 5.5
6
- - 5.6
7
- - 7.0
8
- - hhvm
9
-
10
- sudo: false
11
-
12
- install:
13
- - travis_retry composer install --no-interaction --prefer-source
14
-
15
- script: make test
16
-
17
- matrix:
18
- allow_failures:
19
- - php: hhvm
20
- fast_finish: true
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/psr7/CHANGELOG.md DELETED
@@ -1,28 +0,0 @@
1
- # CHANGELOG
2
-
3
- ## 1.2.0 - 2015-08-15
4
-
5
- * Body as `"0"` is now properly added to a response.
6
- * Now allowing forward seeking in CachingStream.
7
- * Now properly parsing HTTP requests that contain proxy targets in
8
- `parse_request`.
9
- * functions.php is now conditionally required.
10
- * user-info is no longer dropped when resolving URIs.
11
-
12
- ## 1.1.0 - 2015-06-24
13
-
14
- * URIs can now be relative.
15
- * `multipart/form-data` headers are now overridden case-insensitively.
16
- * URI paths no longer encode the following characters because they are allowed
17
- in URIs: "(", ")", "*", "!", "'"
18
- * A port is no longer added to a URI when the scheme is missing and no port is
19
- present.
20
-
21
- ## 1.0.0 - 2015-05-19
22
-
23
- Initial release.
24
-
25
- Currently unsupported:
26
-
27
- - `Psr\Http\Message\ServerRequestInterface`
28
- - `Psr\Http\Message\UploadedFileInterface`
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/psr7/LICENSE DELETED
@@ -1,19 +0,0 @@
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.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/psr7/Makefile DELETED
@@ -1,13 +0,0 @@
1
- all: clean test
2
-
3
- test:
4
- vendor/bin/phpunit $(TEST)
5
-
6
- coverage:
7
- vendor/bin/phpunit --coverage-html=artifacts/coverage $(TEST)
8
-
9
- view-coverage:
10
- open artifacts/coverage/index.html
11
-
12
- clean:
13
- rm -rf artifacts/*
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/psr7/README.md DELETED
@@ -1,580 +0,0 @@
1
- # PSR-7 Message Implementation
2
-
3
- This repository contains a partial [PSR-7](http://www.php-fig.org/psr/psr-7/)
4
- message implementation, several stream decorators, and some helpful
5
- functionality like query string parsing. Currently missing
6
- ServerRequestInterface and UploadedFileInterface; a pull request for these features is welcome.
7
-
8
-
9
- # Stream implementation
10
-
11
- This package comes with a number of stream implementations and stream
12
- decorators.
13
-
14
-
15
- ## AppendStream
16
-
17
- `GuzzleHttp\Psr7\AppendStream`
18
-
19
- Reads from multiple streams, one after the other.
20
-
21
- ```php
22
- use GuzzleHttp\Psr7;
23
-
24
- $a = Psr7\stream_for('abc, ');
25
- $b = Psr7\stream_for('123.');
26
- $composed = new Psr7\AppendStream([$a, $b]);
27
-
28
- $composed->addStream(Psr7\stream_for(' Above all listen to me').
29
-
30
- echo $composed(); // abc, 123. Above all listen to me.
31
- ```
32
-
33
-
34
- ## BufferStream
35
-
36
- `GuzzleHttp\Psr7\BufferStream`
37
-
38
- Provides a buffer stream that can be written to to fill a buffer, and read
39
- from to remove bytes from the buffer.
40
-
41
- This stream returns a "hwm" metadata value that tells upstream consumers
42
- what the configured high water mark of the stream is, or the maximum
43
- preferred size of the buffer.
44
-
45
- ```php
46
- use GuzzleHttp\Psr7;
47
-
48
- // When more than 1024 bytes are in the buffer, it will begin returning
49
- // false to writes. This is an indication that writers should slow down.
50
- $buffer = new Psr7\BufferStream(1024);
51
- ```
52
-
53
-
54
- ## CachingStream
55
-
56
- The CachingStream is used to allow seeking over previously read bytes on
57
- non-seekable streams. This can be useful when transferring a non-seekable
58
- entity body fails due to needing to rewind the stream (for example, resulting
59
- from a redirect). Data that is read from the remote stream will be buffered in
60
- a PHP temp stream so that previously read bytes are cached first in memory,
61
- then on disk.
62
-
63
- ```php
64
- use GuzzleHttp\Psr7;
65
-
66
- $original = Psr7\stream_for(fopen('http://www.google.com', 'r'));
67
- $stream = new Psr7\CachingStream($original);
68
-
69
- $stream->read(1024);
70
- echo $stream->tell();
71
- // 1024
72
-
73
- $stream->seek(0);
74
- echo $stream->tell();
75
- // 0
76
- ```
77
-
78
-
79
- ## DroppingStream
80
-
81
- `GuzzleHttp\Psr7\DroppingStream`
82
-
83
- Stream decorator that begins dropping data once the size of the underlying
84
- stream becomes too full.
85
-
86
- ```php
87
- use GuzzleHttp\Psr7;
88
-
89
- // Create an empty stream
90
- $stream = Psr7\stream_for();
91
-
92
- // Start dropping data when the stream has more than 10 bytes
93
- $dropping = new Psr7\DroppingStream($stream, 10);
94
-
95
- $stream->write('01234567890123456789');
96
- echo $stream; // 0123456789
97
- ```
98
-
99
-
100
- ## FnStream
101
-
102
- `GuzzleHttp\Psr7\FnStream`
103
-
104
- Compose stream implementations based on a hash of functions.
105
-
106
- Allows for easy testing and extension of a provided stream without needing to
107
- to create a concrete class for a simple extension point.
108
-
109
- ```php
110
-
111
- use GuzzleHttp\Psr7;
112
-
113
- $stream = Psr7\stream_for('hi');
114
- $fnStream = Psr7\FnStream::decorate($stream, [
115
- 'rewind' => function () use ($stream) {
116
- echo 'About to rewind - ';
117
- $stream->rewind();
118
- echo 'rewound!';
119
- }
120
- ]);
121
-
122
- $fnStream->rewind();
123
- // Outputs: About to rewind - rewound!
124
- ```
125
-
126
-
127
- ## InflateStream
128
-
129
- `GuzzleHttp\Psr7\InflateStream`
130
-
131
- Uses PHP's zlib.inflate filter to inflate deflate or gzipped content.
132
-
133
- This stream decorator skips the first 10 bytes of the given stream to remove
134
- the gzip header, converts the provided stream to a PHP stream resource,
135
- then appends the zlib.inflate filter. The stream is then converted back
136
- to a Guzzle stream resource to be used as a Guzzle stream.
137
-
138
-
139
- ## LazyOpenStream
140
-
141
- `GuzzleHttp\Psr7\LazyOpenStream`
142
-
143
- Lazily reads or writes to a file that is opened only after an IO operation
144
- take place on the stream.
145
-
146
- ```php
147
- use GuzzleHttp\Psr7;
148
-
149
- $stream = new Psr7\LazyOpenStream('/path/to/file', 'r');
150
- // The file has not yet been opened...
151
-
152
- echo $stream->read(10);
153
- // The file is opened and read from only when needed.
154
- ```
155
-
156
-
157
- ## LimitStream
158
-
159
- `GuzzleHttp\Psr7\LimitStream`
160
-
161
- LimitStream can be used to read a subset or slice of an existing stream object.
162
- This can be useful for breaking a large file into smaller pieces to be sent in
163
- chunks (e.g. Amazon S3's multipart upload API).
164
-
165
- ```php
166
- use GuzzleHttp\Psr7;
167
-
168
- $original = Psr7\stream_for(fopen('/tmp/test.txt', 'r+'));
169
- echo $original->getSize();
170
- // >>> 1048576
171
-
172
- // Limit the size of the body to 1024 bytes and start reading from byte 2048
173
- $stream = new Psr7\LimitStream($original, 1024, 2048);
174
- echo $stream->getSize();
175
- // >>> 1024
176
- echo $stream->tell();
177
- // >>> 0
178
- ```
179
-
180
-
181
- ## MultipartStream
182
-
183
- `GuzzleHttp\Psr7\MultipartStream`
184
-
185
- Stream that when read returns bytes for a streaming multipart or
186
- multipart/form-data stream.
187
-
188
-
189
- ## NoSeekStream
190
-
191
- `GuzzleHttp\Psr7\NoSeekStream`
192
-
193
- NoSeekStream wraps a stream and does not allow seeking.
194
-
195
- ```php
196
- use GuzzleHttp\Psr7;
197
-
198
- $original = Psr7\stream_for('foo');
199
- $noSeek = new Psr7\NoSeekStream($original);
200
-
201
- echo $noSeek->read(3);
202
- // foo
203
- var_export($noSeek->isSeekable());
204
- // false
205
- $noSeek->seek(0);
206
- var_export($noSeek->read(3));
207
- // NULL
208
- ```
209
-
210
-
211
- ## PumpStream
212
-
213
- `GuzzleHttp\Psr7\PumpStream`
214
-
215
- Provides a read only stream that pumps data from a PHP callable.
216
-
217
- When invoking the provided callable, the PumpStream will pass the amount of
218
- data requested to read to the callable. The callable can choose to ignore
219
- this value and return fewer or more bytes than requested. Any extra data
220
- returned by the provided callable is buffered internally until drained using
221
- the read() function of the PumpStream. The provided callable MUST return
222
- false when there is no more data to read.
223
-
224
-
225
- ## Implementing stream decorators
226
-
227
- Creating a stream decorator is very easy thanks to the
228
- `GuzzleHttp\Psr7\StreamDecoratorTrait`. This trait provides methods that
229
- implement `Psr\Http\Message\StreamInterface` by proxying to an underlying
230
- stream. Just `use` the `StreamDecoratorTrait` and implement your custom
231
- methods.
232
-
233
- For example, let's say we wanted to call a specific function each time the last
234
- byte is read from a stream. This could be implemented by overriding the
235
- `read()` method.
236
-
237
- ```php
238
- use Psr\Http\Message\StreamInterface;
239
- use GuzzleHttp\Psr7\StreamDecoratorTrait;
240
-
241
- class EofCallbackStream implements StreamInterface
242
- {
243
- use StreamDecoratorTrait;
244
-
245
- private $callback;
246
-
247
- public function __construct(StreamInterface $stream, callable $cb)
248
- {
249
- $this->stream = $stream;
250
- $this->callback = $cb;
251
- }
252
-
253
- public function read($length)
254
- {
255
- $result = $this->stream->read($length);
256
-
257
- // Invoke the callback when EOF is hit.
258
- if ($this->eof()) {
259
- call_user_func($this->callback);
260
- }
261
-
262
- return $result;
263
- }
264
- }
265
- ```
266
-
267
- This decorator could be added to any existing stream and used like so:
268
-
269
- ```php
270
- use GuzzleHttp\Psr7;
271
-
272
- $original = Psr7\stream_for('foo');
273
-
274
- $eofStream = new EofCallbackStream($original, function () {
275
- echo 'EOF!';
276
- });
277
-
278
- $eofStream->read(2);
279
- $eofStream->read(1);
280
- // echoes "EOF!"
281
- $eofStream->seek(0);
282
- $eofStream->read(3);
283
- // echoes "EOF!"
284
- ```
285
-
286
-
287
- ## PHP StreamWrapper
288
-
289
- You can use the `GuzzleHttp\Psr7\StreamWrapper` class if you need to use a
290
- PSR-7 stream as a PHP stream resource.
291
-
292
- Use the `GuzzleHttp\Psr7\StreamWrapper::getResource()` method to create a PHP
293
- stream from a PSR-7 stream.
294
-
295
- ```php
296
- use GuzzleHttp\Psr7\StreamWrapper;
297
-
298
- $stream = GuzzleHttp\Psr7\stream_for('hello!');
299
- $resource = StreamWrapper::getResource($stream);
300
- echo fread($resource, 6); // outputs hello!
301
- ```
302
-
303
-
304
- # Function API
305
-
306
- There are various functions available under the `GuzzleHttp\Psr7` namespace.
307
-
308
-
309
- ## `function str`
310
-
311
- `function str(MessageInterface $message)`
312
-
313
- Returns the string representation of an HTTP message.
314
-
315
- ```php
316
- $request = new GuzzleHttp\Psr7\Request('GET', 'http://example.com');
317
- echo GuzzleHttp\Psr7\str($request);
318
- ```
319
-
320
-
321
- ## `function uri_for`
322
-
323
- `function uri_for($uri)`
324
-
325
- This function accepts a string or `Psr\Http\Message\UriInterface` and returns a
326
- UriInterface for the given value. If the value is already a `UriInterface`, it
327
- is returned as-is.
328
-
329
- ```php
330
- $uri = GuzzleHttp\Psr7\uri_for('http://example.com');
331
- assert($uri === GuzzleHttp\Psr7\uri_for($uri));
332
- ```
333
-
334
-
335
- ## `function stream_for`
336
-
337
- `function stream_for($resource = '', array $options = [])`
338
-
339
- Create a new stream based on the input type.
340
-
341
- Options is an associative array that can contain the following keys:
342
-
343
- * - metadata: Array of custom metadata.
344
- * - size: Size of the stream.
345
-
346
- This method accepts the following `$resource` types:
347
-
348
- - `Psr\Http\Message\StreamInterface`: Returns the value as-is.
349
- - `string`: Creates a stream object that uses the given string as the contents.
350
- - `resource`: Creates a stream object that wraps the given PHP stream resource.
351
- - `Iterator`: If the provided value implements `Iterator`, then a read-only
352
- stream object will be created that wraps the given iterable. Each time the
353
- stream is read from, data from the iterator will fill a buffer and will be
354
- continuously called until the buffer is equal to the requested read size.
355
- Subsequent read calls will first read from the buffer and then call `next`
356
- on the underlying iterator until it is exhausted.
357
- - `object` with `__toString()`: If the object has the `__toString()` method,
358
- the object will be cast to a string and then a stream will be returned that
359
- uses the string value.
360
- - `NULL`: When `null` is passed, an empty stream object is returned.
361
- - `callable` When a callable is passed, a read-only stream object will be
362
- created that invokes the given callable. The callable is invoked with the
363
- number of suggested bytes to read. The callable can return any number of
364
- bytes, but MUST return `false` when there is no more data to return. The
365
- stream object that wraps the callable will invoke the callable until the
366
- number of requested bytes are available. Any additional bytes will be
367
- buffered and used in subsequent reads.
368
-
369
- ```php
370
- $stream = GuzzleHttp\Psr7\stream_for('foo');
371
- $stream = GuzzleHttp\Psr7\stream_for(fopen('/path/to/file', 'r'));
372
-
373
- $generator function ($bytes) {
374
- for ($i = 0; $i < $bytes; $i++) {
375
- yield ' ';
376
- }
377
- }
378
-
379
- $stream = GuzzleHttp\Psr7\stream_for($generator(100));
380
- ```
381
-
382
-
383
- ## `function parse_header`
384
-
385
- `function parse_header($header)`
386
-
387
- Parse an array of header values containing ";" separated data into an array of
388
- associative arrays representing the header key value pair data of the header.
389
- When a parameter does not contain a value, but just contains a key, this
390
- function will inject a key with a '' string value.
391
-
392
-
393
- ## `function normalize_header`
394
-
395
- `function normalize_header($header)`
396
-
397
- Converts an array of header values that may contain comma separated headers
398
- into an array of headers with no comma separated values.
399
-
400
-
401
- ## `function modify_request`
402
-
403
- `function modify_request(RequestInterface $request, array $changes)`
404
-
405
- Clone and modify a request with the given changes. This method is useful for
406
- reducing the number of clones needed to mutate a message.
407
-
408
- The changes can be one of:
409
-
410
- - method: (string) Changes the HTTP method.
411
- - set_headers: (array) Sets the given headers.
412
- - remove_headers: (array) Remove the given headers.
413
- - body: (mixed) Sets the given body.
414
- - uri: (UriInterface) Set the URI.
415
- - query: (string) Set the query string value of the URI.
416
- - version: (string) Set the protocol version.
417
-
418
-
419
- ## `function rewind_body`
420
-
421
- `function rewind_body(MessageInterface $message)`
422
-
423
- Attempts to rewind a message body and throws an exception on failure. The body
424
- of the message will only be rewound if a call to `tell()` returns a value other
425
- than `0`.
426
-
427
-
428
- ## `function try_fopen`
429
-
430
- `function try_fopen($filename, $mode)`
431
-
432
- Safely opens a PHP stream resource using a filename.
433
-
434
- When fopen fails, PHP normally raises a warning. This function adds an error
435
- handler that checks for errors and throws an exception instead.
436
-
437
-
438
- ## `function copy_to_string`
439
-
440
- `function copy_to_string(StreamInterface $stream, $maxLen = -1)`
441
-
442
- Copy the contents of a stream into a string until the given number of bytes
443
- have been read.
444
-
445
-
446
- ## `function copy_to_stream`
447
-
448
- `function copy_to_stream(StreamInterface $source, StreamInterface $dest, $maxLen = -1)`
449
-
450
- Copy the contents of a stream into another stream until the given number of
451
- bytes have been read.
452
-
453
-
454
- ## `function hash`
455
-
456
- `function hash(StreamInterface $stream, $algo, $rawOutput = false)`
457
-
458
- Calculate a hash of a Stream. This method reads the entire stream to calculate
459
- a rolling hash (based on PHP's hash_init functions).
460
-
461
-
462
- ## `function readline`
463
-
464
- `function readline(StreamInterface $stream, $maxLength = null)`
465
-
466
- Read a line from the stream up to the maximum allowed buffer length.
467
-
468
-
469
- ## `function parse_request`
470
-
471
- `function parse_request($message)`
472
-
473
- Parses a request message string into a request object.
474
-
475
-
476
- ## `function parse_response`
477
-
478
- `function parse_response($message)`
479
-
480
- Parses a response message string into a response object.
481
-
482
-
483
- ## `function parse_query`
484
-
485
- `function parse_query($str, $urlEncoding = true)`
486
-
487
- Parse a query string into an associative array.
488
-
489
- If multiple values are found for the same key, the value of that key value pair
490
- will become an array. This function does not parse nested PHP style arrays into
491
- an associative array (e.g., `foo[a]=1&foo[b]=2` will be parsed into
492
- `['foo[a]' => '1', 'foo[b]' => '2']`).
493
-
494
-
495
- ## `function build_query`
496
-
497
- `function build_query(array $params, $encoding = PHP_QUERY_RFC3986)`
498
-
499
- Build a query string from an array of key value pairs.
500
-
501
- This function can use the return value of parseQuery() to build a query string.
502
- This function does not modify the provided keys when an array is encountered
503
- (like http_build_query would).
504
-
505
-
506
- ## `function mimetype_from_filename`
507
-
508
- `function mimetype_from_filename($filename)`
509
-
510
- Determines the mimetype of a file by looking at its extension.
511
-
512
-
513
- ## `function mimetype_from_extension`
514
-
515
- `function mimetype_from_extension($extension)`
516
-
517
- Maps a file extensions to a mimetype.
518
-
519
-
520
- # Static URI methods
521
-
522
- The `GuzzleHttp\Psr7\Uri` class has several static methods to manipulate URIs.
523
-
524
-
525
- ## `GuzzleHttp\Psr7\Uri::removeDotSegments`
526
-
527
- `public static function removeDotSegments($path) -> UriInterface`
528
-
529
- Removes dot segments from a path and returns the new path.
530
-
531
- See http://tools.ietf.org/html/rfc3986#section-5.2.4
532
-
533
-
534
- ## `GuzzleHttp\Psr7\Uri::resolve`
535
-
536
- `public static function resolve(UriInterface $base, $rel) -> UriInterface`
537
-
538
- Resolve a base URI with a relative URI and return a new URI.
539
-
540
- See http://tools.ietf.org/html/rfc3986#section-5
541
-
542
-
543
- ## `GuzzleHttp\Psr7\Uri::withQueryValue`
544
-
545
- `public static function withQueryValue(UriInterface $uri, $key, $value) -> UriInterface`
546
-
547
- Create a new URI with a specific query string value.
548
-
549
- Any existing query string values that exactly match the provided key are
550
- removed and replaced with the given key value pair.
551
-
552
- Note: this function will convert "=" to "%3D" and "&" to "%26".
553
-
554
-
555
- ## `GuzzleHttp\Psr7\Uri::withoutQueryValue`
556
-
557
- `public static function withoutQueryValue(UriInterface $uri, $key, $value) -> UriInterface`
558
-
559
- Create a new URI with a specific query string value removed.
560
-
561
- Any existing query string values that exactly match the provided key are
562
- removed.
563
-
564
- Note: this function will convert "=" to "%3D" and "&" to "%26".
565
-
566
-
567
- ## `GuzzleHttp\Psr7\Uri::fromParts`
568
-
569
- `public static function fromParts(array $parts) -> UriInterface`
570
-
571
- Create a `GuzzleHttp\Psr7\Uri` object from a hash of `parse_url` parts.
572
-
573
-
574
- # Not Implemented
575
-
576
- A few aspects of PSR-7 are not implemented in this project. A pull request for
577
- any of these features is welcome:
578
-
579
- - `Psr\Http\Message\ServerRequestInterface`
580
- - `Psr\Http\Message\UploadedFileInterface`
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/psr7/composer.json DELETED
@@ -1,35 +0,0 @@
1
- {
2
- "name": "guzzlehttp/psr7",
3
- "type": "library",
4
- "description": "PSR-7 message implementation",
5
- "keywords": ["message", "stream", "http", "uri"],
6
- "license": "MIT",
7
- "authors": [
8
- {
9
- "name": "Michael Dowling",
10
- "email": "mtdowling@gmail.com",
11
- "homepage": "https://github.com/mtdowling"
12
- }
13
- ],
14
- "require": {
15
- "php": ">=5.4.0",
16
- "psr/http-message": "~1.0"
17
- },
18
- "require-dev": {
19
- "phpunit/phpunit": "~4.0"
20
- },
21
- "provide": {
22
- "psr/http-message-implementation": "1.0"
23
- },
24
- "autoload": {
25
- "psr-4": {
26
- "GuzzleHttp\\Psr7\\": "src/"
27
- },
28
- "files": ["src/functions_include.php"]
29
- },
30
- "extra": {
31
- "branch-alias": {
32
- "dev-master": "1.0-dev"
33
- }
34
- }
35
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/psr7/phpunit.xml.dist DELETED
@@ -1,17 +0,0 @@
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>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/psr7/src/AppendStream.php DELETED
@@ -1,233 +0,0 @@
1
- <?php
2
- namespace GuzzleHttp\Psr7;
3
-
4
- use Psr\Http\Message\StreamInterface;
5
-
6
- /**
7
- * Reads from multiple streams, one after the other.
8
- *
9
- * This is a read-only stream decorator.
10
- */
11
- class AppendStream implements StreamInterface
12
- {
13
- /** @var StreamInterface[] Streams being decorated */
14
- private $streams = [];
15
-
16
- private $seekable = true;
17
- private $current = 0;
18
- private $pos = 0;
19
- private $detached = false;
20
-
21
- /**
22
- * @param StreamInterface[] $streams Streams to decorate. Each stream must
23
- * be readable.
24
- */
25
- public function __construct(array $streams = [])
26
- {
27
- foreach ($streams as $stream) {
28
- $this->addStream($stream);
29
- }
30
- }
31
-
32
- public function __toString()
33
- {
34
- try {
35
- $this->rewind();
36
- return $this->getContents();
37
- } catch (\Exception $e) {
38
- return '';
39
- }
40
- }
41
-
42
- /**
43
- * Add a stream to the AppendStream
44
- *
45
- * @param StreamInterface $stream Stream to append. Must be readable.
46
- *
47
- * @throws \InvalidArgumentException if the stream is not readable
48
- */
49
- public function addStream(StreamInterface $stream)
50
- {
51
- if (!$stream->isReadable()) {
52
- throw new \InvalidArgumentException('Each stream must be readable');
53
- }
54
-
55
- // The stream is only seekable if all streams are seekable
56
- if (!$stream->isSeekable()) {
57
- $this->seekable = false;
58
- }
59
-
60
- $this->streams[] = $stream;
61
- }
62
-
63
- public function getContents()
64
- {
65
- return copy_to_string($this);
66
- }
67
-
68
- /**
69
- * Closes each attached stream.
70
- *
71
- * {@inheritdoc}
72
- */
73
- public function close()
74
- {
75
- $this->pos = $this->current = 0;
76
-
77
- foreach ($this->streams as $stream) {
78
- $stream->close();
79
- }
80
-
81
- $this->streams = [];
82
- }
83
-
84
- /**
85
- * Detaches each attached stream
86
- *
87
- * {@inheritdoc}
88
- */
89
- public function detach()
90
- {
91
- $this->close();
92
- $this->detached = true;
93
- }
94
-
95
- public function tell()
96
- {
97
- return $this->pos;
98
- }
99
-
100
- /**
101
- * Tries to calculate the size by adding the size of each stream.
102
- *
103
- * If any of the streams do not return a valid number, then the size of the
104
- * append stream cannot be determined and null is returned.
105
- *
106
- * {@inheritdoc}
107
- */
108
- public function getSize()
109
- {
110
- $size = 0;
111
-
112
- foreach ($this->streams as $stream) {
113
- $s = $stream->getSize();
114
- if ($s === null) {
115
- return null;
116
- }
117
- $size += $s;
118
- }
119
-
120
- return $size;
121
- }
122
-
123
- public function eof()
124
- {
125
- return !$this->streams ||
126
- ($this->current >= count($this->streams) - 1 &&
127
- $this->streams[$this->current]->eof());
128
- }
129
-
130
- public function rewind()
131
- {
132
- $this->seek(0);
133
- }
134
-
135
- /**
136
- * Attempts to seek to the given position. Only supports SEEK_SET.
137
- *
138
- * {@inheritdoc}
139
- */
140
- public function seek($offset, $whence = SEEK_SET)
141
- {
142
- if (!$this->seekable) {
143
- throw new \RuntimeException('This AppendStream is not seekable');
144
- } elseif ($whence !== SEEK_SET) {
145
- throw new \RuntimeException('The AppendStream can only seek with SEEK_SET');
146
- }
147
-
148
- $this->pos = $this->current = 0;
149
-
150
- // Rewind each stream
151
- foreach ($this->streams as $i => $stream) {
152
- try {
153
- $stream->rewind();
154
- } catch (\Exception $e) {
155
- throw new \RuntimeException('Unable to seek stream '
156
- . $i . ' of the AppendStream', 0, $e);
157
- }
158
- }
159
-
160
- // Seek to the actual position by reading from each stream
161
- while ($this->pos < $offset && !$this->eof()) {
162
- $result = $this->read(min(8096, $offset - $this->pos));
163
- if ($result === '') {
164
- break;
165
- }
166
- }
167
- }
168
-
169
- /**
170
- * Reads from all of the appended streams until the length is met or EOF.
171
- *
172
- * {@inheritdoc}
173
- */
174
- public function read($length)
175
- {
176
- $buffer = '';
177
- $total = count($this->streams) - 1;
178
- $remaining = $length;
179
- $progressToNext = false;
180
-
181
- while ($remaining > 0) {
182
-
183
- // Progress to the next stream if needed.
184
- if ($progressToNext || $this->streams[$this->current]->eof()) {
185
- $progressToNext = false;
186
- if ($this->current === $total) {
187
- break;
188
- }
189
- $this->current++;
190
- }
191
-
192
- $result = $this->streams[$this->current]->read($remaining);
193
-
194
- // Using a loose comparison here to match on '', false, and null
195
- if ($result == null) {
196
- $progressToNext = true;
197
- continue;
198
- }
199
-
200
- $buffer .= $result;
201
- $remaining = $length - strlen($buffer);
202
- }
203
-
204
- $this->pos += strlen($buffer);
205
-
206
- return $buffer;
207
- }
208
-
209
- public function isReadable()
210
- {
211
- return true;
212
- }
213
-
214
- public function isWritable()
215
- {
216
- return false;
217
- }
218
-
219
- public function isSeekable()
220
- {
221
- return $this->seekable;
222
- }
223
-
224
- public function write($string)
225
- {
226
- throw new \RuntimeException('Cannot write to an AppendStream');
227
- }
228
-
229
- public function getMetadata($key = null)
230
- {
231
- return $key ? null : [];
232
- }
233
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/psr7/src/BufferStream.php DELETED
@@ -1,137 +0,0 @@
1
- <?php
2
- namespace GuzzleHttp\Psr7;
3
-
4
- use Psr\Http\Message\StreamInterface;
5
-
6
- /**
7
- * Provides a buffer stream that can be written to to fill a buffer, and read
8
- * from to remove bytes from the buffer.
9
- *
10
- * This stream returns a "hwm" metadata value that tells upstream consumers
11
- * what the configured high water mark of the stream is, or the maximum
12
- * preferred size of the buffer.
13
- */
14
- class BufferStream implements StreamInterface
15
- {
16
- private $hwm;
17
- private $buffer = '';
18
-
19
- /**
20
- * @param int $hwm High water mark, representing the preferred maximum
21
- * buffer size. If the size of the buffer exceeds the high
22
- * water mark, then calls to write will continue to succeed
23
- * but will return false to inform writers to slow down
24
- * until the buffer has been drained by reading from it.
25
- */
26
- public function __construct($hwm = 16384)
27
- {
28
- $this->hwm = $hwm;
29
- }
30
-
31
- public function __toString()
32
- {
33
- return $this->getContents();
34
- }
35
-
36
- public function getContents()
37
- {
38
- $buffer = $this->buffer;
39
- $this->buffer = '';
40
-
41
- return $buffer;
42
- }
43
-
44
- public function close()
45
- {
46
- $this->buffer = '';
47
- }
48
-
49
- public function detach()
50
- {
51
- $this->close();
52
- }
53
-
54
- public function getSize()
55
- {
56
- return strlen($this->buffer);
57
- }
58
-
59
- public function isReadable()
60
- {
61
- return true;
62
- }
63
-
64
- public function isWritable()
65
- {
66
- return true;
67
- }
68
-
69
- public function isSeekable()
70
- {
71
- return false;
72
- }
73
-
74
- public function rewind()
75
- {
76
- $this->seek(0);
77
- }
78
-
79
- public function seek($offset, $whence = SEEK_SET)
80
- {
81
- throw new \RuntimeException('Cannot seek a BufferStream');
82
- }
83
-
84
- public function eof()
85
- {
86
- return strlen($this->buffer) === 0;
87
- }
88
-
89
- public function tell()
90
- {
91
- throw new \RuntimeException('Cannot determine the position of a BufferStream');
92
- }
93
-
94
- /**
95
- * Reads data from the buffer.
96
- */
97
- public function read($length)
98
- {
99
- $currentLength = strlen($this->buffer);
100
-
101
- if ($length >= $currentLength) {
102
- // No need to slice the buffer because we don't have enough data.
103
- $result = $this->buffer;
104
- $this->buffer = '';
105
- } else {
106
- // Slice up the result to provide a subset of the buffer.
107
- $result = substr($this->buffer, 0, $length);
108
- $this->buffer = substr($this->buffer, $length);
109
- }
110
-
111
- return $result;
112
- }
113
-
114
- /**
115
- * Writes data to the buffer.
116
- */
117
- public function write($string)
118
- {
119
- $this->buffer .= $string;
120
-
121
- // TODO: What should happen here?
122
- if (strlen($this->buffer) >= $this->hwm) {
123
- return false;
124
- }
125
-
126
- return strlen($string);
127
- }
128
-
129
- public function getMetadata($key = null)
130
- {
131
- if ($key == 'hwm') {
132
- return $this->hwm;
133
- }
134
-
135
- return $key ? null : [];
136
- }
137
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/psr7/src/CachingStream.php DELETED
@@ -1,136 +0,0 @@
1
- <?php
2
- namespace GuzzleHttp\Psr7;
3
-
4
- use Psr\Http\Message\StreamInterface;
5
-
6
- /**
7
- * Stream decorator that can cache previously read bytes from a sequentially
8
- * read stream.
9
- */
10
- class CachingStream implements StreamInterface
11
- {
12
- use StreamDecoratorTrait;
13
-
14
- /** @var StreamInterface Stream being wrapped */
15
- private $remoteStream;
16
-
17
- /** @var int Number of bytes to skip reading due to a write on the buffer */
18
- private $skipReadBytes = 0;
19
-
20
- /**
21
- * We will treat the buffer object as the body of the stream
22
- *
23
- * @param StreamInterface $stream Stream to cache
24
- * @param StreamInterface $target Optionally specify where data is cached
25
- */
26
- public function __construct(
27
- StreamInterface $stream,
28
- StreamInterface $target = null
29
- ) {
30
- $this->remoteStream = $stream;
31
- $this->stream = $target ?: new Stream(fopen('php://temp', 'r+'));
32
- }
33
-
34
- public function getSize()
35
- {
36
- return max($this->stream->getSize(), $this->remoteStream->getSize());
37
- }
38
-
39
- public function rewind()
40
- {
41
- $this->seek(0);
42
- }
43
-
44
- public function seek($offset, $whence = SEEK_SET)
45
- {
46
- if ($whence == SEEK_SET) {
47
- $byte = $offset;
48
- } elseif ($whence == SEEK_CUR) {
49
- $byte = $offset + $this->tell();
50
- } elseif ($whence == SEEK_END) {
51
- $size = $this->remoteStream->getSize();
52
- if ($size === null) {
53
- $size = $this->cacheEntireStream();
54
- }
55
- // Because 0 is the first byte, we seek to size - 1.
56
- $byte = $size - 1 - $offset;
57
- } else {
58
- throw new \InvalidArgumentException('Invalid whence');
59
- }
60
-
61
- $diff = $byte - $this->stream->getSize();
62
-
63
- if ($diff > 0) {
64
- // If the seek byte is greater the number of read bytes, then read
65
- // the difference of bytes to cache the bytes and inherently seek.
66
- $this->read($diff);
67
- } else {
68
- // We can just do a normal seek since we've already seen this byte.
69
- $this->stream->seek($byte);
70
- }
71
- }
72
-
73
- public function read($length)
74
- {
75
- // Perform a regular read on any previously read data from the buffer
76
- $data = $this->stream->read($length);
77
- $remaining = $length - strlen($data);
78
-
79
- // More data was requested so read from the remote stream
80
- if ($remaining) {
81
- // If data was written to the buffer in a position that would have
82
- // been filled from the remote stream, then we must skip bytes on
83
- // the remote stream to emulate overwriting bytes from that
84
- // position. This mimics the behavior of other PHP stream wrappers.
85
- $remoteData = $this->remoteStream->read(
86
- $remaining + $this->skipReadBytes
87
- );
88
-
89
- if ($this->skipReadBytes) {
90
- $len = strlen($remoteData);
91
- $remoteData = substr($remoteData, $this->skipReadBytes);
92
- $this->skipReadBytes = max(0, $this->skipReadBytes - $len);
93
- }
94
-
95
- $data .= $remoteData;
96
- $this->stream->write($remoteData);
97
- }
98
-
99
- return $data;
100
- }
101
-
102
- public function write($string)
103
- {
104
- // When appending to the end of the currently read stream, you'll want
105
- // to skip bytes from being read from the remote stream to emulate
106
- // other stream wrappers. Basically replacing bytes of data of a fixed
107
- // length.
108
- $overflow = (strlen($string) + $this->tell()) - $this->remoteStream->tell();
109
- if ($overflow > 0) {
110
- $this->skipReadBytes += $overflow;
111
- }
112
-
113
- return $this->stream->write($string);
114
- }
115
-
116
- public function eof()
117
- {
118
- return $this->stream->eof() && $this->remoteStream->eof();
119
- }
120
-
121
- /**
122
- * Close both the remote stream and buffer stream
123
- */
124
- public function close()
125
- {
126
- $this->remoteStream->close() && $this->stream->close();
127
- }
128
-
129
- private function cacheEntireStream()
130
- {
131
- $target = new FnStream(['write' => 'strlen']);
132
- copy_to_stream($this, $target);
133
-
134
- return $this->tell();
135
- }
136
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/psr7/src/DroppingStream.php DELETED
@@ -1,42 +0,0 @@
1
- <?php
2
- namespace GuzzleHttp\Psr7;
3
-
4
- use Psr\Http\Message\StreamInterface;
5
-
6
- /**
7
- * Stream decorator that begins dropping data once the size of the underlying
8
- * stream becomes too full.
9
- */
10
- class DroppingStream implements StreamInterface
11
- {
12
- use StreamDecoratorTrait;
13
-
14
- private $maxLength;
15
-
16
- /**
17
- * @param StreamInterface $stream Underlying stream to decorate.
18
- * @param int $maxLength Maximum size before dropping data.
19
- */
20
- public function __construct(StreamInterface $stream, $maxLength)
21
- {
22
- $this->stream = $stream;
23
- $this->maxLength = $maxLength;
24
- }
25
-
26
- public function write($string)
27
- {
28
- $diff = $this->maxLength - $this->stream->getSize();
29
-
30
- // Begin returning 0 when the underlying stream is too large.
31
- if ($diff <= 0) {
32
- return 0;
33
- }
34
-
35
- // Write the stream or a subset of the stream if needed.
36
- if (strlen($string) < $diff) {
37
- return $this->stream->write($string);
38
- }
39
-
40
- return $this->stream->write(substr($string, 0, $diff));
41
- }
42
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/psr7/src/FnStream.php DELETED
@@ -1,149 +0,0 @@
1
- <?php
2
- namespace GuzzleHttp\Psr7;
3
-
4
- use Psr\Http\Message\StreamInterface;
5
-
6
- /**
7
- * Compose stream implementations based on a hash of functions.
8
- *
9
- * Allows for easy testing and extension of a provided stream without needing
10
- * to create a concrete class for a simple extension point.
11
- */
12
- class FnStream implements StreamInterface
13
- {
14
- /** @var array */
15
- private $methods;
16
-
17
- /** @var array Methods that must be implemented in the given array */
18
- private static $slots = ['__toString', 'close', 'detach', 'rewind',
19
- 'getSize', 'tell', 'eof', 'isSeekable', 'seek', 'isWritable', 'write',
20
- 'isReadable', 'read', 'getContents', 'getMetadata'];
21
-
22
- /**
23
- * @param array $methods Hash of method name to a callable.
24
- */
25
- public function __construct(array $methods)
26
- {
27
- $this->methods = $methods;
28
-
29
- // Create the functions on the class
30
- foreach ($methods as $name => $fn) {
31
- $this->{'_fn_' . $name} = $fn;
32
- }
33
- }
34
-
35
- /**
36
- * Lazily determine which methods are not implemented.
37
- * @throws \BadMethodCallException
38
- */
39
- public function __get($name)
40
- {
41
- throw new \BadMethodCallException(str_replace('_fn_', '', $name)
42
- . '() is not implemented in the FnStream');
43
- }
44
-
45
- /**
46
- * The close method is called on the underlying stream only if possible.
47
- */
48
- public function __destruct()
49
- {
50
- if (isset($this->_fn_close)) {
51
- call_user_func($this->_fn_close);
52
- }
53
- }
54
-
55
- /**
56
- * Adds custom functionality to an underlying stream by intercepting
57
- * specific method calls.
58
- *
59
- * @param StreamInterface $stream Stream to decorate
60
- * @param array $methods Hash of method name to a closure
61
- *
62
- * @return FnStream
63
- */
64
- public static function decorate(StreamInterface $stream, array $methods)
65
- {
66
- // If any of the required methods were not provided, then simply
67
- // proxy to the decorated stream.
68
- foreach (array_diff(self::$slots, array_keys($methods)) as $diff) {
69
- $methods[$diff] = [$stream, $diff];
70
- }
71
-
72
- return new self($methods);
73
- }
74
-
75
- public function __toString()
76
- {
77
- return call_user_func($this->_fn___toString);
78
- }
79
-
80
- public function close()
81
- {
82
- return call_user_func($this->_fn_close);
83
- }
84
-
85
- public function detach()
86
- {
87
- return call_user_func($this->_fn_detach);
88
- }
89
-
90
- public function getSize()
91
- {
92
- return call_user_func($this->_fn_getSize);
93
- }
94
-
95
- public function tell()
96
- {
97
- return call_user_func($this->_fn_tell);
98
- }
99
-
100
- public function eof()
101
- {
102
- return call_user_func($this->_fn_eof);
103
- }
104
-
105
- public function isSeekable()
106
- {
107
- return call_user_func($this->_fn_isSeekable);
108
- }
109
-
110
- public function rewind()
111
- {
112
- call_user_func($this->_fn_rewind);
113
- }
114
-
115
- public function seek($offset, $whence = SEEK_SET)
116
- {
117
- call_user_func($this->_fn_seek, $offset, $whence);
118
- }
119
-
120
- public function isWritable()
121
- {
122
- return call_user_func($this->_fn_isWritable);
123
- }
124
-
125
- public function write($string)
126
- {
127
- return call_user_func($this->_fn_write, $string);
128
- }
129
-
130
- public function isReadable()
131
- {
132
- return call_user_func($this->_fn_isReadable);
133
- }
134
-
135
- public function read($length)
136
- {
137
- return call_user_func($this->_fn_read, $length);
138
- }
139
-
140
- public function getContents()
141
- {
142
- return call_user_func($this->_fn_getContents);
143
- }
144
-
145
- public function getMetadata($key = null)
146
- {
147
- return call_user_func($this->_fn_getMetadata, $key);
148
- }
149
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/psr7/src/InflateStream.php DELETED
@@ -1,29 +0,0 @@
1
- <?php
2
- namespace GuzzleHttp\Psr7;
3
-
4
- use Psr\Http\Message\StreamInterface;
5
-
6
- /**
7
- * Uses PHP's zlib.inflate filter to inflate deflate or gzipped content.
8
- *
9
- * This stream decorator skips the first 10 bytes of the given stream to remove
10
- * the gzip header, converts the provided stream to a PHP stream resource,
11
- * then appends the zlib.inflate filter. The stream is then converted back
12
- * to a Guzzle stream resource to be used as a Guzzle stream.
13
- *
14
- * @link http://tools.ietf.org/html/rfc1952
15
- * @link http://php.net/manual/en/filters.compression.php
16
- */
17
- class InflateStream implements StreamInterface
18
- {
19
- use StreamDecoratorTrait;
20
-
21
- public function __construct(StreamInterface $stream)
22
- {
23
- // Skip the first 10 bytes
24
- $stream = new LimitStream($stream, -1, 10);
25
- $resource = StreamWrapper::getResource($stream);
26
- stream_filter_append($resource, 'zlib.inflate', STREAM_FILTER_READ);
27
- $this->stream = new Stream($resource);
28
- }
29
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/psr7/src/LazyOpenStream.php DELETED
@@ -1,39 +0,0 @@
1
- <?php
2
- namespace GuzzleHttp\Psr7;
3
-
4
- use Psr\Http\Message\StreamInterface;
5
-
6
- /**
7
- * Lazily reads or writes to a file that is opened only after an IO operation
8
- * take place on the stream.
9
- */
10
- class LazyOpenStream implements StreamInterface
11
- {
12
- use StreamDecoratorTrait;
13
-
14
- /** @var string File to open */
15
- private $filename;
16
-
17
- /** @var string $mode */
18
- private $mode;
19
-
20
- /**
21
- * @param string $filename File to lazily open
22
- * @param string $mode fopen mode to use when opening the stream
23
- */
24
- public function __construct($filename, $mode)
25
- {
26
- $this->filename = $filename;
27
- $this->mode = $mode;
28
- }
29
-
30
- /**
31
- * Creates the underlying stream lazily when required.
32
- *
33
- * @return StreamInterface
34
- */
35
- protected function createStream()
36
- {
37
- return stream_for(try_fopen($this->filename, $this->mode));
38
- }
39
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/psr7/src/LimitStream.php DELETED
@@ -1,155 +0,0 @@
1
- <?php
2
- namespace GuzzleHttp\Psr7;
3
-
4
- use Psr\Http\Message\StreamInterface;
5
-
6
-
7
- /**
8
- * Decorator used to return only a subset of a stream
9
- */
10
- class LimitStream implements StreamInterface
11
- {
12
- use StreamDecoratorTrait;
13
-
14
- /** @var int Offset to start reading from */
15
- private $offset;
16
-
17
- /** @var int Limit the number of bytes that can be read */
18
- private $limit;
19
-
20
- /**
21
- * @param StreamInterface $stream Stream to wrap
22
- * @param int $limit Total number of bytes to allow to be read
23
- * from the stream. Pass -1 for no limit.
24
- * @param int|null $offset Position to seek to before reading (only
25
- * works on seekable streams).
26
- */
27
- public function __construct(
28
- StreamInterface $stream,
29
- $limit = -1,
30
- $offset = 0
31
- ) {
32
- $this->stream = $stream;
33
- $this->setLimit($limit);
34
- $this->setOffset($offset);
35
- }
36
-
37
- public function eof()
38
- {
39
- // Always return true if the underlying stream is EOF
40
- if ($this->stream->eof()) {
41
- return true;
42
- }
43
-
44
- // No limit and the underlying stream is not at EOF
45
- if ($this->limit == -1) {
46
- return false;
47
- }
48
-
49
- return $this->stream->tell() >= $this->offset + $this->limit;
50
- }
51
-
52
- /**
53
- * Returns the size of the limited subset of data
54
- * {@inheritdoc}
55
- */
56
- public function getSize()
57
- {
58
- if (null === ($length = $this->stream->getSize())) {
59
- return null;
60
- } elseif ($this->limit == -1) {
61
- return $length - $this->offset;
62
- } else {
63
- return min($this->limit, $length - $this->offset);
64
- }
65
- }
66
-
67
- /**
68
- * Allow for a bounded seek on the read limited stream
69
- * {@inheritdoc}
70
- */
71
- public function seek($offset, $whence = SEEK_SET)
72
- {
73
- if ($whence !== SEEK_SET || $offset < 0) {
74
- throw new \RuntimeException(sprintf(
75
- 'Cannot seek to offset % with whence %s',
76
- $offset,
77
- $whence
78
- ));
79
- }
80
-
81
- $offset += $this->offset;
82
-
83
- if ($this->limit !== -1) {
84
- if ($offset > $this->offset + $this->limit) {
85
- $offset = $this->offset + $this->limit;
86
- }
87
- }
88
-
89
- $this->stream->seek($offset);
90
- }
91
-
92
- /**
93
- * Give a relative tell()
94
- * {@inheritdoc}
95
- */
96
- public function tell()
97
- {
98
- return $this->stream->tell() - $this->offset;
99
- }
100
-
101
- /**
102
- * Set the offset to start limiting from
103
- *
104
- * @param int $offset Offset to seek to and begin byte limiting from
105
- *
106
- * @throws \RuntimeException if the stream cannot be seeked.
107
- */
108
- public function setOffset($offset)
109
- {
110
- $current = $this->stream->tell();
111
-
112
- if ($current !== $offset) {
113
- // If the stream cannot seek to the offset position, then read to it
114
- if ($this->stream->isSeekable()) {
115
- $this->stream->seek($offset);
116
- } elseif ($current > $offset) {
117
- throw new \RuntimeException("Could not seek to stream offset $offset");
118
- } else {
119
- $this->stream->read($offset - $current);
120
- }
121
- }
122
-
123
- $this->offset = $offset;
124
- }
125
-
126
- /**
127
- * Set the limit of bytes that the decorator allows to be read from the
128
- * stream.
129
- *
130
- * @param int $limit Number of bytes to allow to be read from the stream.
131
- * Use -1 for no limit.
132
- */
133
- public function setLimit($limit)
134
- {
135
- $this->limit = $limit;
136
- }
137
-
138
- public function read($length)
139
- {
140
- if ($this->limit == -1) {
141
- return $this->stream->read($length);
142
- }
143
-
144
- // Check if the current position is less than the total allowed
145
- // bytes + original offset
146
- $remaining = ($this->offset + $this->limit) - $this->stream->tell();
147
- if ($remaining > 0) {
148
- // Only return the amount of requested data, ensuring that the byte
149
- // limit is not exceeded
150
- return $this->stream->read(min($remaining, $length));
151
- }
152
-
153
- return '';
154
- }
155
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/psr7/src/MessageTrait.php DELETED
@@ -1,158 +0,0 @@
1
- <?php
2
- namespace GuzzleHttp\Psr7;
3
-
4
- use Psr\Http\Message\StreamInterface;
5
-
6
- /**
7
- * Trait implementing functionality common to requests and responses.
8
- */
9
- trait MessageTrait
10
- {
11
- /** @var array Cached HTTP header collection with lowercase key to values */
12
- private $headers = [];
13
-
14
- /** @var array Actual key to list of values per header. */
15
- private $headerLines = [];
16
-
17
- /** @var string */
18
- private $protocol = '1.1';
19
-
20
- /** @var StreamInterface */
21
- private $stream;
22
-
23
- public function getProtocolVersion()
24
- {
25
- return $this->protocol;
26
- }
27
-
28
- public function withProtocolVersion($version)
29
- {
30
- if ($this->protocol === $version) {
31
- return $this;
32
- }
33
-
34
- $new = clone $this;
35
- $new->protocol = $version;
36
- return $new;
37
- }
38
-
39
- public function getHeaders()
40
- {
41
- return $this->headerLines;
42
- }
43
-
44
- public function hasHeader($header)
45
- {
46
- return isset($this->headers[strtolower($header)]);
47
- }
48
-
49
- public function getHeader($header)
50
- {
51
- $name = strtolower($header);
52
- return isset($this->headers[$name]) ? $this->headers[$name] : [];
53
- }
54
-
55
- public function getHeaderLine($header)
56
- {
57
- return implode(', ', $this->getHeader($header));
58
- }
59
-
60
- public function withHeader($header, $value)
61
- {
62
- $new = clone $this;
63
- $header = trim($header);
64
- $name = strtolower($header);
65
-
66
- if (!is_array($value)) {
67
- $new->headers[$name] = [trim($value)];
68
- } else {
69
- $new->headers[$name] = $value;
70
- foreach ($new->headers[$name] as &$v) {
71
- $v = trim($v);
72
- }
73
- }
74
-
75
- // Remove the header lines.
76
- foreach (array_keys($new->headerLines) as $key) {
77
- if (strtolower($key) === $name) {
78
- unset($new->headerLines[$key]);
79
- }
80
- }
81
-
82
- // Add the header line.
83
- $new->headerLines[$header] = $new->headers[$name];
84
-
85
- return $new;
86
- }
87
-
88
- public function withAddedHeader($header, $value)
89
- {
90
- if (!$this->hasHeader($header)) {
91
- return $this->withHeader($header, $value);
92
- }
93
-
94
- $new = clone $this;
95
- $new->headers[strtolower($header)][] = $value;
96
- $new->headerLines[$header][] = $value;
97
- return $new;
98
- }
99
-
100
- public function withoutHeader($header)
101
- {
102
- if (!$this->hasHeader($header)) {
103
- return $this;
104
- }
105
-
106
- $new = clone $this;
107
- $name = strtolower($header);
108
- unset($new->headers[$name]);
109
-
110
- foreach (array_keys($new->headerLines) as $key) {
111
- if (strtolower($key) === $name) {
112
- unset($new->headerLines[$key]);
113
- }
114
- }
115
-
116
- return $new;
117
- }
118
-
119
- public function getBody()
120
- {
121
- if (!$this->stream) {
122
- $this->stream = stream_for('');
123
- }
124
-
125
- return $this->stream;
126
- }
127
-
128
- public function withBody(StreamInterface $body)
129
- {
130
- if ($body === $this->stream) {
131
- return $this;
132
- }
133
-
134
- $new = clone $this;
135
- $new->stream = $body;
136
- return $new;
137
- }
138
-
139
- private function setHeaders(array $headers)
140
- {
141
- $this->headerLines = $this->headers = [];
142
- foreach ($headers as $header => $value) {
143
- $header = trim($header);
144
- $name = strtolower($header);
145
- if (!is_array($value)) {
146
- $value = trim($value);
147
- $this->headers[$name][] = $value;
148
- $this->headerLines[$header][] = $value;
149
- } else {
150
- foreach ($value as $v) {
151
- $v = trim($v);
152
- $this->headers[$name][] = $v;
153
- $this->headerLines[$header][] = $v;
154
- }
155
- }
156
- }
157
- }
158
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/psr7/src/MultipartStream.php DELETED
@@ -1,153 +0,0 @@
1
- <?php
2
- namespace GuzzleHttp\Psr7;
3
-
4
- use Psr\Http\Message\StreamInterface;
5
-
6
- /**
7
- * Stream that when read returns bytes for a streaming multipart or
8
- * multipart/form-data stream.
9
- */
10
- class MultipartStream implements StreamInterface
11
- {
12
- use StreamDecoratorTrait;
13
-
14
- private $boundary;
15
-
16
- /**
17
- * @param array $elements Array of associative arrays, each containing a
18
- * required "name" key mapping to the form field,
19
- * name, a required "contents" key mapping to a
20
- * StreamInterface/resource/string, an optional
21
- * "headers" associative array of custom headers,
22
- * and an optional "filename" key mapping to a
23
- * string to send as the filename in the part.
24
- * @param string $boundary You can optionally provide a specific boundary
25
- *
26
- * @throws \InvalidArgumentException
27
- */
28
- public function __construct(array $elements = [], $boundary = null)
29
- {
30
- $this->boundary = $boundary ?: uniqid();
31
- $this->stream = $this->createStream($elements);
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 headers needed before transferring the content of a POST file
51
- */
52
- private function getHeaders(array $headers)
53
- {
54
- $str = '';
55
- foreach ($headers as $key => $value) {
56
- $str .= "{$key}: {$value}\r\n";
57
- }
58
-
59
- return "--{$this->boundary}\r\n" . trim($str) . "\r\n\r\n";
60
- }
61
-
62
- /**
63
- * Create the aggregate stream that will be used to upload the POST data
64
- */
65
- protected function createStream(array $elements)
66
- {
67
- $stream = new AppendStream();
68
-
69
- foreach ($elements as $element) {
70
- $this->addElement($stream, $element);
71
- }
72
-
73
- // Add the trailing boundary with CRLF
74
- $stream->addStream(stream_for("--{$this->boundary}--\r\n"));
75
-
76
- return $stream;
77
- }
78
-
79
- private function addElement(AppendStream $stream, array $element)
80
- {
81
- foreach (['contents', 'name'] as $key) {
82
- if (!array_key_exists($key, $element)) {
83
- throw new \InvalidArgumentException("A '{$key}' key is required");
84
- }
85
- }
86
-
87
- $element['contents'] = stream_for($element['contents']);
88
-
89
- if (empty($element['filename'])) {
90
- $uri = $element['contents']->getMetadata('uri');
91
- if (substr($uri, 0, 6) !== 'php://') {
92
- $element['filename'] = $uri;
93
- }
94
- }
95
-
96
- list($body, $headers) = $this->createElement(
97
- $element['name'],
98
- $element['contents'],
99
- isset($element['filename']) ? $element['filename'] : null,
100
- isset($element['headers']) ? $element['headers'] : []
101
- );
102
-
103
- $stream->addStream(stream_for($this->getHeaders($headers)));
104
- $stream->addStream($body);
105
- $stream->addStream(stream_for("\r\n"));
106
- }
107
-
108
- /**
109
- * @return array
110
- */
111
- private function createElement($name, $stream, $filename, array $headers)
112
- {
113
- // Set a default content-disposition header if one was no provided
114
- $disposition = $this->getHeader($headers, 'content-disposition');
115
- if (!$disposition) {
116
- $headers['Content-Disposition'] = $filename
117
- ? sprintf('form-data; name="%s"; filename="%s"',
118
- $name,
119
- basename($filename))
120
- : "form-data; name=\"{$name}\"";
121
- }
122
-
123
- // Set a default content-length header if one was no provided
124
- $length = $this->getHeader($headers, 'content-length');
125
- if (!$length) {
126
- if ($length = $stream->getSize()) {
127
- $headers['Content-Length'] = (string) $length;
128
- }
129
- }
130
-
131
- // Set a default Content-Type if one was not supplied
132
- $type = $this->getHeader($headers, 'content-type');
133
- if (!$type && $filename) {
134
- if ($type = mimetype_from_filename($filename)) {
135
- $headers['Content-Type'] = $type;
136
- }
137
- }
138
-
139
- return [$stream, $headers];
140
- }
141
-
142
- private function getHeader(array $headers, $key)
143
- {
144
- $lowercaseHeader = strtolower($key);
145
- foreach ($headers as $k => $v) {
146
- if (strtolower($k) === $lowercaseHeader) {
147
- return $v;
148
- }
149
- }
150
-
151
- return null;
152
- }
153
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/psr7/src/NoSeekStream.php DELETED
@@ -1,22 +0,0 @@
1
- <?php
2
- namespace GuzzleHttp\Psr7;
3
-
4
- use Psr\Http\Message\StreamInterface;
5
-
6
- /**
7
- * Stream decorator that prevents a stream from being seeked
8
- */
9
- class NoSeekStream implements StreamInterface
10
- {
11
- use StreamDecoratorTrait;
12
-
13
- public function seek($offset, $whence = SEEK_SET)
14
- {
15
- throw new \RuntimeException('Cannot seek a NoSeekStream');
16
- }
17
-
18
- public function isSeekable()
19
- {
20
- return false;
21
- }
22
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/google-api-php-client/vendor/guzzlehttp/psr7/src/PumpStream.php DELETED
@@ -1,165 +0,0 @@
1
- <?php
2
- namespace GuzzleHttp\Psr7;
3
-
4
- use Psr\Http\Message\StreamInterface;
5
-
6
- /**
7
- * Provides a read only stream that pumps data from a PHP callable.
8
- *
9
- * When invoking the provided callable, the PumpStream will pass the amount of
10
- * data requested to read to the callable. The callable can choose to ignore
11
- * this value and return fewer or more bytes than requested. Any extra data
12
- * returned by the provided callable is buffered internally until drained using
13
- * the read() function of the PumpStream. The provided callable MUST return
14
- * false when there is no more data to read.
15
- */
16
- class PumpStream implements StreamInterface
17
- {
18
- /** @var callable */
19
- private $source;
20
-
21
- /** @var int */
22
- private $size;
23
-
24
- /** @var int */
25
- private $tellPos = 0;
26
-
27
- /** @var array */
28
- private $metadata;
29
-
30
- /** @var BufferStream */
31
- private $buffer;
32
-
33
- /**
34
- * @param callable $source Source of the stream data. The callable MAY
35
- * accept an integer argument used to control the
36
- * amount of data to return. The callable MUST
37
- * return a string when called, or false on error
38
- * or EOF.
39
- * @param array $options Stream options:
40
- *