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
574c0103
Commit
574c0103
authored
Dec 20, 2017
by
Markus Kalkbrenner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revert #484
parent
aebed2ab
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
22 deletions
+9
-22
library/Solarium/Core/Client/Adapter/Http.php
library/Solarium/Core/Client/Adapter/Http.php
+2
-14
library/Solarium/QueryType/Extract/RequestBuilder.php
library/Solarium/QueryType/Extract/RequestBuilder.php
+1
-0
tests/Solarium/Tests/Core/Client/Adapter/HttpTest.php
tests/Solarium/Tests/Core/Client/Adapter/HttpTest.php
+3
-7
tests/Solarium/Tests/QueryType/Extract/RequestBuilderTest.php
...s/Solarium/Tests/QueryType/Extract/RequestBuilderTest.php
+3
-1
No files found.
library/Solarium/Core/Client/Adapter/Http.php
View file @
574c0103
...
...
@@ -111,25 +111,13 @@ class Http extends Configurable implements AdapterInterface
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
$request
->
addHeader
(
"Content-Type: multipart/form-data; boundary=
{
$boundary
}
"
);
$data
=
"--
{
$boundary
}
"
.
$CRLF
;
$data
.=
'Content-Disposition: form-data; name="upload"; filename='
.
$filename
.
$CRLF
;
$data
.=
'Content-Type: application/octet-stream'
.
$CRLF
.
$CRLF
;
$data
.=
file_get_contents
(
$request
->
getFileUpload
())
.
$CRLF
;
$data
.=
'--'
.
$boundary
.
'--'
;
$content_length
=
strlen
(
$data
);
$request
->
addHeader
(
"Content-Length:
$content_length
\r\n
"
);
stream_context_set_option
(
$context
,
'http'
,
'content'
,
$data
file_get_contents
(
$request
->
getFileUpload
())
);
$request
->
addHeader
(
'Content-Type: multipart/form-data'
);
}
else
{
$data
=
$request
->
getRawData
();
if
(
null
!==
$data
)
{
...
...
library/Solarium/QueryType/Extract/RequestBuilder.php
View file @
574c0103
...
...
@@ -107,6 +107,7 @@ class RequestBuilder extends BaseRequestBuilder
}
elseif
(
is_readable
(
$file
))
{
$request
->
setFileUpload
(
$file
);
$request
->
addParam
(
'resource.name'
,
basename
(
$query
->
getFile
()));
$request
->
addHeader
(
'Content-Type: multipart/form-data'
);
}
else
{
throw
new
RuntimeException
(
'Extract query file path/url invalid or not available'
);
}
...
...
tests/Solarium/Tests/Core/Client/Adapter/HttpTest.php
View file @
574c0103
...
...
@@ -184,20 +184,16 @@ class HttpTest extends \PHPUnit_Framework_TestCase
$context
=
$this
->
adapter
->
createContext
(
$request
,
$endpoint
);
// Remove content from comparison, since we can't determine the
// random boundary string.
$stream_context_get_options
=
stream_context_get_options
(
$context
);
unset
(
$stream_context_get_options
[
'http'
][
'content'
]);
unset
(
$stream_context_get_options
[
'http'
][
'header'
]);
$this
->
assertEquals
(
array
(
'http'
=>
array
(
'method'
=>
$method
,
'timeout'
=>
$timeout
,
'content'
=>
file_get_contents
(
__FILE__
),
'header'
=>
'Content-Type: multipart/form-data'
,
)
),
$stream_context_get_options
stream_context_get_options
(
$context
)
);
}
...
...
tests/Solarium/Tests/QueryType/Extract/RequestBuilderTest.php
View file @
574c0103
...
...
@@ -134,7 +134,9 @@ class RequestBuilderTest extends \PHPUnit_Framework_TestCase
public
function
testContentTypeHeader
()
{
$headers
=
array
();
$headers
=
array
(
'Content-Type: multipart/form-data'
);
$request
=
$this
->
builder
->
build
(
$this
->
query
);
$this
->
assertEquals
(
$headers
,
$request
->
getHeaders
());
...
...
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