Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
c9dff530
Commit
c9dff530
authored
Jul 16, 2014
by
Klimov Paul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Redundant `yii\authclient\OpenId::sendStreamRequest()` removed.
parent
78daea1b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
109 deletions
+3
-109
OpenId.php
extensions/authclient/OpenId.php
+3
-109
No files found.
extensions/authclient/OpenId.php
View file @
c9dff530
...
@@ -229,14 +229,14 @@ class OpenId extends BaseClient implements ClientInterface
...
@@ -229,14 +229,14 @@ class OpenId extends BaseClient implements ClientInterface
}
}
/**
/**
* Sends
HTTP request.
* Sends
request to the server
* @param string $url request URL.
* @param string $url request URL.
* @param string $method request method.
* @param string $method request method.
* @param array $params request params.
* @param array $params request param
eter
s.
* @return array|string response.
* @return array|string response.
* @throws \yii\base\Exception on failure.
* @throws \yii\base\Exception on failure.
*/
*/
protected
function
send
Curl
Request
(
$url
,
$method
=
'GET'
,
$params
=
[])
protected
function
sendRequest
(
$url
,
$method
=
'GET'
,
$params
=
[])
{
{
$params
=
http_build_query
(
$params
,
''
,
'&'
);
$params
=
http_build_query
(
$params
,
''
,
'&'
);
$curl
=
curl_init
(
$url
.
(
$method
==
'GET'
&&
$params
?
'?'
.
$params
:
''
));
$curl
=
curl_init
(
$url
.
(
$method
==
'GET'
&&
$params
?
'?'
.
$params
:
''
));
...
@@ -286,112 +286,6 @@ class OpenId extends BaseClient implements ClientInterface
...
@@ -286,112 +286,6 @@ class OpenId extends BaseClient implements ClientInterface
}
}
/**
/**
* Sends HTTP request.
* @param string $url request URL.
* @param string $method request method.
* @param array $params request params.
* @return array|string response.
* @throws \yii\base\Exception on failure.
* @throws \yii\base\NotSupportedException if request method is not supported.
*/
protected
function
sendStreamRequest
(
$url
,
$method
=
'GET'
,
$params
=
[])
{
if
(
!
$this
->
hostExists
(
$url
))
{
throw
new
Exception
(
'Invalid request.'
);
}
$params
=
http_build_query
(
$params
,
''
,
'&'
);
switch
(
$method
)
{
case
'GET'
:
$options
=
[
'http'
=>
[
'method'
=>
'GET'
,
'header'
=>
'Accept: application/xrds+xml, */*'
,
'ignore_errors'
=>
true
,
]
];
$url
=
$url
.
(
$params
?
'?'
.
$params
:
''
);
break
;
case
'POST'
:
$options
=
[
'http'
=>
[
'method'
=>
'POST'
,
'header'
=>
'Content-type: application/x-www-form-urlencoded'
,
'content'
=>
$params
,
'ignore_errors'
=>
true
,
]
];
break
;
case
'HEAD'
:
/* We want to send a HEAD request,
but since get_headers doesn't accept $context parameter,
we have to change the defaults.*/
$default
=
stream_context_get_options
(
stream_context_get_default
());
stream_context_get_default
([
'http'
=>
[
'method'
=>
'HEAD'
,
'header'
=>
'Accept: application/xrds+xml, */*'
,
'ignore_errors'
=>
true
,
]
]);
$url
=
$url
.
(
$params
?
'?'
.
$params
:
''
);
$headersTmp
=
get_headers
(
$url
);
if
(
empty
(
$headersTmp
))
{
return
[];
}
// Parsing headers.
$headers
=
[];
foreach
(
$headersTmp
as
$header
)
{
$pos
=
strpos
(
$header
,
':'
);
$name
=
strtolower
(
trim
(
substr
(
$header
,
0
,
$pos
)));
$headers
[
$name
]
=
trim
(
substr
(
$header
,
$pos
+
1
));
}
// and restore them
stream_context_get_default
(
$default
);
return
$headers
;
default
:
throw
new
NotSupportedException
(
"Method
{
$method
}
not supported"
);
}
if
(
$this
->
verifyPeer
)
{
$options
=
array_merge
(
$options
,
[
'ssl'
=>
[
'verify_peer'
=>
true
,
'capath'
=>
$this
->
capath
,
'cafile'
=>
$this
->
cainfo
,
]
]
);
}
$context
=
stream_context_create
(
$options
);
return
file_get_contents
(
$url
,
false
,
$context
);
}
/**
* Sends request to the server
* @param string $url request URL.
* @param string $method request method.
* @param array $params request parameters.
* @return array|string response.
*/
protected
function
sendRequest
(
$url
,
$method
=
'GET'
,
$params
=
[])
{
if
(
function_exists
(
'curl_init'
)
&&
!
ini_get
(
'safe_mode'
))
{
return
$this
->
sendCurlRequest
(
$url
,
$method
,
$params
);
}
return
$this
->
sendStreamRequest
(
$url
,
$method
,
$params
);
}
/**
* Combines given URLs into single one.
* Combines given URLs into single one.
* @param string $baseUrl base URL.
* @param string $baseUrl base URL.
* @param string|array $additionalUrl additional URL string or information array.
* @param string|array $additionalUrl additional URL string or information array.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment