Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
solarium
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
solarium
Commits
0f9daaa6
Commit
0f9daaa6
authored
Aug 10, 2017
by
Alejandro Garza
Committed by
thePanz
Jan 19, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes bugs from PR 484; fix Http adapter for extraction requests
parent
3363bfe1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
10 deletions
+15
-10
CHANGELOG.md
CHANGELOG.md
+1
-0
library/Solarium/Core/Client/Adapter/Http.php
library/Solarium/Core/Client/Adapter/Http.php
+14
-10
No files found.
CHANGELOG.md
View file @
0f9daaa6
...
...
@@ -2,6 +2,7 @@
## 3.x - Unreleased
-
(backport) Fixes bugs from PR #484: fix Http adapter for extraction requests (PR #519)
-
Updated PHP annotations and docblock (PR #526)
-
Performance updates for formatting values (PR #485)
-
Provide fluent interface (PR #483)
...
...
library/Solarium/Core/Client/Adapter/Http.php
View file @
0f9daaa6
...
...
@@ -101,26 +101,30 @@ class Http extends Configurable implements AdapterInterface
public
function
createContext
(
$request
,
$endpoint
)
{
$method
=
$request
->
getMethod
();
$context
=
stream_context_create
(
array
(
'http'
=>
array
(
$context
=
stream_context_create
(
array
(
'http'
=>
array
(
'method'
=>
$method
,
'timeout'
=>
$endpoint
->
getTimeout
(),
),
)
);
));
if
(
$method
==
Request
::
METHOD_POST
)
{
if
(
$request
->
getFileUpload
())
{
$boundary
=
'----------'
.
md5
(
time
());
$CRLF
=
"
\r\n
"
;
$file
=
$request
->
getFileUpload
();
$filename
=
basename
(
$file
);
// Add the proper boundary to the Content-Type header
$headers
=
$request
->
getHeaders
();
// Remove the Content-Type header, because we will replace it with something else.
if
((
$key
=
array_search
(
"Content-Type: multipart/form-data"
,
$headers
))
!==
false
)
{
unset
(
$headers
[
$key
]);
}
$request
->
setHeaders
(
$headers
);
$request
->
addHeader
(
"Content-Type: multipart/form-data; boundary=
{
$boundary
}
"
);
$data
=
"--
{
$boundary
}
"
.
$CRLF
;
$data
.=
'Content-Disposition: form-data; name="upload"; filename='
.
$file
name
.
$CRLF
;
$data
.=
'Content-Disposition: form-data; name="upload"; filename='
.
$file
.
$CRLF
;
$data
.=
'Content-Type: application/octet-stream'
.
$CRLF
.
$CRLF
;
$data
.=
file_get_contents
(
$
request
->
getFileUpload
()
)
.
$CRLF
;
$data
.=
file_get_contents
(
$
file
)
.
$CRLF
;
$data
.=
'--'
.
$boundary
.
'--'
;
$content_length
=
strlen
(
$data
);
$request
->
addHeader
(
"Content-Length:
$content_length
\r\n
"
);
...
...
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