WP Mail SMTP by WPForms - Version 1.5.2

Version Description

  • 2019-07-18 =
  • Fixed: "Redirect URI mismatch" error for "Gmail" mailer when trying to re-authorize an account that was initially created with version < v1.5.0.
  • Changed: Make "Authentication" setting in "Other SMTP" mailer ON by default for new users.
  • Changed: Mailers docs links now point to wpmailsmtp.com own site.
Download this release

Release Info

Developer slaFFik
Plugin Icon 128x128 WP Mail SMTP by WPForms
Version 1.5.2
Comparing to
See all releases

Code changes from version 1.5.1 to 1.5.2

Files changed (59) hide show
  1. assets/languages/wp-mail-smtp.pot +8 -4
  2. readme.txt +13 -6
  3. src/Admin/Area.php +1 -0
  4. src/Admin/PageAbstract.php +4 -0
  5. src/Admin/Pages/Test.php +1 -1
  6. src/Options.php +1 -0
  7. src/Providers/AuthAbstract.php +4 -0
  8. src/Providers/Gmail/Auth.php +27 -1
  9. src/Providers/Gmail/Options.php +1 -1
  10. src/Providers/Mailgun/Options.php +1 -1
  11. src/Providers/SMTP/Options.php +1 -1
  12. src/Providers/Sendgrid/Options.php +1 -1
  13. vendor/guzzlehttp/guzzle/LICENSE +19 -19
  14. vendor/guzzlehttp/guzzle/src/Client.php +422 -422
  15. vendor/guzzlehttp/guzzle/src/ClientInterface.php +84 -84
  16. vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php +314 -314
  17. vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php +84 -84
  18. vendor/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php +90 -90
  19. vendor/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php +71 -71
  20. vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php +403 -403
  21. vendor/guzzlehttp/guzzle/src/Exception/BadResponseException.php +27 -27
  22. vendor/guzzlehttp/guzzle/src/Exception/ClientException.php +7 -7
  23. vendor/guzzlehttp/guzzle/src/Exception/ConnectException.php +37 -37
  24. vendor/guzzlehttp/guzzle/src/Exception/GuzzleException.php +13 -13
  25. vendor/guzzlehttp/guzzle/src/Exception/RequestException.php +217 -217
  26. vendor/guzzlehttp/guzzle/src/Exception/SeekException.php +27 -27
  27. vendor/guzzlehttp/guzzle/src/Exception/ServerException.php +7 -7
  28. vendor/guzzlehttp/guzzle/src/Exception/TooManyRedirectsException.php +4 -4
  29. vendor/guzzlehttp/guzzle/src/Exception/TransferException.php +4 -4
  30. vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php +565 -565
  31. vendor/guzzlehttp/guzzle/src/Handler/CurlFactoryInterface.php +27 -27
  32. vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php +45 -45
  33. vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php +199 -199
  34. vendor/guzzlehttp/guzzle/src/Handler/EasyHandle.php +92 -92
  35. vendor/guzzlehttp/guzzle/src/Handler/MockHandler.php +189 -189
  36. vendor/guzzlehttp/guzzle/src/Handler/Proxy.php +55 -55
  37. vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php +532 -532
  38. vendor/guzzlehttp/guzzle/src/HandlerStack.php +273 -273
  39. vendor/guzzlehttp/guzzle/src/MessageFormatter.php +180 -180
  40. vendor/guzzlehttp/guzzle/src/Middleware.php +255 -255
  41. vendor/guzzlehttp/guzzle/src/Pool.php +123 -123
  42. vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php +106 -106
  43. vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php +237 -237
  44. vendor/guzzlehttp/guzzle/src/RequestOptions.php +255 -255
  45. vendor/guzzlehttp/guzzle/src/RetryMiddleware.php +112 -112
  46. vendor/guzzlehttp/guzzle/src/TransferStats.php +126 -126
  47. vendor/guzzlehttp/guzzle/src/UriTemplate.php +237 -237
  48. vendor/guzzlehttp/guzzle/src/functions.php +333 -333
  49. vendor/guzzlehttp/guzzle/src/functions_include.php +6 -6
  50. vendor/phpseclib/phpseclib/LICENSE +20 -21
  51. vendor/phpseclib/phpseclib/phpseclib/Crypt/AES.php +126 -126
  52. vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA.php +3201 -3201
  53. vendor/phpseclib/phpseclib/phpseclib/Crypt/Random.php +274 -274
  54. vendor/phpseclib/phpseclib/phpseclib/Crypt/Rijndael.php +936 -936
  55. vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger.php +3779 -3779
  56. vendor/phpseclib/phpseclib/phpseclib/bootstrap.php +16 -16
  57. vendor/phpseclib/phpseclib/phpseclib/openssl.cnf +6 -6
  58. vendor/phpseclib/phpseclib/travis/code_coverage_id_rsa +30 -0
  59. wp_mail_smtp.php +2 -2
assets/languages/wp-mail-smtp.pot CHANGED
@@ -1,13 +1,13 @@
1
msgid ""
2
msgstr ""
3
- "Project-Id-Version: WP Mail SMTP 1.5.0\n"
4
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wp-mail-smtp\n"
5
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
6
"Language-Team: LANGUAGE <LL@li.org>\n"
7
"MIME-Version: 1.0\n"
8
"Content-Type: text/plain; charset=UTF-8\n"
9
"Content-Transfer-Encoding: 8bit\n"
10
- "POT-Creation-Date: 2019-07-12T17:44:13+03:00\n"
11
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12
"X-Generator: WP-CLI 2.2.0\n"
13
"X-Domain: wp-mail-smtp\n"
@@ -128,7 +128,7 @@ msgstr ""
128
msgid "WP Mail SMTP Pro related message was successfully dismissed."
129
msgstr ""
130
131
- #: src/Admin/PageAbstract.php:77
132
msgid "Save Settings"
133
msgstr ""
134
@@ -733,7 +733,7 @@ msgid "This means the connection to your SMTP host was made successfully, but th
733
msgstr ""
734
735
#: src/Admin/Pages/Test.php:600
736
- msgid "Typically this error is returned when your are sending too many e-mails or e-mails that have been identified as spam."
737
msgstr ""
738
739
#: src/Admin/Pages/Test.php:603
@@ -1086,6 +1086,10 @@ msgstr ""
1086
msgid "Consider running an email test after fixing it."
1087
msgstr ""
1088
1089
#: src/Providers/Gmail/Options.php:32
1090
msgid "Gmail"
1091
msgstr ""
1
msgid ""
2
msgstr ""
3
+ "Project-Id-Version: WP Mail SMTP 1.5.2\n"
4
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wp-mail-smtp\n"
5
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
6
"Language-Team: LANGUAGE <LL@li.org>\n"
7
"MIME-Version: 1.0\n"
8
"Content-Type: text/plain; charset=UTF-8\n"
9
"Content-Transfer-Encoding: 8bit\n"
10
+ "POT-Creation-Date: 2019-07-18T11:22:11+03:00\n"
11
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12
"X-Generator: WP-CLI 2.2.0\n"
13
"X-Domain: wp-mail-smtp\n"
128
msgid "WP Mail SMTP Pro related message was successfully dismissed."
129
msgstr ""
130
131
+ #: src/Admin/PageAbstract.php:81
132
msgid "Save Settings"
133
msgstr ""
134
733
msgstr ""
734
735
#: src/Admin/Pages/Test.php:600
736
+ msgid "Typically this error is returned when you are sending too many e-mails or e-mails that have been identified as spam."
737
msgstr ""
738
739
#: src/Admin/Pages/Test.php:603
1086
msgid "Consider running an email test after fixing it."
1087
msgstr ""
1088
1089
+ #: src/Providers/Gmail/Auth.php:170
1090
+ msgid "There was an error while processing the Google authentication request. Please make sure that you have Client ID and Client Secret both valid and saved."
1091
+ msgstr ""
1092
+
1093
#: src/Providers/Gmail/Options.php:32
1094
msgid "Gmail"
1095
msgstr ""
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: wpforms, jaredatch, smub, slaFFik
3
Tags: smtp, wp mail smtp, wordpress smtp, gmail smtp, sendgrid smtp, mailgun smtp, mail, mailer, phpmailer, wp_mail, email, mailgun, sengrid, gmail, wp smtp
4
Requires at least: 4.9
5
Tested up to: 5.2
6
- Stable tag: 1.5.1
7
Requires PHP: 5.3
8
9
The most popular WordPress SMTP and PHP Mailer plugin. Trusted by over 1 million sites.
@@ -12,7 +12,7 @@ The most popular WordPress SMTP and PHP Mailer plugin. Trusted by over 1 million
12
13
### WordPress Mail SMTP Plugin
14
15
- Having problems with your WordPress site not sending emails? You're not alone. Over 1 million websites use WP Mail SMTP to send their emails reliabily.
16
17
Our goal is to make email deliverability easy and reliable. We want to ensure your emails reach the inbox.
18
@@ -59,7 +59,7 @@ Mailgun SMTP is a popular SMTP service provider that allows you to send large qu
59
60
WP Mail SMTP plugin offers a native integration with MailGun. All you have to do is connect your Mailgun account, and you will improve your email deliverability.
61
62
- Read our <a href="https://wpforms.com/how-to-send-wordpress-emails-with-mailgun/" rel="friend">Mailgun documentation</a> for more details.
63
64
= Gmail SMTP =
65
@@ -69,13 +69,13 @@ This allows you to use your <a href="http://www.wpbeginner.com/beginners-guide/h
69
70
Unlike other Gmail SMTP plugins, our Gmail SMTP option uses OAuth to authenticate your Google account, keeping your login information 100% secure.
71
72
- Read our <a href="https://wpforms.com/how-to-securely-send-wordpress-emails-using-gmail-smtp/" rel="friend">Gmail documentation</a> for more details.
73
74
= SendGrid SMTP =
75
76
SendGrid has a free SMTP plan that you can use to send up to 100 emails per day. With our native SendGrid SMTP integration, you can easily and securely set up SendGrid SMTP on your WordPress site.
77
78
- Read our <a href="https://wpforms.com/fix-wordpress-email-notifications-with-sendgrid/" rel="friend">SendGrid documentation</a> for more details.
79
80
= Microsoft SMTP (Outlook.com and Office 365) =
81
@@ -85,6 +85,8 @@ Many business use Outlook.com or Office 365 to their to power their email. For t
85
86
Advanced or technical users can harness the power of Amazon AWS (Amazon Web Services) with the Amazon SES mailer. With this integration, you can send a high volume of emails at a very reasonable rate.
87
88
= Other SMTP =
89
90
WP Mail SMTP plugin also works with all major email services such as Gmail, Yahoo, Outlook, Microsoft Live, and any other email sending service that offers SMTP.
@@ -97,7 +99,7 @@ You can set the following options:
97
* Choose to use SMTP authentication or not.
98
* Specify an SMTP username and password.
99
100
- To see recommended settings for the popular services as well as troubleshooting tips, check out our <a href="https://wpforms.com/docs/how-to-set-up-smtp-using-the-wp-mail-smtp-plugin/" rel="friend">SMTP documentation</a>.
101
102
We hope that you find WP Mail SMTP plugin helpful!
103
@@ -195,6 +197,11 @@ By all means please contact us to discuss features or options you'd like to see
195
196
== Changelog ==
197
198
= 1.5.1 - 2019-07-12 =
199
* Fixed: Duplicated emails sent to the first recipient in a loop (and others not receiving their emails).
200
3
Tags: smtp, wp mail smtp, wordpress smtp, gmail smtp, sendgrid smtp, mailgun smtp, mail, mailer, phpmailer, wp_mail, email, mailgun, sengrid, gmail, wp smtp
4
Requires at least: 4.9
5
Tested up to: 5.2
6
+ Stable tag: 1.5.2
7
Requires PHP: 5.3
8
9
The most popular WordPress SMTP and PHP Mailer plugin. Trusted by over 1 million sites.
12
13
### WordPress Mail SMTP Plugin
14
15
+ Having problems with your WordPress site not sending emails? You're not alone. Over 1 million websites use WP Mail SMTP to send their emails reliably.
16
17
Our goal is to make email deliverability easy and reliable. We want to ensure your emails reach the inbox.
18
59
60
WP Mail SMTP plugin offers a native integration with MailGun. All you have to do is connect your Mailgun account, and you will improve your email deliverability.
61
62
+ Read our <a href="https://wpmailsmtp.com/docs/how-to-set-up-the-mailgun-mailer-in-wp-mail-smtp/" rel="friend">Mailgun documentation</a> for more details.
63
64
= Gmail SMTP =
65
69
70
Unlike other Gmail SMTP plugins, our Gmail SMTP option uses OAuth to authenticate your Google account, keeping your login information 100% secure.
71
72
+ Read our <a href="https://wpmailsmtp.com/docs/how-to-set-up-the-gmail-mailer-in-wp-mail-smtp/" rel="friend">Gmail documentation</a> for more details.
73
74
= SendGrid SMTP =
75
76
SendGrid has a free SMTP plan that you can use to send up to 100 emails per day. With our native SendGrid SMTP integration, you can easily and securely set up SendGrid SMTP on your WordPress site.
77
78
+ Read our <a href="https://wpmailsmtp.com/docs/how-to-set-up-the-sendgrid-mailer-in-wp-mail-smtp/" rel="friend">SendGrid documentation</a> for more details.
79
80
= Microsoft SMTP (Outlook.com and Office 365) =
81
85
86
Advanced or technical users can harness the power of Amazon AWS (Amazon Web Services) with the Amazon SES mailer. With this integration, you can send a high volume of emails at a very reasonable rate.
87
88
+ Read our <a href="https://wpmailsmtp.com/docs/how-to-set-up-the-amazon-ses-mailer-in-wp-mail-smtp/" rel="friend">Amazon SES documentation</a> for more details.
89
+
90
= Other SMTP =
91
92
WP Mail SMTP plugin also works with all major email services such as Gmail, Yahoo, Outlook, Microsoft Live, and any other email sending service that offers SMTP.
99
* Choose to use SMTP authentication or not.
100
* Specify an SMTP username and password.
101
102
+ To see recommended settings for the popular services as well as troubleshooting tips, check out our <a href="https://wpmailsmtp.com/docs/how-to-set-up-the-other-smtp-mailer-in-wp-mail-smtp/" rel="friend">SMTP documentation</a>.
103
104
We hope that you find WP Mail SMTP plugin helpful!
105
197
198
== Changelog ==
199
200
+ = 1.5.2 - 2019-07-18 =
201
+ * Fixed: "Redirect URI mismatch" error for "Gmail" mailer when trying to re-authorize an account that was initially created with version < v1.5.0.
202
+ * Changed: Make "Authentication" setting in "Other SMTP" mailer ON by default for new users.
203
+ * Changed: Mailers docs links now point to wpmailsmtp.com own site.
204
+
205
= 1.5.1 - 2019-07-12 =
206
* Fixed: Duplicated emails sent to the first recipient in a loop (and others not receiving their emails).
207
src/Admin/Area.php CHANGED
@@ -731,6 +731,7 @@ class Area {
731
* Get plugin admin area page URL.
732
*
733
* @since 1.0.0
734
*
735
* @param string $page
736
*
731
* Get plugin admin area page URL.
732
*
733
* @since 1.0.0
734
+ * @since 1.5.0 URL is changed to support the top level position of the plugin admin area.
735
*
736
* @param string $page
737
*
src/Admin/PageAbstract.php CHANGED
@@ -18,6 +18,7 @@ abstract class PageAbstract implements PageInterface {
18
* @inheritdoc
19
*/
20
public function get_link() {
21
return esc_url(
22
add_query_arg(
23
'tab',
@@ -51,6 +52,7 @@ abstract class PageAbstract implements PageInterface {
51
* @since 1.0.0
52
*/
53
public function wp_nonce_field() {
54
wp_nonce_field( Area::SLUG . '-' . $this->slug );
55
}
56
@@ -61,6 +63,7 @@ abstract class PageAbstract implements PageInterface {
61
* @since 1.0.0
62
*/
63
public function check_admin_referer() {
64
check_admin_referer( Area::SLUG . '-' . $this->slug );
65
}
66
@@ -70,6 +73,7 @@ abstract class PageAbstract implements PageInterface {
70
* @since 1.5.0
71
*/
72
public function display_save_btn() {
73
?>
74
75
<p class="wp-mail-smtp-submit">
18
* @inheritdoc
19
*/
20
public function get_link() {
21
+
22
return esc_url(
23
add_query_arg(
24
'tab',
52
* @since 1.0.0
53
*/
54
public function wp_nonce_field() {
55
+
56
wp_nonce_field( Area::SLUG . '-' . $this->slug );
57
}
58
63
* @since 1.0.0
64
*/
65
public function check_admin_referer() {
66
+
67
check_admin_referer( Area::SLUG . '-' . $this->slug );
68
}
69
73
* @since 1.5.0
74
*/
75
public function display_save_btn() {
76
+
77
?>
78
79
<p class="wp-mail-smtp-submit">
src/Admin/Pages/Test.php CHANGED
@@ -597,7 +597,7 @@ Lead Developer, WP Mail SMTP';
597
'description' => array(
598
'<strong>' . esc_html__( 'Error due to unsolicited and/or bulk e-mail.', 'wp-mail-smtp' ) . '</strong>',
599
esc_html__( 'This means the connection to your SMTP host was made successfully, but the host rejected the email.', 'wp-mail-smtp' ),
600
- esc_html__( 'Typically this error is returned when your are sending too many e-mails or e-mails that have been identified as spam.', 'wp-mail-smtp' ),
601
),
602
'steps' => array(
603
esc_html__( 'Check the emails that are sending are sending individually. Example: email is not sending to 30 recipients. You can install any WordPress e-mail logging plugin to do that.', 'wp-mail-smtp' ),
597
'description' => array(
598
'<strong>' . esc_html__( 'Error due to unsolicited and/or bulk e-mail.', 'wp-mail-smtp' ) . '</strong>',
599
esc_html__( 'This means the connection to your SMTP host was made successfully, but the host rejected the email.', 'wp-mail-smtp' ),
600
+ esc_html__( 'Typically this error is returned when you are sending too many e-mails or e-mails that have been identified as spam.', 'wp-mail-smtp' ),
601
),
602
'steps' => array(
603
esc_html__( 'Check the emails that are sending are sending individually. Example: email is not sending to 30 recipients. You can install any WordPress e-mail logging plugin to do that.', 'wp-mail-smtp' ),
src/Options.php CHANGED
@@ -146,6 +146,7 @@ class Options {
146
),
147
'smtp' => array(
148
'autotls' => true,
149
),
150
);
151
}
146
),
147
'smtp' => array(
148
'autotls' => true,
149
+ 'auth' => true,
150
),
151
);
152
}
src/Providers/AuthAbstract.php CHANGED
@@ -51,6 +51,7 @@ abstract class AuthAbstract implements AuthInterface {
51
* @since 1.0.0
52
*/
53
protected function include_vendor_lib() {
54
require_once wp_mail_smtp()->plugin_path . '/vendor/autoload.php';
55
}
56
@@ -62,6 +63,7 @@ abstract class AuthAbstract implements AuthInterface {
62
* @return string
63
*/
64
public static function get_plugin_auth_url() {
65
return add_query_arg( 'tab', 'auth', wp_mail_smtp()->get_admin()->get_admin_page_url() );
66
}
67
@@ -132,6 +134,7 @@ abstract class AuthAbstract implements AuthInterface {
132
* @inheritdoc
133
*/
134
public function is_clients_saved() {
135
return ! empty( $this->options['client_id'] ) && ! empty( $this->options['client_secret'] );
136
}
137
@@ -139,6 +142,7 @@ abstract class AuthAbstract implements AuthInterface {
139
* @inheritdoc
140
*/
141
public function is_auth_required() {
142
return empty( $this->options['access_token'] ) || empty( $this->options['refresh_token'] );
143
}
144
}
51
* @since 1.0.0
52
*/
53
protected function include_vendor_lib() {
54
+
55
require_once wp_mail_smtp()->plugin_path . '/vendor/autoload.php';
56
}
57
63
* @return string
64
*/
65
public static function get_plugin_auth_url() {
66
+
67
return add_query_arg( 'tab', 'auth', wp_mail_smtp()->get_admin()->get_admin_page_url() );
68
}
69
134
* @inheritdoc
135
*/
136
public function is_clients_saved() {
137
+
138
return ! empty( $this->options['client_id'] ) && ! empty( $this->options['client_secret'] );
139
}
140
142
* @inheritdoc
143
*/
144
public function is_auth_required() {
145
+
146
return empty( $this->options['access_token'] ) || empty( $this->options['refresh_token'] );
147
}
148
}
src/Providers/Gmail/Auth.php CHANGED
@@ -2,6 +2,7 @@
2
3
namespace WPMailSMTP\Providers\Gmail;
4
5
use WPMailSMTP\Debug;
6
use WPMailSMTP\Options as PluginOptions;
7
use WPMailSMTP\Providers\AuthAbstract;
@@ -37,6 +38,24 @@ class Auth extends AuthAbstract {
37
}
38
}
39
40
/**
41
* Init and get the Google Client object.
42
*
@@ -140,9 +159,16 @@ class Auth extends AuthAbstract {
140
*/
141
public function process() {
142
143
// We can't process without saved client_id/secret.
144
if ( ! $this->is_clients_saved() ) {
145
- Debug::set( 'There was an error while processing the Google authentication request. Please make sure that you have Client ID and Client Secret both valid and saved.' );
146
wp_safe_redirect(
147
add_query_arg(
148
'error',
2
3
namespace WPMailSMTP\Providers\Gmail;
4
5
+ use WPMailSMTP\Admin\Area;
6
use WPMailSMTP\Debug;
7
use WPMailSMTP\Options as PluginOptions;
8
use WPMailSMTP\Providers\AuthAbstract;
38
}
39
}
40
41
+ /**
42
+ * Get the url, that users will be redirected back to finish the OAuth process.
43
+ *
44
+ * @since 1.5.2 Returned to the old, pre-1.5, structure of the link to preserve BC.
45
+ *
46
+ * @return string
47
+ */
48
+ public static function get_plugin_auth_url() {
49
+
50
+ return add_query_arg(
51
+ array(
52
+ 'page' => Area::SLUG,
53
+ 'tab' => 'auth',
54
+ ),
55
+ admin_url( 'options-general.php' )
56
+ );
57
+ }
58
+
59
/**
60
* Init and get the Google Client object.
61
*
159
*/
160
public function process() {
161
162
+ if ( ! ( isset( $_GET['tab'] ) && $_GET['tab'] === 'auth' ) ) {
163
+ wp_safe_redirect( wp_mail_smtp()->get_admin()->get_admin_page_url() );
164
+ exit;
165
+ }
166
+
167
// We can't process without saved client_id/secret.
168
if ( ! $this->is_clients_saved() ) {
169
+ Debug::set(
170
+ esc_html__( 'There was an error while processing the Google authentication request. Please make sure that you have Client ID and Client Secret both valid and saved.', 'wp-mail-smtp' )
171
+ );
172
wp_safe_redirect(
173
add_query_arg(
174
'error',
src/Providers/Gmail/Options.php CHANGED
@@ -43,7 +43,7 @@ class Options extends OptionsAbstract {
43
),
44
)
45
),
46
- '<a href="https://wpforms.com/how-to-securely-send-wordpress-emails-using-gmail-smtp/" target="_blank" rel="noopener noreferrer">',
47
'</a>'
48
),
49
'php' => '5.5',
43
),
44
)
45
),
46
+ '<a href="https://wpmailsmtp.com/docs/how-to-set-up-the-gmail-mailer-in-wp-mail-smtp/" target="_blank" rel="noopener noreferrer">',
47
'</a>'
48
),
49
'php' => '5.5',
src/Providers/Mailgun/Options.php CHANGED
@@ -38,7 +38,7 @@ class Options extends OptionsAbstract {
38
),
39
'<a href="https://www.mailgun.com" target="_blank" rel="noopener noreferrer">',
40
'</a>',
41
- '<a href="https://wpforms.com/how-to-send-wordpress-emails-with-mailgun/" target="_blank" rel="noopener noreferrer">',
42
'</a>'
43
),
44
)
38
),
39
'<a href="https://www.mailgun.com" target="_blank" rel="noopener noreferrer">',
40
'</a>',
41
+ '<a href="https://wpmailsmtp.com/docs/how-to-set-up-the-mailgun-mailer-in-wp-mail-smtp/" target="_blank" rel="noopener noreferrer">',
42
'</a>'
43
),
44
)
src/Providers/SMTP/Options.php CHANGED
@@ -36,7 +36,7 @@ class Options extends OptionsAbstract {
36
),
37
)
38
),
39
- 'https://wpforms.com/docs/how-to-set-up-smtp-using-the-wp-mail-smtp-plugin/'
40
),
41
)
42
);
36
),
37
)
38
),
39
+ 'https://wpmailsmtp.com/docs/how-to-set-up-the-other-smtp-mailer-in-wp-mail-smtp/'
40
),
41
)
42
);
src/Providers/Sendgrid/Options.php CHANGED
@@ -38,7 +38,7 @@ class Options extends OptionsAbstract {
38
),
39
'<a href="https://sendgrid.com" target="_blank" rel="noopener noreferrer">',
40
'</a>',
41
- '<a href="https://wpforms.com/fix-wordpress-email-notifications-with-sendgrid/" target="_blank" rel="noopener noreferrer">',
42
'</a>'
43
),
44
)
38
),
39
'<a href="https://sendgrid.com" target="_blank" rel="noopener noreferrer">',
40
'</a>',
41
+ '<a href="https://wpmailsmtp.com/docs/how-to-set-up-the-sendgrid-mailer-in-wp-mail-smtp/" target="_blank" rel="noopener noreferrer">',
42
'</a>'
43
),
44
)
vendor/guzzlehttp/guzzle/LICENSE CHANGED
@@ -1,19 +1,19 @@
1
- Copyright (c) 2011-2018 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.
1
+ Copyright (c) 2011-2018 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.
vendor/guzzlehttp/guzzle/src/Client.php CHANGED
@@ -1,422 +1,422 @@
1
- <?php
2
- namespace GuzzleHttp;
3
-
4
- use GuzzleHttp\Cookie\CookieJar;
5
- use GuzzleHttp\Promise;
6
- use GuzzleHttp\Psr7;
7
- use Psr\Http\Message\UriInterface;
8
- use Psr\Http\Message\RequestInterface;
9
- use Psr\Http\Message\ResponseInterface;
10
-
11
- /**
12
- * @method ResponseInterface get(string|UriInterface $uri, array $options = [])
13
- * @method ResponseInterface head(string|UriInterface $uri, array $options = [])
14
- * @method ResponseInterface put(string|UriInterface $uri, array $options = [])
15
- * @method ResponseInterface post(string|UriInterface $uri, array $options = [])
16
- * @method ResponseInterface patch(string|UriInterface $uri, array $options = [])
17
- * @method ResponseInterface delete(string|UriInterface $uri, array $options = [])
18
- * @method Promise\PromiseInterface getAsync(string|UriInterface $uri, array $options = [])
19
- * @method Promise\PromiseInterface headAsync(string|UriInterface $uri, array $options = [])
20
- * @method Promise\PromiseInterface putAsync(string|UriInterface $uri, array $options = [])
21
- * @method Promise\PromiseInterface postAsync(string|UriInterface $uri, array $options = [])
22
- * @method Promise\PromiseInterface patchAsync(string|UriInterface $uri, array $options = [])
23
- * @method Promise\PromiseInterface deleteAsync(string|UriInterface $uri, array $options = [])
24
- */
25
- class Client implements ClientInterface
26
- {
27
- /** @var array Default request options */
28
- private $config;
29
-
30
- /**
31
- * Clients accept an array of constructor parameters.
32
- *
33
- * Here's an example of creating a client using a base_uri and an array of
34
- * default request options to apply to each request:
35
- *
36
- * $client = new Client([
37
- * 'base_uri' => 'http://www.foo.com/1.0/',
38
- * 'timeout' => 0,
39
- * 'allow_redirects' => false,
40
- * 'proxy' => '192.168.16.1:10'
41
- * ]);
42
- *
43
- * Client configuration settings include the following options:
44
- *
45
- * - handler: (callable) Function that transfers HTTP requests over the
46
- * wire. The function is called with a Psr7\Http\Message\RequestInterface
47
- * and array of transfer options, and must return a
48
- * GuzzleHttp\Promise\PromiseInterface that is fulfilled with a
49
- * Psr7\Http\Message\ResponseInterface on success. "handler" is a
50
- * constructor only option that cannot be overridden in per/request
51
- * options. If no handler is provided, a default handler will be created
52
- * that enables all of the request options below by attaching all of the
53
- * default middleware to the handler.
54
- * - base_uri: (string|UriInterface) Base URI of the client that is merged
55
- * into relative URIs. Can be a string or instance of UriInterface.
56
- * - **: any request option
57
- *
58
- * @param array $config Client configuration settings.
59
- *
60
- * @see \GuzzleHttp\RequestOptions for a list of available request options.
61
- */
62
- public function __construct(array $config = [])
63
- {
64
- if (!isset($config['handler'])) {
65
- $config['handler'] = HandlerStack::create();
66
- } elseif (!is_callable($config['handler'])) {
67
- throw new \InvalidArgumentException('handler must be a callable');
68
- }
69
-
70
- // Convert the base_uri to a UriInterface
71
- if (isset($config['base_uri'])) {
72
- $config['base_uri'] = Psr7\uri_for($config['base_uri']);
73
- }
74
-
75
- $this->configureDefaults($config);
76
- }
77
-
78
- public function __call($method, $args)
79
- {
80
- if (count($args) < 1) {
81
- throw new \InvalidArgumentException('Magic request methods require a URI and optional options array');
82
- }
83
-
84
- $uri = $args[0];
85
- $opts = isset($args[1]) ? $args[1] : [];
86
-
87
- return substr($method, -5) === 'Async'
88
- ? $this->requestAsync(substr($method, 0, -5), $uri, $opts)
89
- : $this->request($method, $uri, $opts);
90
- }
91
-
92
- public function sendAsync(RequestInterface $request, array $options = [])
93
- {
94
- // Merge the base URI into the request URI if needed.
95
- $options = $this->prepareDefaults($options);
96
-
97
- return $this->transfer(
98
- $request->withUri($this->buildUri($request->getUri(), $options), $request->hasHeader('Host')),
99
- $options
100
- );
101
- }
102
-
103
- public function send(RequestInterface $request, array $options = [])
104
- {
105
- $options[RequestOptions::SYNCHRONOUS] = true;
106
- return $this->sendAsync($request, $options)->wait();
107
- }
108
-
109
- public function requestAsync($method, $uri = '', array $options = [])
110
- {
111
- $options = $this->prepareDefaults($options);
112
- // Remove request modifying parameter because it can be done up-front.
113
- $headers = isset($options['headers']) ? $options['headers'] : [];
114
- $body = isset($options['body']) ? $options['body'] : null;
115
- $version = isset($options['version']) ? $options['version'] : '1.1';
116
- // Merge the URI into the base URI.
117
- $uri = $this->buildUri($uri, $options);
118
- if (is_array($body)) {
119
- $this->invalidBody();
120
- }
121
- $request = new Psr7\Request($method, $uri, $headers, $body, $version);
122
- // Remove the option so that they are not doubly-applied.
123
- unset($options['headers'], $options['body'], $options['version']);
124
-
125
- return $this->transfer($request, $options);
126
- }
127
-
128
- public function request($method, $uri = '', array $options = [])
129
- {
130
- $options[RequestOptions::SYNCHRONOUS] = true;
131
- return $this->requestAsync($method, $uri, $options)->wait();
132
- }
133
-
134
- public function getConfig($option = null)
135
- {
136
- return $option === null
137
- ? $this->config
138
- : (isset($this->config[$option]) ? $this->config[$option] : null);
139
- }
140
-
141
- private function buildUri($uri, array $config)
142
- {
143
- // for BC we accept null which would otherwise fail in uri_for
144
- $uri = Psr7\uri_for($uri === null ? '' : $uri);
145
-
146
- if (isset($config['base_uri'])) {
147
- $uri = Psr7\UriResolver::resolve(Psr7\uri_for($config['base_uri']), $uri);
148
- }
149
-
150
- return $uri->getScheme() === '' && $uri->getHost() !== '' ? $uri->withScheme('http') : $uri;
151
- }
152
-
153
- /**
154
- * Configures the default options for a client.
155
- *
156
- * @param array $config
157
- */
158
- private function configureDefaults(array $config)
159
- {
160
- $defaults = [
161
- 'allow_redirects' => RedirectMiddleware::$defaultSettings,
162
- 'http_errors' => true,
163
- 'decode_content' => true,
164
- 'verify' => true,
165
- 'cookies' => false
166
- ];
167
-
168
- // Use the standard Linux HTTP_PROXY and HTTPS_PROXY if set.
169
-
170
- // We can only trust the HTTP_PROXY environment variable in a CLI
171
- // process due to the fact that PHP has no reliable mechanism to
172
- // get environment variables that start with "HTTP_".
173
- if (php_sapi_name() == 'cli' && getenv('HTTP_PROXY')) {
174
- $defaults['proxy']['http'] = getenv('HTTP_PROXY');
175
- }
176
-
177
- if ($proxy = getenv('HTTPS_PROXY')) {
178
- $defaults['proxy']['https'] = $proxy;
179
- }
180
-
181
- if ($noProxy = getenv('NO_PROXY')) {
182
- $cleanedNoProxy = str_replace(' ', '', $noProxy);
183
- $defaults['proxy']['no'] = explode(',', $cleanedNoProxy);
184
- }
185
-
186
- $this->config = $config + $defaults;
187
-
188
- if (!empty($config['cookies']) && $config['cookies'] === true) {
189
- $this->config['cookies'] = new CookieJar();
190
- }
191
-
192
- // Add the default user-agent header.
193
- if (!isset($this->config['headers'])) {
194
- $this->config['headers'] = ['User-Agent' => default_user_agent()];
195
- } else {
196
- // Add the User-Agent header if one was not already set.
197
- foreach (array_keys($this->config['headers']) as $name) {
198
- if (strtolower($name) === 'user-agent') {
199
- return;
200
- }
201
- }
202
- $this->config['headers']['User-Agent'] = default_user_agent();
203
- }
204
- }
205
-
206
- /**
207
- * Merges default options into the array.
208
- *
209
- * @param array $options Options to modify by reference
210
- *
211
- * @return array
212
- */
213
- private function prepareDefaults($options)
214
- {
215
- $defaults = $this->config;
216
-
217
- if (!empty($defaults['headers'])) {
218
- // Default headers are only added if they are not present.
219
- $defaults['_conditional'] = $defaults['headers'];
220
- unset($defaults['headers']);
221
- }
222
-
223
- // Special handling for headers is required as they are added as
224
- // conditional headers and as headers passed to a request ctor.
225
- if (array_key_exists('headers', $options)) {
226
- // Allows default headers to be unset.
227
- if ($options['headers'] === null) {
228
- $defaults['_conditional'] = null;
229
- unset($options['headers']);
230
- } elseif (!is_array($options['headers'])) {
231
- throw new \InvalidArgumentException('headers must be an array');
232
- }
233
- }
234
-
235
- // Shallow merge defaults underneath options.
236
- $result = $options + $defaults;
237
-
238
- // Remove null values.
239
- foreach ($result as $k => $v) {
240
- if ($v === null) {
241
- unset($result[$k]);
242
- }
243
- }
244
-
245
- return $result;
246
- }
247
-
248
- /**
249
- * Transfers the given request and applies request options.
250
- *
251
- * The URI of the request is not modified and the request options are used
252
- * as-is without merging in default options.
253
- *
254
- * @param RequestInterface $request
255
- * @param array $options
256
- *
257
- * @return Promise\PromiseInterface
258
- */
259
- private function transfer(RequestInterface $request, array $options)
260
- {
261
- // save_to -> sink
262
- if (isset($options['save_to'])) {
263
- $options['sink'] = $options['save_to'];
264
- unset($options['save_to']);
265
- }
266
-
267
- // exceptions -> http_errors
268
- if (isset($options['exceptions'])) {
269
- $options['http_errors'] = $options['exceptions'];
270
- unset($options['exceptions']);
271
- }
272
-
273
- $request = $this->applyOptions($request, $options);
274
- $handler = $options['handler'];
275
-
276
- try {
277
- return Promise\promise_for($handler($request, $options));
278
- } catch (\Exception $e) {
279
- return Promise\rejection_for($e);
280
- }
281
- }
282
-
283
- /**
284
- * Applies the array of request options to a request.
285
- *
286
- * @param RequestInterface $request
287
- * @param array $options
288
- *
289
- * @return RequestInterface
290
- */
291
- private function applyOptions(RequestInterface $request, array &$options)
292
- {
293
- $modify = [
294
- 'set_headers' => [],
295
- ];
296
-
297
- if (isset($options['headers'])) {
298
- $modify['set_headers'] = $options['headers'];
299
- unset($options['headers']);
300
- }
301
-
302
- if (isset($options['form_params'])) {
303
- if (isset($options['multipart'])) {
304
- throw new \InvalidArgumentException('You cannot use '
305
- . 'form_params and multipart at the same time. Use the '
306
- . 'form_params option if you want to send application/'
307
- . 'x-www-form-urlencoded requests, and the multipart '
308
- . 'option to send multipart/form-data requests.');
309
- }
310
- $options['body'] = http_build_query($options['form_params'], '', '&');
311
- unset($options['form_params']);
312
- // Ensure that we don't have the header in different case and set the new value.
313
- $options['_conditional'] = Psr7\_caseless_remove(['Content-Type'], $options['_conditional']);
314
- $options['_conditional']['Content-Type'] = 'application/x-www-form-urlencoded';
315
- }
316
-
317
- if (isset($options['multipart'])) {
318
- $options['body'] = new Psr7\MultipartStream($options['multipart']);
319
- unset($options['multipart']);
320
- }
321
-
322
- if (isset($options['json'])) {
323
- $options['body'] = \GuzzleHttp\json_encode($options['json']);
324
- unset($options['json']);
325
- // Ensure that we don't have the header in different case and set the new value.
326
- $options['_conditional'] = Psr7\_caseless_remove(['Content-Type'], $options['_conditional']);
327
- $options['_conditional']['Content-Type'] = 'application/json';
328
- }
329
-
330
- if (!empty($options['decode_content'])
331
- && $options['decode_content'] !== true
332
- ) {
333
- // Ensure that we don't have the header in different case and set the new value.
334
- $options['_conditional'] = Psr7\_caseless_remove(['Accept-Encoding'], $options['_conditional']);
335
- $modify['set_headers']['Accept-Encoding'] = $options['decode_content'];
336
- }
337
-
338
- if (isset($options['body'])) {
339
- if (is_array($options['body'])) {
340
- $this->invalidBody();
341
- }
342
- $modify['body'] = Psr7\stream_for($options['body']);
343
- unset($options['body']);
344
- }
345
-
346
- if (!empty($options['auth']) && is_array($options['auth'])) {
347
- $value = $options['auth'];
348
- $type = isset($value[2]) ? strtolower($value[2]) : 'basic';
349
- switch ($type) {
350
- case 'basic':
351
- // Ensure that we don't have the header in different case and set the new value.
352
- $modify['set_headers'] = Psr7\_caseless_remove(['Authorization'], $modify['set_headers']);
353
- $modify['set_headers']['Authorization'] = 'Basic '
354
- . base64_encode("$value[0]:$value[1]");
355
- break;
356
- case 'digest':
357
- // @todo: Do not rely on curl
358
- $options['curl'][CURLOPT_HTTPAUTH] = CURLAUTH_DIGEST;
359
- $options['curl'][CURLOPT_USERPWD] = "$value[0]:$value[1]";
360
- break;
361
- case 'ntlm':
362
- $options['curl'][CURLOPT_HTTPAUTH] = CURLAUTH_NTLM;
363
- $options['curl'][CURLOPT_USERPWD] = "$value[0]:$value[1]";
364
- break;
365
- }
366
- }
367
-
368
- if (isset($options['query'])) {
369
- $value = $options['query'];
370
- if (is_array($value)) {
371
- $value = http_build_query($value, null, '&', PHP_QUERY_RFC3986);
372
- }
373
- if (!is_string($value)) {
374
- throw new \InvalidArgumentException('query must be a string or array');
375
- }
376
- $modify['query'] = $value;
377
- unset($options['query']);
378
- }
379
-
380
- // Ensure that sink is not an invalid value.
381
- if (isset($options['sink'])) {
382
- // TODO: Add more sink validation?
383
- if (is_bool($options['sink'])) {
384
- throw new \InvalidArgumentException('sink must not be a boolean');
385
- }
386
- }
387
-
388
- $request = Psr7\modify_request($request, $modify);
389
- if ($request->getBody() instanceof Psr7\MultipartStream) {
390
- // Use a multipart/form-data POST if a Content-Type is not set.
391
- // Ensure that we don't have the header in different case and set the new value.
392
- $options['_conditional'] = Psr7\_caseless_remove(['Content-Type'], $options['_conditional']);
393
- $options['_conditional']['Content-Type'] = 'multipart/form-data; boundary='
394
- . $request->getBody()->getBoundary();
395
- }
396
-
397
- // Merge in conditional headers if they are not present.
398
- if (isset($options['_conditional'])) {
399
- // Build up the changes so it's in a single clone of the message.
400
- $modify = [];
401
- foreach ($options['_conditional'] as $k => $v) {
402
- if (!$request->hasHeader($k)) {
403
- $modify['set_headers'][$k] = $v;
404
- }
405
- }
406
- $request = Psr7\modify_request($request, $modify);
407
- // Don't pass this internal value along to middleware/handlers.
408
- unset($options['_conditional']);
409
- }
410
-
411
- return $request;
412
- }
413
-
414
- private function invalidBody()
415
- {
416
- throw new \InvalidArgumentException('Passing in the "body" request '
417
- . 'option as an array to send a POST request has been deprecated. '
418
- . 'Please use the "form_params" request option to send a '
419
- . 'application/x-www-form-urlencoded request, or the "multipart" '
420
- . 'request option to send a multipart/form-data request.');
421
- }
422
- }
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ use GuzzleHttp\Cookie\CookieJar;
5
+ use GuzzleHttp\Promise;
6
+ use GuzzleHttp\Psr7;
7
+ use Psr\Http\Message\UriInterface;
8
+ use Psr\Http\Message\RequestInterface;
9
+ use Psr\Http\Message\ResponseInterface;
10
+
11
+ /**
12
+ * @method ResponseInterface get(string|UriInterface $uri, array $options = [])
13
+ * @method ResponseInterface head(string|UriInterface $uri, array $options = [])
14
+ * @method ResponseInterface put(string|UriInterface $uri, array $options = [])
15
+ * @method ResponseInterface post(string|UriInterface $uri, array $options = [])
16
+ * @method ResponseInterface patch(string|UriInterface $uri, array $options = [])
17
+ * @method ResponseInterface delete(string|UriInterface $uri, array $options = [])
18
+ * @method Promise\PromiseInterface getAsync(string|UriInterface $uri, array $options = [])
19
+ * @method Promise\PromiseInterface headAsync(string|UriInterface $uri, array $options = [])
20
+ * @method Promise\PromiseInterface putAsync(string|UriInterface $uri, array $options = [])
21
+ * @method Promise\PromiseInterface postAsync(string|UriInterface $uri, array $options = [])
22
+ * @method Promise\PromiseInterface patchAsync(string|UriInterface $uri, array $options = [])
23
+ * @method Promise\PromiseInterface deleteAsync(string|UriInterface $uri, array $options = [])
24
+ */
25
+ class Client implements ClientInterface
26
+ {
27
+ /** @var array Default request options */
28
+ private $config;
29
+
30
+ /**
31
+ * Clients accept an array of constructor parameters.
32
+ *
33
+ * Here's an example of creating a client using a base_uri and an array of
34
+ * default request options to apply to each request:
35
+ *
36
+ * $client = new Client([
37
+ * 'base_uri' => 'http://www.foo.com/1.0/',
38
+ * 'timeout' => 0,
39
+ * 'allow_redirects' => false,
40
+ * 'proxy' => '192.168.16.1:10'
41
+ * ]);
42
+ *
43
+ * Client configuration settings include the following options:
44
+ *
45
+ * - handler: (callable) Function that transfers HTTP requests over the
46
+ * wire. The function is called with a Psr7\Http\Message\RequestInterface
47
+ * and array of transfer options, and must return a
48
+ * GuzzleHttp\Promise\PromiseInterface that is fulfilled with a
49
+ * Psr7\Http\Message\ResponseInterface on success. "handler" is a
50
+ * constructor only option that cannot be overridden in per/request
51
+ * options. If no handler is provided, a default handler will be created
52
+ * that enables all of the request options below by attaching all of the
53
+ * default middleware to the handler.
54
+ * - base_uri: (string|UriInterface) Base URI of the client that is merged
55
+ * into relative URIs. Can be a string or instance of UriInterface.
56
+ * - **: any request option
57
+ *
58
+ * @param array $config Client configuration settings.
59
+ *
60
+ * @see \GuzzleHttp\RequestOptions for a list of available request options.
61
+ */
62
+ public function __construct(array $config = [])
63
+ {
64
+ if (!isset($config['handler'])) {
65
+ $config['handler'] = HandlerStack::create();
66
+ } elseif (!is_callable($config['handler'])) {
67
+ throw new \InvalidArgumentException('handler must be a callable');
68
+ }
69
+
70
+ // Convert the base_uri to a UriInterface
71
+ if (isset($config['base_uri'])) {
72
+ $config['base_uri'] = Psr7\uri_for($config['base_uri']);
73
+ }
74
+
75
+ $this->configureDefaults($config);
76
+ }
77
+
78
+ public function __call($method, $args)
79
+ {
80
+ if (count($args) < 1) {
81
+ throw new \InvalidArgumentException('Magic request methods require a URI and optional options array');
82
+ }
83
+
84
+ $uri = $args[0];
85
+ $opts = isset($args[1]) ? $args[1] : [];
86
+
87
+ return substr($method, -5) === 'Async'
88
+ ? $this->requestAsync(substr($method, 0, -5), $uri, $opts)
89
+ : $this->request($method, $uri, $opts);
90
+ }
91
+
92
+ public function sendAsync(RequestInterface $request, array $options = [])
93
+ {
94
+ // Merge the base URI into the request URI if needed.
95
+ $options = $this->prepareDefaults($options);
96
+
97
+ return $this->transfer(
98
+ $request->withUri($this->buildUri($request->getUri(), $options), $request->hasHeader('Host')),
99
+ $options
100
+ );
101
+ }
102
+
103
+ public function send(RequestInterface $request, array $options = [])
104
+ {
105
+ $options[RequestOptions::SYNCHRONOUS] = true;
106
+ return $this->sendAsync($request, $options)->wait();
107
+ }
108
+
109
+ public function requestAsync($method, $uri = '', array $options = [])
110
+ {
111
+ $options = $this->prepareDefaults($options);
112
+ // Remove request modifying parameter because it can be done up-front.
113
+ $headers = isset($options['headers']) ? $options['headers'] : [];
114
+ $body = isset($options['body']) ? $options['body'] : null;
115
+ $version = isset($options['version']) ? $options['version'] : '1.1';
116
+ // Merge the URI into the base URI.
117
+ $uri = $this->buildUri($uri, $options);
118
+ if (is_array($body)) {
119
+ $this->invalidBody();
120
+ }
121
+ $request = new Psr7\Request($method, $uri, $headers, $body, $version);
122
+ // Remove the option so that they are not doubly-applied.
123
+ unset($options['headers'], $options['body'], $options['version']);
124
+
125
+ return $this->transfer($request, $options);
126
+ }
127
+
128
+ public function request($method, $uri = '', array $options = [])
129
+ {
130
+ $options[RequestOptions::SYNCHRONOUS] = true;
131
+ return $this->requestAsync($method, $uri, $options)->wait();
132
+ }
133
+
134
+ public function getConfig($option = null)
135
+ {
136
+ return $option === null
137
+ ? $this->config
138
+ : (isset($this->config[$option]) ? $this->config[$option] : null);
139
+ }
140
+
141
+ private function buildUri($uri, array $config)
142
+ {
143
+ // for BC we accept null which would otherwise fail in uri_for
144
+ $uri = Psr7\uri_for($uri === null ? '' : $uri);
145
+
146
+ if (isset($config['base_uri'])) {
147
+ $uri = Psr7\UriResolver::resolve(Psr7\uri_for($config['base_uri']), $uri);
148
+ }
149
+
150
+ return $uri->getScheme() === '' && $uri->getHost() !== '' ? $uri->withScheme('http') : $uri;
151
+ }
152
+
153
+ /**
154
+ * Configures the default options for a client.
155
+ *
156
+ * @param array $config
157
+ */
158
+ private function configureDefaults(array $config)
159
+ {
160
+ $defaults = [
161
+ 'allow_redirects' => RedirectMiddleware::$defaultSettings,
162
+ 'http_errors' => true,
163
+ 'decode_content' => true,
164
+ 'verify' => true,
165
+ 'cookies' => false
166
+ ];
167
+
168
+ // Use the standard Linux HTTP_PROXY and HTTPS_PROXY if set.
169
+
170
+ // We can only trust the HTTP_PROXY environment variable in a CLI
171
+ // process due to the fact that PHP has no reliable mechanism to
172
+ // get environment variables that start with "HTTP_".
173
+ if (php_sapi_name() == 'cli' && getenv('HTTP_PROXY')) {
174
+ $defaults['proxy']['http'] = getenv('HTTP_PROXY');
175
+ }
176
+
177
+ if ($proxy = getenv('HTTPS_PROXY')) {
178
+ $defaults['proxy']['https'] = $proxy;
179
+ }
180
+
181
+ if ($noProxy = getenv('NO_PROXY')) {
182
+ $cleanedNoProxy = str_replace(' ', '', $noProxy);
183
+ $defaults['proxy']['no'] = explode(',', $cleanedNoProxy);
184
+ }
185
+
186
+ $this->config = $config + $defaults;
187
+
188
+ if (!empty($config['cookies']) && $config['cookies'] === true) {
189
+ $this->config['cookies'] = new CookieJar();
190
+ }
191
+
192
+ // Add the default user-agent header.
193
+ if (!isset($this->config['headers'])) {
194
+ $this->config['headers'] = ['User-Agent' => default_user_agent()];
195
+ } else {
196
+ // Add the User-Agent header if one was not already set.
197
+ foreach (array_keys($this->config['headers']) as $name) {
198
+ if (strtolower($name) === 'user-agent') {
199
+ return;
200
+ }
201
+ }
202
+ $this->config['headers']['User-Agent'] = default_user_agent();
203
+ }
204
+ }
205
+
206
+ /**
207
+ * Merges default options into the array.
208
+ *
209
+ * @param array $options Options to modify by reference
210
+ *
211
+ * @return array
212
+ */
213
+ private function prepareDefaults($options)
214
+ {
215
+ $defaults = $this->config;
216
+
217
+ if (!empty($defaults['headers'])) {
218
+ // Default headers are only added if they are not present.
219
+ $defaults['_conditional'] = $defaults['headers'];
220
+ unset($defaults['headers']);
221
+ }
222
+
223
+ // Special handling for headers is required as they are added as
224
+ // conditional headers and as headers passed to a request ctor.
225
+ if (array_key_exists('headers', $options)) {
226
+ // Allows default headers to be unset.
227
+ if ($options['headers'] === null) {
228
+ $defaults['_conditional'] = null;
229
+ unset($options['headers']);
230
+ } elseif (!is_array($options['headers'])) {
231
+ throw new \InvalidArgumentException('headers must be an array');
232
+ }
233
+ }
234
+
235
+ // Shallow merge defaults underneath options.
236
+ $result = $options + $defaults;
237
+
238
+ // Remove null values.
239
+ foreach ($result as $k => $v) {
240
+ if ($v === null) {
241
+ unset($result[$k]);
242
+ }
243
+ }
244
+
245
+ return $result;
246
+ }
247
+
248
+ /**
249
+ * Transfers the given request and applies request options.
250
+ *
251
+ * The URI of the request is not modified and the request options are used
252
+ * as-is without merging in default options.
253
+ *
254
+ * @param RequestInterface $request
255
+ * @param array $options
256
+ *
257
+ * @return Promise\PromiseInterface
258
+ */
259
+ private function transfer(RequestInterface $request, array $options)
260
+ {
261
+ // save_to -> sink
262
+ if (isset($options['save_to'])) {
263
+ $options['sink'] = $options['save_to'];
264
+ unset($options['save_to']);
265
+ }
266
+
267
+ // exceptions -> http_errors
268
+ if (isset($options['exceptions'])) {
269
+ $options['http_errors'] = $options['exceptions'];
270
+ unset($options['exceptions']);
271
+ }
272
+
273
+ $request = $this->applyOptions($request, $options);
274
+ $handler = $options['handler'];
275
+
276
+ try {
277
+ return Promise\promise_for($handler($request, $options));
278
+ } catch (\Exception $e) {
279
+ return Promise\rejection_for($e);
280
+ }
281
+ }
282
+
283
+ /**
284
+ * Applies the array of request options to a request.
285
+ *
286
+ * @param RequestInterface $request
287
+ * @param array $options
288
+ *
289
+ * @return RequestInterface
290
+ */
291
+ private function applyOptions(RequestInterface $request, array &$options)
292
+ {
293
+ $modify = [
294
+ 'set_headers' => [],
295
+ ];
296
+
297
+ if (isset($options['headers'])) {
298
+ $modify['set_headers'] = $options['headers'];
299
+ unset($options['headers']);
300
+ }
301
+
302
+ if (isset($options['form_params'])) {
303
+ if (isset($options['multipart'])) {
304
+ throw new \InvalidArgumentException('You cannot use '
305
+ . 'form_params and multipart at the same time. Use the '
306
+ . 'form_params option if you want to send application/'
307
+ . 'x-www-form-urlencoded requests, and the multipart '
308
+ . 'option to send multipart/form-data requests.');
309
+ }
310
+ $options['body'] = http_build_query($options['form_params'], '', '&');
311
+ unset($options['form_params']);
312
+ // Ensure that we don't have the header in different case and set the new value.
313
+ $options['_conditional'] = Psr7\_caseless_remove(['Content-Type'], $options['_conditional']);
314
+ $options['_conditional']['Content-Type'] = 'application/x-www-form-urlencoded';
315
+ }
316
+
317
+ if (isset($options['multipart'])) {
318
+ $options['body'] = new Psr7\MultipartStream($options['multipart']);
319
+ unset($options['multipart']);
320
+ }
321
+
322
+ if (isset($options['json'])) {
323
+ $options['body'] = \GuzzleHttp\json_encode($options['json']);
324
+ unset($options['json']);
325
+ // Ensure that we don't have the header in different case and set the new value.
326
+ $options['_conditional'] = Psr7\_caseless_remove(['Content-Type'], $options['_conditional']);
327
+ $options['_conditional']['Content-Type'] = 'application/json';
328
+ }
329
+
330
+ if (!empty($options['decode_content'])
331
+ && $options['decode_content'] !== true
332
+ ) {
333
+ // Ensure that we don't have the header in different case and set the new value.
334
+ $options['_conditional'] = Psr7\_caseless_remove(['Accept-Encoding'], $options['_conditional']);
335
+ $modify['set_headers']['Accept-Encoding'] = $options['decode_content'];
336
+ }
337
+
338
+ if (isset($options['body'])) {
339
+ if (is_array($options['body'])) {
340
+ $this->invalidBody();
341
+ }
342
+ $modify['body'] = Psr7\stream_for($options['body']);
343
+ unset($options['body']);
344
+ }
345
+
346
+ if (!empty($options['auth']) && is_array($options['auth'])) {
347
+ $value = $options['auth'];
348
+ $type = isset($value[2]) ? strtolower($value[2]) : 'basic';
349
+ switch ($type) {
350
+ case 'basic':
351
+ // Ensure that we don't have the header in different case and set the new value.
352
+ $modify['set_headers'] = Psr7\_caseless_remove(['Authorization'], $modify['set_headers']);
353
+ $modify['set_headers']['Authorization'] = 'Basic '
354
+ . base64_encode("$value[0]:$value[1]");
355
+ break;
356
+ case 'digest':
357
+ // @todo: Do not rely on curl
358
+ $options['curl'][CURLOPT_HTTPAUTH] = CURLAUTH_DIGEST;
359
+ $options['curl'][CURLOPT_USERPWD] = "$value[0]:$value[1]";
360
+ break;
361
+ case 'ntlm':
362
+ $options['curl'][CURLOPT_HTTPAUTH] = CURLAUTH_NTLM;
363
+ $options['curl'][CURLOPT_USERPWD] = "$value[0]:$value[1]";
364
+ break;
365
+ }
366
+ }
367
+
368
+ if (isset($options['query'])) {
369
+ $value = $options['query'];
370
+ if (is_array($value)) {
371
+ $value = http_build_query($value, null, '&', PHP_QUERY_RFC3986);
372
+ }
373
+ if (!is_string($value)) {
374
+ throw new \InvalidArgumentException('query must be a string or array');
375
+ }
376
+ $modify['query'] = $value;
377
+ unset($options['query']);
378
+ }
379
+
380
+ // Ensure that sink is not an invalid value.
381
+ if (isset($options['sink'])) {
382
+ // TODO: Add more sink validation?
383
+ if (is_bool($options['sink'])) {
384
+ throw new \InvalidArgumentException('sink must not be a boolean');
385
+ }
386
+ }
387
+
388
+ $request = Psr7\modify_request($request, $modify);
389
+ if ($request->getBody() instanceof Psr7\MultipartStream) {
390
+ // Use a multipart/form-data POST if a Content-Type is not set.
391
+ // Ensure that we don't have the header in different case and set the new value.
392
+ $options['_conditional'] = Psr7\_caseless_remove(['Content-Type'], $options['_conditional']);
393
+ $options['_conditional']['Content-Type'] = 'multipart/form-data; boundary='
394
+ . $request->getBody()->getBoundary();
395
+ }
396
+
397
+ // Merge in conditional headers if they are not present.
398
+ if (isset($options['_conditional'])) {
399
+ // Build up the changes so it's in a single clone of the message.
400
+ $modify = [];
401
+ foreach ($options['_conditional'] as $k => $v) {
402
+ if (!$request->hasHeader($k)) {
403
+ $modify['set_headers'][$k] = $v;
404
+ }
405
+ }
406
+ $request = Psr7\modify_request($request, $modify);
407
+ // Don't pass this internal value along to middleware/handlers.
408
+ unset($options['_conditional']);
409
+ }
410
+
411
+ return $request;
412
+ }
413
+
414
+ private function invalidBody()
415
+ {
416
+ throw new \InvalidArgumentException('Passing in the "body" request '
417
+ . 'option as an array to send a POST request has been deprecated. '
418
+ . 'Please use the "form_params" request option to send a '
419
+ . 'application/x-www-form-urlencoded request, or the "multipart" '
420
+ . 'request option to send a multipart/form-data request.');
421
+ }
422
+ }
vendor/guzzlehttp/guzzle/src/ClientInterface.php CHANGED
@@ -1,84 +1,84 @@
1
- <?php
2
- namespace GuzzleHttp;
3
-
4
- use GuzzleHttp\Promise\PromiseInterface;
5
- use GuzzleHttp\Exception\GuzzleException;
6
- use Psr\Http\Message\RequestInterface;
7
- use Psr\Http\Message\ResponseInterface;
8
- use Psr\Http\Message\UriInterface;
9
-
10
- /**
11
- * Client interface for sending HTTP requests.
12
- */
13
- interface ClientInterface
14
- {
15
- const VERSION = '6.3.3';
16
-
17
- /**
18
- * Send an HTTP request.
19
- *
20
- * @param RequestInterface $request Request to send
21
- * @param array $options Request options to apply to the given
22
- * request and to the transfer.
23
- *
24
- * @return ResponseInterface
25
- * @throws GuzzleException
26
- */
27
- public function send(RequestInterface $request, array $options = []);
28
-
29
- /**
30
- * Asynchronously send an HTTP request.
31
- *
32
- * @param RequestInterface $request Request to send
33
- * @param array $options Request options to apply to the given
34
- * request and to the transfer.
35
- *
36
- * @return PromiseInterface
37
- */
38
- public function sendAsync(RequestInterface $request, array $options = []);
39
-
40
- /**
41
- * Create and send an HTTP request.
42
- *
43
- * Use an absolute path to override the base path of the client, or a
44
- * relative path to append to the base path of the client. The URL can
45
- * contain the query string as well.
46
- *
47
- * @param string $method HTTP method.
48
- * @param string|UriInterface $uri URI object or string.
49
- * @param array $options Request options to apply.
50
- *
51
- * @return ResponseInterface
52
- * @throws GuzzleException
53
- */
54
- public function request($method, $uri, array $options = []);
55
-
56
- /**
57
- * Create and send an asynchronous HTTP request.
58
- *
59
- * Use an absolute path to override the base path of the client, or a
60
- * relative path to append to the base path of the client. The URL can
61
- * contain the query string as well. Use an array to provide a URL
62
- * template and additional variables to use in the URL template expansion.
63
- *
64
- * @param string $method HTTP method
65
- * @param string|UriInterface $uri URI object or string.
66
- * @param array $options Request options to apply.
67
- *
68
- * @return PromiseInterface
69
- */
70
- public function requestAsync($method, $uri, array $options = []);
71
-
72
- /**
73
- * Get a client configuration option.
74
- *
75
- * These options include default request options of the client, a "handler"
76
- * (if utilized by the concrete client), and a "base_uri" if utilized by
77
- * the concrete client.
78
- *
79
- * @param string|null $option The config option to retrieve.
80
- *
81
- * @return mixed
82
- */
83
- public function getConfig($option = null);
84
- }
1
+ <?php
2
+ namespace GuzzleHttp;
3
+
4
+ use GuzzleHttp\Promise\PromiseInterface;
5
+ use GuzzleHttp\Exception\GuzzleException;
6
+ use Psr\Http\Message\RequestInterface;
7
+ use Psr\Http\Message\ResponseInterface;
8
+ use Psr\Http\Message\UriInterface;
9
+
10
+ /**
11
+ * Client interface for sending HTTP requests.
12
+ */
13
+ interface ClientInterface
14
+ {
15
+ const VERSION = '6.3.3';
16
+
17
+ /**
18
+ * Send an HTTP request.
19
+ *
20
+ * @param RequestInterface $request Request to send
21
+ * @param array $options Request options to apply to the given
22
+ * request and to the transfer.
23
+ *
24
+ * @return ResponseInterface
25
+ * @throws GuzzleException
26
+ */
27
+ public function send(RequestInterface $request, array $options = []);
28
+
29
+ /**
30
+ * Asynchronously send an HTTP request.
31
+ *
32
+ * @param RequestInterface $request Request to send
33
+ * @param array $options Request options to apply to the given
34
+ * request and to the transfer.
35
+ *
36
+ * @return PromiseInterface
37
+ */
38
+ public function sendAsync(RequestInterface $request, array $options = []);
39
+
40
+ /**
41
+ * Create and send an HTTP request.
42
+ *
43
+ * Use an absolute path to override the base path of the client, or a
44
+ * relative path to append to the base path of the client. The URL can
45
+ * contain the query string as well.
46
+ *
47
+ * @param string $method HTTP method.
48
+ * @param string|UriInterface $uri URI object or string.
49
+ * @param array $options Request options to apply.
50
+ *
51
+ * @return ResponseInterface
52
+ * @throws GuzzleException
53
+ */
54
+ public function request($method, $uri, array $options = []);
55
+
56
+ /**
57
+ * Create and send an asynchronous HTTP request.
58
+ *
59
+ * Use an absolute path to override the base path of the client, or a
60
+ * relative path to append to the base path of the client. The URL can
61
+ * contain the query string as well. Use an array to provide a URL
62
+ * template and additional variables to use in the URL template expansion.
63
+ *
64
+ * @param string $method HTTP method
65
+ * @param string|UriInterface $uri URI object or string.
66
+ * @param array $options Request options to apply.
67
+ *
68
+ * @return PromiseInterface
69
+ */
70
+ public function requestAsync($method, $uri, array $options = []);
71
+
72
+ /**
73
+ * Get a client configuration option.
74
+ *
75
+ * These options include default request options of the client, a "handler"
76
+ * (if utilized by the concrete client), and a "base_uri" if utilized by
77
+ * the concrete client.
78
+ *
79
+ * @param string|null $option The config option to retrieve.
80
+ *
81
+ * @return mixed
82
+ */
83
+ public function getConfig($option = null);
84
+ }
vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php CHANGED
@@ -1,314 +1,314 @@
1
- <?php
2
- namespace GuzzleHttp\Cookie;
3
-
4
- use Psr\Http\Message\RequestInterface;
5
- use Psr\Http\Message\ResponseInterface;
6
-
7
- /**
8
- * Cookie jar that stores cookies as an array
9
- */
10
- class CookieJar implements CookieJarInterface
11
- {
12
- /** @var SetCookie[] Loaded cookie data */
13
- private $cookies = [];
14
-
15
- /** @var bool */
16
- private $strictMode;
17
-
18
- /**
19
- * @param bool $strictMode Set to true to throw exceptions when invalid
20
- * cookies are added to the cookie jar.
21
- * @param array $cookieArray Array of SetCookie objects or a hash of
22
- * arrays that can be used with the SetCookie
23
- * 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
- * @deprecated
62
- */
63
- public static function getCookieValue($value)
64
- {
65
- return $value;
66
- }
67
-
68
- /**
69
- * Evaluate if this cookie should be persisted to storage
70
- * that survives between requests.
71
- *
72
- * @param SetCookie $cookie Being evaluated.
73
- * @param bool $allowSessionCookies If we should persist session cookies
74
- * @return bool
75
- */
76
- public static function shouldPersist(
77
- SetCookie $cookie,
78
- $allowSessionCookies = false
79
- ) {
80
- if ($cookie->getExpires() || $allowSessionCookies) {
81
- if (!$cookie->getDiscard()) {
82
- return true;
83
- }
84
- }
85
-
86
- return false;
87
- }
88
-
89
- /**
90
- * Finds and returns the cookie based on the name
91
- *
92
- * @param string $name cookie name to search for
93
- * @return SetCookie|null cookie that was found or null if not found
94
- */
95
- public function getCookieByName($name)
96
- {
97
- // don't allow a null name
98
- if ($name === null) {
99
- return null;
100
- }
101
- foreach ($this->cookies as $cookie) {
102
- if ($cookie->getName() !== null && strcasecmp($cookie->getName(), $name) === 0) {
103
- return $cookie;
104
- }
105
- }
106
- }
107
-
108
- public function toArray()
109
- {
110
- return array_map(function (SetCookie $cookie) {
111
- return $cookie->toArray();
112
- }, $this->getIterator()->getArrayCopy());
113
- }
114
-
115
- public function clear($domain = null, $path = null, $name = null)
116
- {
117
- if (!$domain) {
118
- $this->cookies = [];
119
- return;
120
- } elseif (!$path) {
121
- $this->cookies = array_filter(
122
- $this->cookies,
123
- function (SetCookie $cookie) use ($path, $domain) {
124
- return !$cookie->matchesDomain($domain);
125
- }
126
- );
127
- } elseif (!$name) {
128
- $this->cookies = array_filter(
129
- $this->cookies,
130
- function (SetCookie $cookie) use ($path, $domain) {
131
- return !($cookie->matchesPath($path) &&
132
- $cookie->matchesDomain($domain));
133
- }
134
- );
135
- } else {
136
- $this->cookies = array_filter(
137
- $this->cookies,
138
- function (SetCookie $cookie) use ($path, $domain, $name) {
139
- return !($cookie->getName() == $name &&
140
- $cookie->matchesPath($path) &&
141
- $cookie->matchesDomain($domain));
142
- }
143
- );
144
- }
145
- }
146
-
147
- public function clearSessionCookies()
148
- {
149
- $this->cookies = array_filter(
150
- $this->cookies,
151
- function (SetCookie $cookie) {
152
- return !$cookie->getDiscard() && $cookie->getExpires();
153
- }
154
- );
155
- }
156
-
157
- public function setCookie(SetCookie $cookie)
158
- {
159
- // If the name string is empty (but not 0), ignore the set-cookie
160
- // string entirely.
161
- $name = $cookie->getName();
162
- if (!$name && $name !== '0') {
163
- return false;
164
- }
165
-
166
- // Only allow cookies with set and valid domain, name, value
167
- $result = $cookie->validate();
168
- if ($result !== true) {
169
- if ($this->strictMode) {
170
- throw new \RuntimeException('Invalid cookie: ' . $result);
171
- } else {
172
- $this->removeCookieIfEmpty($cookie);
173
- return false;
174
- }
175
- }
176
-
177
- // Resolve conflicts with previously set cookies
178
- foreach ($this->cookies as $i => $c) {
179
-
180
- // Two cookies are identical, when their path, and domain are
181
- // identical.
182
- if ($c->getPath() != $cookie->getPath() ||
183
- $c->getDomain() != $cookie->getDomain() ||
184
- $c->getName() != $cookie->getName()
185
- ) {
186
- continue;
187
- }
188
-
189
- // The previously set cookie is a discard cookie and this one is
190
- // not so allow the new cookie to be set
191
- if (!$cookie->getDiscard() && $c->getDiscard()) {
192
- unset($this->cookies[$i]);
193
- continue;
194
- }
195
-
196
- // If the new cookie's expiration is further into the future, then
197
- // replace the old cookie
198
- if ($cookie->getExpires() > $c->getExpires()) {
199
- unset($this->cookies[$i]);
200
- continue;
201
- }
202
-
203
- // If the value has changed, we better change it
204
- if ($cookie->getValue() !== $c->getValue()) {
205
- unset($this->cookies[$i]);
206
- continue;
207
- }
208
-
209
- // The cookie exists, so no need to continue
210
- return false;
211
- }
212
-
213
- $this->cookies[] = $cookie;
214
-
215
- return true;
216
- }
217
-
218
- public function count()
219
- {
220
- return count($this->cookies);
221
- }
222
-
223
- public function getIterator()
224
- {
225
- return new \ArrayIterator(array_values($this->cookies));
226
- }
227
-
228
- public function extractCookies(
229
- RequestInterface $request,
230
- ResponseInterface $response
231
- ) {
232
- if ($cookieHeader = $response->getHeader('Set-Cookie')) {
233
- foreach ($cookieHeader as $cookie) {
234
- $sc = SetCookie::fromString($cookie);
235
- if (!$sc->getDomain()) {
236
- $sc->setDomain($request->getUri()->getHost());
237
- }
238
- if (0 !== strpos($sc->getPath(), '/')) {
239
- $sc->setPath($this->getCookiePathFromRequest($request));
240
- }
241
- $this->setCookie($sc);
242
- }
243
- }
244
- }
245
-
246
- /**
247
- * Computes cookie path following RFC 6265 section 5.1.4
248
- *
249
- * @link https://tools.ietf.org/html/rfc6265#section-5.1.4
250
- *
251
- * @param RequestInterface $request
252
- * @return string
253
- */
254
- private function getCookiePathFromRequest(RequestInterface $request)
255
- {
256
- $uriPath = $request->getUri()->getPath();
257
- if ('' === $uriPath) {
258
- return '/';
259
- }
260
- if (0 !== strpos($uriPath, '/')) {
261
- return '/';
262
- }
263
- if ('/' === $uriPath) {
264
- return '/';
265
- }
266
- if (0 === $lastSlashPos = strrpos($uriPath, '/')) {
267
- return '/';
268
- }
269
-
270
- return substr($uriPath, 0, $lastSlashPos);
271
- }
272
-
273
- public function withCookieHeader(RequestInterface $request)
274
- {
275
- $values = [];
276
- $uri = $request->getUri();
277
- $scheme = $uri->getScheme();
278
- $host = $uri->getHost();
279
- $path = $uri->getPath() ?: '/';
280
-
281
- foreach ($this->cookies as $cookie) {
282
- if ($cookie->matchesPath($path) &&
283
- $cookie->matchesDomain($host) &&
284
- !$cookie->isExpired() &&
285
- (!$cookie->getSecure() || $scheme === 'https')
286
- ) {
287
- $values[] = $cookie->getName() . '='
288
- . $cookie->getValue();
289
- }
290
- }
291
-
292
- return $values
293
- ? $request->withHeader('Cookie', implode('; ', $values))
294
- : $request;
295
- }
296
-
297
- /**
298
- * If a cookie already exists and the server asks to set it again with a
299
- * null value, the cookie must be deleted.
300
- *
301
- * @param SetCookie $cookie
302
- */
303
- private function removeCookieIfEmpty(SetCookie $cookie)
304
- {
305
- $cookieValue = $cookie->getValue();
306
- if ($cookieValue === null || $cookieValue === '') {
307
- $this->clear(
308
- $cookie->getDomain(),
309
- $cookie->getPath(),
310
- $cookie->getName()
311
- );
312
- }
313
- }
314
- }
1
+ <?php
2
+ namespace GuzzleHttp\Cookie;
3
+
4
+ use Psr\Http\Message\RequestInterface;
5
+ use Psr\Http\Message\ResponseInterface;
6
+
7
+ /**
8
+ * Cookie jar that stores cookies as an array
9
+ */
10
+ class CookieJar implements CookieJarInterface
11
+ {
12
+ /** @var SetCookie[] Loaded cookie data */
13
+ private $cookies = [];
14
+
15
+ /** @var bool */
16
+ private $strictMode;
17
+
18
+ /**
19
+ * @param bool $strictMode Set to true to throw exceptions when invalid
20
+ * cookies are added to the cookie jar.
21
+ * @param array $cookieArray Array of SetCookie objects or a hash of
22
+ * arrays that can be used with the SetCookie
23
+ * 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
+ * @deprecated
62
+ */
63
+ public static function getCookieValue($value)
64
+ {
65
+ return $value;
66
+ }
67
+
68
+ /**
69
+ * Evaluate if this cookie should be persisted to storage
70
+ * that survives between requests.
71
+ *
72
+ * @param SetCookie $cookie Being evaluated.
73
+ * @param bool $allowSessionCookies If we should persist session cookies
74
+ * @return bool
75
+ */
76
+ public static function shouldPersist(
77
+ SetCookie $cookie,
78
+ $allowSessionCookies = false
79
+ ) {
80
+ if ($cookie->getExpires() || $allowSessionCookies) {
81
+ if (!$cookie->getDiscard()) {
82
+ return true;
83
+ }
84
+ }
85
+
86
+ return false;
87
+ }
88
+
89
+ /**
90
+ * Finds and returns the cookie based on the name
91
+ *
92
+ * @param string $name cookie name to search for
93
+ * @return SetCookie|null cookie that was found or null if not found
94
+ */
95
+ public function getCookieByName($name)
96
+ {
97
+ // don't allow a null name
98
+ if ($name === null) {
99
+ return null;
100
+ }
101
+ foreach ($this->cookies as $cookie) {
102
+ if ($cookie->getName() !== null && strcasecmp($cookie->getName(), $name) === 0) {
103
+ return $cookie;
104
+ }
105
+ }
106
+ }
107
+
108
+ public function toArray()
109
+ {
110
+ return array_map(function (SetCookie $cookie) {
111
+ return $cookie->toArray();
112
+ }, $this->getIterator()->getArrayCopy());
113
+ }
114
+
115
+ public function clear($domain = null, $path = null, $name = null)
116
+ {
117
+ if (!$domain) {
118
+ $this->cookies = [];
119
+ return;
120
+ } elseif (!$path) {
121
+ $this->cookies = array_filter(
122
+ $this->cookies,
123
+ function (SetCookie $cookie) use ($path, $domain) {
124
+ return !$cookie->matchesDomain($domain);
125
+ }
126
+ );
127
+ } elseif (!$name) {
128
+ $this->cookies = array_filter(
129
+ $this->cookies,
130
+ function (SetCookie $cookie) use ($path, $domain) {
131
+ return !($cookie->matchesPath($path) &&
132
+ $cookie->matchesDomain($domain));
133
+ }
134
+ );
135
+ } else {
136
+ $this->cookies = array_filter(
137
+ $this->cookies,
138
+ function (SetCookie $cookie) use ($path, $domain, $name) {
139
+ return !($cookie->getName() == $name &&
140
+ $cookie->matchesPath($path) &&
141
+ $cookie->matchesDomain($domain));
142
+ }
143
+ );
144
+ }
145
+ }
146
+
147
+ public function clearSessionCookies()
148
+ {
149
+ $this->cookies = array_filter(
150
+ $this->cookies,
151
+ function (SetCookie $cookie) {
152
+ return !$cookie->getDiscard() && $cookie->getExpires();
153
+ }
154
+ );
155
+ }
156
+
157
+ public function setCookie(SetCookie $cookie)
158
+ {
159
+ // If the name string is empty (but not 0), ignore the set-cookie
160
+ // string entirely.
161
+ $name = $cookie->getName();
162
+ if (!$name && $name !== '0') {
163
+ return false;
164
+ }
165
+
166
+ // Only allow cookies with set and valid domain, name, value
167
+ $result = $cookie->validate();
168
+ if ($result !== true) {
169
+ if ($this->strictMode) {
170
+ throw new \RuntimeException('Invalid cookie: ' . $result);
171
+ } else {
172
+ $this->removeCookieIfEmpty($cookie);
173
+ return false;
174
+ }
175
+ }
176
+
177
+ // Resolve conflicts with previously set cookies
178
+ foreach ($this->cookies as $i => $c) {
179
+
180
+ // Two cookies are identical, when their path, and domain are
181
+ // identical.
182
+ if ($c->getPath() != $cookie->getPath() ||
183
+ $c->getDomain() != $cookie->getDomain() ||
184
+ $c->getName() != $cookie->getName()
185
+ ) {
186
+ continue;
187
+ }
188
+
189
+ // The previously set cookie is a discard cookie and this one is
190
+ // not so allow the new cookie to be set
191
+ if (!$cookie->getDiscard() && $c->getDiscard()) {
192
+ unset($this->cookies[$i]);
193
+ continue;
194
+ }
195
+
196
+ // If the new cookie's expiration is further into the future, then
197
+ // replace the old cookie
198
+ if ($cookie->getExpires() > $c->getExpires()) {
199
+ unset($this->cookies[$i]);
200
+ continue;
201
+ }
202
+
203
+ // If the value has changed, we better change it
204
+ if ($cookie->getValue() !== $c->getValue()) {
205
+ unset($this->cookies[$i]);
206
+ continue;
207
+ }
208
+
209
+ // The cookie exists, so no need to continue
210
+ return false;
211
+ }
212
+
213
+ $this->cookies[] = $cookie;
214
+
215
+ return true;
216
+ }
217
+
218
+ public function count()
219
+ {
220
+ return count($this->cookies);
221
+ }
222
+
223
+ public function getIterator()
224
+ {
225
+ return new \ArrayIterator(array_values($this->cookies));
226
+ }
227
+
228
+ public function extractCookies(
229
+ RequestInterface $request,
230
+ ResponseInterface $response
231
+ ) {
232
+ if ($cookieHeader = $response->getHeader('Set-Cookie')) {
233
+ foreach ($cookieHeader as $cookie) {
234
+ $sc = SetCookie::fromString($cookie);
235
+ if (!$sc->getDomain()) {
236
+ $sc->setDomain($request->getUri()->getHost());
237
+ }
238
+ if (0 !== strpos($sc->getPath(), '/')) {
239
+ $sc->setPath($this->getCookiePathFromRequest($request));
240
+ }
241
+ $this->setCookie($sc);
242
+ }
243
+ }
244
+ }
245
+
246
+ /**
247
+ * Computes cookie path following RFC 6265 section 5.1.4
248
+ *
249
+ * @link https://tools.ietf.org/html/rfc6265#section-5.1.4
250
+ *
251
+ * @param RequestInterface $request
252
+ * @return string
253
+ */
254
+ private function getCookiePathFromRequest(RequestInterface $request)
255
+ {
256
+ $uriPath = $request->getUri()->getPath();
257
+ if ('' === $uriPath) {
258
+ return '/';
259
+ }
260
+ if (0 !== strpos($uriPath, '/')) {
261
+ return '/';
262
+ }
263
+ if ('/' === $uriPath) {
264
+ return '/';
265
+ }
266
+ if (0 === $lastSlashPos = strrpos($uriPath, '/')) {
267
+ return '/';
268
+ }
269
+
270
+ return substr($uriPath, 0, $lastSlashPos);
271
+ }
272
+
273
+ public function withCookieHeader(RequestInterface $request)
274
+ {
275
+ $values = [];
276
+ $uri = $request->getUri();
277
+ $scheme = $uri->getScheme();
278
+ $host = $uri->getHost();
279
+ $path = $uri->getPath() ?: '/';
280
+
281
+ foreach ($this->cookies as $cookie) {
282
+ if ($cookie->matchesPath($path) &&
283
+ $cookie->matchesDomain($host) &&
284
+ !$cookie->isExpired() &&
285
+ (!$cookie->getSecure() || $scheme === 'https')
286
+ ) {
287
+ $values[] = $cookie->getName() . '='
288
+ . $cookie->getValue();
289
+ }
290
+ }
291
+
292
+ return $values
293
+ ? $request->withHeader('Cookie', implode('; ', $values))
294
+ : $request;
295
+ }
296
+
297
+ /**
298
+ * If a cookie already exists and the server asks to set it again with a
299
+ * null value, the cookie must be deleted.
300
+ *
301
+ * @param SetCookie $cookie
302
+ */
303
+ private function removeCookieIfEmpty(SetCookie $cookie)
304
+ {
305
+ $cookieValue = $cookie->getValue();
306
+ if ($cookieValue === null || $cookieValue === '') {
307
+ $this->clear(
308
+ $cookie->getDomain(),
309
+ $cookie->getPath(),
310
+ $cookie->getName()
311
+ );
312
+ }
313
+ }
314
+ }
vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php CHANGED
@@ -1,84 +1,84 @@
1
- <?php
2
- namespace GuzzleHttp\Cookie;
3
-
4
- use Psr\Http\Message\RequestInterface;
5
- use Psr\Http\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
- * Create a request with added cookie headers.
21
- *
22
- * If no matching cookies are found in the cookie jar, then no Cookie
23
- * header is added to the request and the same request is returned.
24
- *
25
- * @param RequestInterface $request Request object to modify.
26
- *
27
- * @return RequestInterface returns the modified request.
28
- */
29
- public function withCookieHeader(RequestInterface $request);
30
-
31
- /**
32
- * Extract cookies from an HTTP response and store them in the CookieJar.
33
- *
34
- * @param RequestInterface $request Request that was sent
35
- * @param ResponseInterface $response Response that was received
36
- */
37
- public function extractCookies(
38
- RequestInterface $request,
39
- ResponseInterface $response
40
- );
41
-
42
- /**
43
- * Sets a cookie in the cookie jar.
44
- *
45
- * @param SetCookie $cookie Cookie to set.
46
- *
47
- * @return bool Returns true on success or false on failure
48
- */
49
- public function setCookie(SetCookie $cookie);
50
-
51
- /**
52
- * Remove cookies currently held in the cookie jar.
53
- *
54
- * Invoking this method without arguments will empty the whole cookie jar.
55
- * If given a $domain argument only cookies belonging to that domain will
56
- * be removed. If given a $domain and $path argument, cookies belonging to
57
- * the specified path within that domain are removed. If given all three
58
- * arguments, then the cookie with the specified name, path and domain is
59
- * removed.
60
- *
61
- * @param string $domain Clears cookies matching a domain
62
- * @param string $path Clears cookies matching a domain and path
63
- * @param string $name Clears cookies matching a domain, path, and name
64
- *
65
- * @return CookieJarInterface
66
- */
67
- public function clear($domain = null, $path = null, $name = null);
68
-
69
- /**
70
- * Discard all sessions cookies.
71
- *
72
- * Removes cookies that don't have an expire field or a have a discard
73
- * field set to true. To be called when the user agent shuts down according
74
- * to RFC 2965.
75
- */
76
- public function clearSessionCookies();
77
-
78
- /**
79
- * Converts the cookie jar to an array.
80
- *
81
- * @return array
82
- */
83
- public function toArray();
84
- }
1
+ <?php
2
+ namespace GuzzleHttp\Cookie;
3
+
4
+ use Psr\Http\Message\RequestInterface;
5
+ use Psr\Http\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
+ * Create a request with added cookie headers.
21
+ *
22
+ * If no matching cookies are found in the cookie jar, then no Cookie
23
+ * header is added to the request and the same request is returned.
24
+ *
25
+ * @param RequestInterface $request Request object to modify.
26
+ *
27
+ * @return RequestInterface returns the modified request.
28
+ */
29
+ public function withCookieHeader(RequestInterface $request);
30
+
31
+ /**
32
+ * Extract cookies from an HTTP response and store them in the CookieJar.
33
+ *
34
+ * @param RequestInterface $request Request that was sent
35
+ * @param ResponseInterface $response Response that was received
36
+ */
37
+ public function extractCookies(
38
+ RequestInterface $request,
39
+ ResponseInterface $response
40
+ );
41
+
42
+ /**
43
+ * Sets a cookie in the cookie jar.
44
+ *
45
+ * @param SetCookie $cookie Cookie to set.
46
+ *
47
+ * @return bool Returns true on success or false on failure
48
+ */
49
+ public function setCookie(SetCookie $cookie);
50
+
51
+ /**
52
+ * Remove cookies currently held in the cookie jar.
53
+ *
54
+ * Invoking this method without arguments will empty the whole cookie jar.
55
+ * If given a $domain argument only cookies belonging to that domain will
56
+ * be removed. If given a $domain and $path argument, cookies belonging to
57
+ * the specified path within that domain are removed. If given all three
58
+ * arguments, then the cookie with the specified name, path and domain is
59
+ * removed.
60
+ *
61
+ * @param string $domain Clears cookies matching a domain
62
+ * @param string $path Clears cookies matching a domain and path
63
+ * @param string $name Clears cookies matching a domain, path, and name
64
+ *
65
+ * @return CookieJarInterface
66
+ */
67
+ public function clear($domain = null, $path = null, $name = null);
68
+
69
+ /**
70
+ * Discard all sessions cookies.
71
+ *
72
+ * Removes cookies that don't have an expire field or a have a discard
73
+ * field set to true. To be called when the user agent shuts down according
74
+ * to RFC 2965.
75
+ */
76
+ public function clearSessionCookies();
77
+
78
+ /**
79
+ * Converts the cookie jar to an array.
80
+ *
81
+ * @return array
82
+ */
83
+ public function toArray();
84
+ }
vendor/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php CHANGED
@@ -1,90 +1,90 @@
1
- <?php
2
- namespace GuzzleHttp\Cookie;
3
-
4
- /**
5
- * Persists non-session cookies using a JSON formatted file
6
- */
7
- class FileCookieJar extends CookieJar
8
- {
9
- /** @var string filename */
10
- private $filename;
11
-
12
- /** @var bool Control whether to persist session cookies or not. */
13
- private $storeSessionCookies;
14
-
15
- /**
16
- * Create a new FileCookieJar object
17
- *
18
- * @param string $cookieFile File to store the cookie data
19
- * @param bool $storeSessionCookies Set to true to store session cookies
20
- * in the cookie jar.
21
- *
22
- * @throws \RuntimeException if the file cannot be found or created
23
- */
24
- public function __construct($cookieFile, $storeSessionCookies = false)
25
- {
26
- $this->filename = $cookieFile;
27
- $this->storeSessionCookies = $storeSessionCookies;
28
-
29
- if (file_exists($cookieFile)) {
30
- $this->load($cookieFile);
31
- }
32
- }
33
-
34
- /**
35
- * Saves the file when shutting down
36
- */
37
- public function __destruct()
38
- {
39
- $this->save($this->filename);
40
- }
41
-
42
- /**
43
- * Saves the cookies to a file.
44
- *
45
- * @param string $filename File to save
46
- * @throws \RuntimeException if the file cannot be found or created
47
- */
48
- public function save($filename)
49
- {
50
- $json = [];
51
- foreach ($this as $cookie) {
52
- /** @var SetCookie $cookie */
53
- if (CookieJar::shouldPersist($cookie, $this->storeSessionCookies)) {
54
- $json[] = $cookie->toArray();
55
- }
56
- }
57
-
58
- $jsonStr = \GuzzleHttp\json_encode($json);
59
- if (false === file_put_contents($filename, $jsonStr)) {
60
- throw new \RuntimeException("Unable to save file {$filename}");
61
- }
62
- }
63
-
64
- /**
65
- * Load cookies from a JSON formatted file.
66
- *
67
- * Old cookies are kept unless overwritten by newly loaded ones.
68
- *
69
- * @param string $filename Cookie file to load.
70
- * @throws \RuntimeException if the file cannot be loaded.
71
- */
72
- public function load($filename)
73
- {
74
- $json = file_get_contents($filename);
75
- if (false === $json) {
76
- throw new \RuntimeException("Unable to load file {$filename}");
77
- } elseif ($json === '') {
78
- return;
79
- }
80
-
81
- $data = \GuzzleHttp\json_decode($json, true);
82
- if (is_array($data)) {
83
- foreach (json_decode($json, true) as $cookie) {
84
- $this->setCookie(new SetCookie($cookie));
85
- }
86
- } elseif (strlen($data)) {
87
- throw new \RuntimeException("Invalid cookie file: {$filename}");
88
- }
89
- }
90
- }
1
+ <?php
2
+ namespace GuzzleHttp\Cookie;
3
+
4
+ /**
5
+ * Persists non-session cookies using a JSON formatted file
6
+ */
7
+ class FileCookieJar extends CookieJar
8
+ {
9
+ /** @var string filename */
10
+ private $filename;
11
+
12
+ /** @var bool Control whether to persist session cookies or not. */
13
+ private $storeSessionCookies;
14
+
15
+ /**
16
+ * Create a new FileCookieJar object
17
+ *
18
+ * @param string $cookieFile File to store the cookie data
19
+ * @param bool $storeSessionCookies Set to true to store session cookies
20
+ * in the cookie jar.
21
+ *
22
+ * @throws \RuntimeException if the file cannot be found or created
23
+ */
24
+ public function __construct($cookieFile, $storeSessionCookies = false)
25
+ {
26
+ $this->filename = $cookieFile;
27
+ $this->storeSessionCookies = $storeSessionCookies;
28
+
29
+ if (file_exists($cookieFile)) {
30
+ $this->load($cookieFile);
31
+ }
32
+ }
33
+
34
+ /**
35
+ * Saves the file when shutting down
36
+ */
37
+ public function __destruct()
38
+ {
39
+ $this->save($this->filename);
40
+ }
41
+
42
+ /**
43
+ * Saves the cookies to a file.
44
+ *
45
+ * @param string $filename File to save
46
+ * @throws \RuntimeException if the file cannot be found or created
47
+ */
48
+ public function save($filename)
49
+ {
50
+ $json = [];
51
+ foreach ($this as $cookie) {
52
+ /** @var SetCookie $cookie */
53
+ if (CookieJar::shouldPersist($cookie, $this->storeSessionCookies)) {
54
+ $json[] = $cookie->toArray();
55
+ }
56
+ }
57
+
58
+ $jsonStr = \GuzzleHttp\json_encode($json);
59
+ if (false === file_put_contents($filename, $jsonStr)) {
60
+ throw new \RuntimeException("Unable to save file {$filename}");
61
+ }
62
+ }
63
+
64
+ /**
65
+ * Load cookies from a JSON formatted file.
66
+ *
67
+ * Old cookies are kept unless overwritten by newly loaded ones.
68
+ *
69
+ * @param string $filename Cookie file to load.
70
+ * @throws \RuntimeException if the file cannot be loaded.
71
+ */
72
+ public function load($filename)
73
+ {
74
+ $json = file_get_contents($filename);
75
+ if (false === $json) {
76
+ throw new \RuntimeException("Unable to load file {$filename}");
77
+ } elseif ($json === '') {
78
+ return;
79
+ }
80
+
81
+ $data = \GuzzleHttp\json_decode($json, true);
82
+ if (is_array($data)) {
83
+ foreach (json_decode($json, true) as $cookie) {
84
+ $this->setCookie(new SetCookie($cookie));
85
+ }
86
+ } elseif (strlen($data)) {
87
+ throw new \RuntimeException("Invalid cookie file: {$filename}");
88
+ }
89
+ }
90
+ }
vendor/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php CHANGED
@@ -1,71 +1,71 @@
1
- <?php
2
- namespace GuzzleHttp\Cookie;
3
-
4
- /**
5
- * Persists cookies in the client session
6
- */
7
- class SessionCookieJar extends CookieJar
8
- {
9
- /** @var string session key */
10
- private $sessionKey;
11
-
12
- /** @var bool Control whether to persist session cookies or not. */
13
- private $storeSessionCookies;
14
-
15
- /**
16
- * Create a new SessionCookieJar object
17
- *
18
- * @param string $sessionKey Session key name to store the cookie
19
- * data in session
20
- * @param bool $storeSessionCookies Set to true to store session cookies
21
- * in the cookie jar.
22
- */
23
- public function __construct($sessionKey, $storeSessionCookies = false)
24
- {
25
- $this->sessionKey = $sessionKey;
26
- $this->storeSessionCookies = $storeSessionCookies;
27
- $this->load();
28
- }
29
-
30
- /**
31
- * Saves cookies to session when shutting down
32
- */
33
- public function __destruct()
34
- {
35
- $this->save();
36
- }
37
-
38
- /**
39
- * Save cookies to the client session
40
- */
41
- public function save()
42
- {
43
- $json = [];
44
- foreach ($this as $cookie) {
45
- /** @var SetCookie $cookie */
46
- if (CookieJar::shouldPersist($cookie, $this->storeSessionCookies)) {
47
- $json[] = $cookie->toArray();
48
- }
49
- }
50
-
51
- $_SESSION[$this->sessionKey] = json_encode($json);
52
- }
53
-
54
- /**
55
- * Load the contents of the client session into the data array
56
- */
57
- protected function load()
58
- {
59
- if (!isset($_SESSION[$this->sessionKey])) {
60
- return;
61
- }
62
- $data = json_decode($_SESSION[$this->sessionKey], true);
63
- if (is_array($data)) {
64
- foreach ($data as $cookie) {
65
- $this->setCookie(new SetCookie($cookie));
66
- }
67
- } elseif (strlen($data)) {
68
- throw new \RuntimeException("Invalid cookie data");
69
- }
70
- }
71
- }
1
+ <?php
2
+ namespace GuzzleHttp\Cookie;
3
+
4
+ /**
5
+ * Persists cookies in the client session
6
+ */
7
+ class SessionCookieJar extends CookieJar
8
+ {
9
+ /** @var string session key */
10
+ private $sessionKey;
11
+
12
+ /** @var bool Control whether to persist session cookies or not. */
13
+ private $storeSessionCookies;
14
+
15
+ /**
16
+ * Create a new SessionCookieJar object
17
+ *
18
+ * @param string $sessionKey Session key name to store the cookie
19
+ * data in session
20
+ * @param bool $storeSessionCookies Set to true to store session cookies
21
+ * in the cookie jar.
22
+ */
23
+ public function __construct($sessionKey, $storeSessionCookies = false)
24
+ {
25
+ $this->sessionKey = $sessionKey;
26
+ $this->storeSessionCookies = $storeSessionCookies;
27
+ $this->load();
28
+ }
29
+
30
+ /**
31
+ * Saves cookies to session when shutting down
32
+ */
33
+ public function __destruct()
34
+ {
35
+ $this->save();
36
+ }
37
+
38
+ /**
39
+ * Save cookies to the client session
40
+ */
41
+ public function save()
42
+ {
43
+ $json = [];
44
+ foreach ($this as $cookie) {
45
+ /** @var SetCookie $cookie */
46
+ if (CookieJar::shouldPersist($cookie, $this->storeSessionCookies)) {
47
+ $json[] = $cookie->toArray();
48
+ }
49
+ }
50
+
51
+ $_SESSION[$this->sessionKey] = json_encode($json);
52
+ }
53
+
54
+ /**
55
+ * Load the contents of the client session into the data array
56
+ */
57
+ protected function load()
58
+ {
59
+ if (!isset($_SESSION[$this->sessionKey])) {
60
+ return;
61
+ }
62
+ $data = json_decode($_SESSION[$this->sessionKey], true);
63
+ if (is_array($data)) {
64
+ foreach ($data as $cookie) {
65
+ $this->setCookie(new SetCookie($cookie));
66
+ }
67
+ } elseif (strlen($data)) {
68
+ throw new \RuntimeException("Invalid cookie data");
69
+ }
70
+ }
71
+ }
vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php CHANGED
@@ -1,403 +1,403 @@
1
- <?php
2
- namespace GuzzleHttp\Cookie;
3
-
4
- /**
5
- * Set-Cookie object
6
- */
7
- class SetCookie
8
- {
9
- /** @var array */
10
- private static $defaults = [
11
- 'Name' => null,
12
- 'Value' => null,
13
- 'Domain' => null,
14
- 'Path' => '/',
15
- 'Max-Age' => null,
16
- 'Expires' => null,
17
- 'Secure' => false,
18
- 'Discard' => false,
19
- 'HttpOnly' => false
20
- ];
21
-
22
- /** @var array Cookie data */
23
- private $data;
24
-
25
- /**
26
- * Create a new SetCookie object from a string
27
- *
28
- * @param string $cookie Set-Cookie header string
29
- *
30
- * @return self
31
- */
32
- public static function fromString($cookie)
33
- {
34
- // Create the default return array
35
- $data = self::$defaults;
36
- // Explode the cookie string using a series of semicolons
37
- $pieces = array_filter(array_map('trim', explode(';', $cookie)));
38
- // The name of the cookie (first kvp) must exist and include an equal sign.
39
- if (empty($pieces[0]) || !strpos($pieces[0], '=')) {
40
- return new self($data);
41
- }
42
-
43
- // Add the cookie pieces into the parsed data array
44
- foreach ($pieces as $part) {
45
- $cookieParts = explode('=', $part, 2);
46
- $key = trim($cookieParts[0]);
47
- $value = isset($cookieParts[1])
48
- ? trim($cookieParts[1], " \n\r\t\0\x0B")
49
- : true;
50
-
51
- // Only check for non-cookies when cookies have been found
52
- if (empty($data['Name'])) {
53
- $data['Name'] = $key;
54
- $data['Value'] = $value;
55
- } else {
56
- foreach (array_keys(self::$defaults) as $search) {
57
- if (!strcasecmp($search, $key)) {
58
- $data[$search] = $value;
59
- continue 2;
60
- }
61
- }
62
- $data[$key] = $value;
63
- }
64
- }
65
-
66
- return new self($data);
67
- }
68
-
69
- /**
70
- * @param array $data Array of cookie data provided by a Cookie parser
71
- */
72
- public function __construct(array $data = [])
73
- {
74
- $this->data = array_replace(self::$defaults, $data);
75
- // Extract the Expires value and turn it into a UNIX timestamp if needed
76
- if (!$this->getExpires() && $this->getMaxAge()) {
77
- // Calculate the Expires date
78
- $this->setExpires(time() + $this->getMaxAge());
79
- } elseif ($this->getExpires() && !is_numeric($this->getExpires())) {
80
- $this->setExpires($this->getExpires());
81
- }
82
- }
83
-
84
- public function __toString()
85
- {
86
- $str = $this->data['Name'] . '=' . $this->data['Value'] . '; ';
87
- foreach ($this->data as $k => $v) {
88
- if ($k !== 'Name' && $k !== 'Value' && $v !== null && $v !== false) {
89
- if ($k === 'Expires') {
90
- $str .= 'Expires=' . gmdate('D, d M Y H:i:s \G\M\T', $v) . '; ';
91
- } else {
92
- $str .= ($v === true ? $k : "{$k}={$v}") . '; ';
93
- }
94
- }
95
- }
96
-
97
- return rtrim($str, '; ');
98
- }
99
-
100
- public function toArray()
101
- {
102
- return $this->data;
103
- }
104
-
105
- /**
106
- * Get the cookie name
107
- *
108
- * @return string
109
- */
110
- public function getName()
111
- {
112
- return $this->data['Name'];
113
- }
114
-
115
- /**
116
- * Set the cookie name
117
- *
118
- * @param string $name Cookie name
119
- */
120
- public function setName($name)
121
- {
122
- $this->data['Name'] = $name;
123
- }
124
-
125
- /**
126
- * Get the cookie value
127
- *
128
- * @return string
129
- */
130
- public function getValue()
131
- {
132
- return $this->data['Value'];
133
- }
134
-
135
- /**
136
- * Set the cookie value
137
- *
138
- * @param string $value Cookie value
139
- */
140
- public function setValue($value)
141
- {
142
- $this->data['Value'] = $value;
143
- }
144
-
145
- /**
146
- * Get the domain
147
- *
148
- * @return string|null
149
- */
150
- public function getDomain()
151
- {
152
- return $this->data['Domain'];
153
- }
154
-
155
- /**
156
- * Set the domain of the cookie
157
- *
158
- * @param string $domain
159
- */
160
- public function setDomain($domain)
161
- {
162
- $this->data['Domain'] = $domain;
163
- }
164
-
165
- /**
166
- * Get the path
167
- *
168
- * @return string
169
- */
170
- public function getPath()
171
- {
172
- return $this->data['Path'];
173
- }
174
-
175
- /**
176
- * Set the path of the cookie
177
- *
178
- * @param string $path Path of the cookie
179
- */
180
- public function setPath($path)
181
- {
182
- $this->data['Path'] = $path;
183
- }
184
-
185
- /**
186
- * Maximum lifetime of the cookie in seconds
187
- *
188
- * @return int|null
189
- */
190
- public function getMaxAge()
191
- {
192
- return $this->data['Max-Age'];
193
- }
194
-
195
- /**
196
- * Set the max-age of the cookie
197
- *
198
- * @param int $maxAge Max age of the cookie in seconds
199
- */
200
- public function setMaxAge($maxAge)
201
- {
202
- $this->data['Max-Age'] = $maxAge;
203
- }
204
-
205
- /**
206
- * The UNIX timestamp when the cookie Expires
207
- *
208
- * @return mixed
209
- */
210
- public function getExpires()
211
- {
212
- return $this->data['Expires'];
213
- }
214
-
215
- /**
216
- * Set the unix timestamp for which the cookie will expire
217
- *
218
- * @param int $timestamp Unix timestamp
219
- */
220
- public function setExpires($timestamp)
221
- {
222
- $this->data['Expires'] = is_numeric($timestamp)
223
- ? (int) $timestamp
224
- : strtotime($timestamp);
225
- }
226
-
227
- /**
228
- * Get whether or not this is a secure cookie
229
- *
230
- * @return null|bool
231
- */
232
- public function getSecure()
233
- {
234
- return $this->data['Secure'];
235
- }
236
-
237
- /**
238
- * Set whether or not the cookie is secure
239
- *
240
- * @param bool $secure Set to true or false if secure
241
- */
242
- public function setSecure($secure)
243
- {
244
- $this->data['Secure'] = $secure;
245
- }
246
-
247
- /**
248
- * Get whether or not this is a session cookie
249
- *
250
- * @return null|bool
251
- */
252
- public function getDiscard()
253
- {
254
- return $this->data['Discard'];
255
- }
256
-
257
- /**
258
- * Set whether or not this is a session cookie
259
- *
260
- * @param bool $discard Set to true or false if this is a session cookie
261
- */
262
- public function setDiscard($discard)
263
- {
264
- $this->data['Discard'] = $discard;
265
- }
266
-
267
- /**
268
- * Get whether or not this is an HTTP only cookie
269
- *
270
- * @return bool
271
- */
272
- public function getHttpOnly()
273
- {
274
- return $this->data['HttpOnly'];
275
- }
276
-
277
- /**
278
- * Set whether or not this is an HTTP only cookie
279
- *
280
- * @param bool $httpOnly Set to true or false if this is HTTP only
281
- */
282
- public function setHttpOnly($httpOnly)
283
- {
284
- $this->data['HttpOnly'] = $httpOnly;
285
- }
286
-
287
- /**
288
- * Check if the cookie matches a path value.
289
- *
290