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
b2faf8c8
Commit
b2faf8c8
authored
Feb 15, 2017
by
Alejandro Garza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Basing off pull request 413, fixing tests
parent
aa463671
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
9 deletions
+22
-9
library/Solarium/Core/Client/Adapter/Http.php
library/Solarium/Core/Client/Adapter/Http.php
+14
-2
library/Solarium/QueryType/Extract/RequestBuilder.php
library/Solarium/QueryType/Extract/RequestBuilder.php
+0
-1
tests/Solarium/Tests/Core/Client/Adapter/HttpTest.php
tests/Solarium/Tests/Core/Client/Adapter/HttpTest.php
+7
-3
tests/Solarium/Tests/QueryType/Extract/RequestBuilderTest.php
...s/Solarium/Tests/QueryType/Extract/RequestBuilderTest.php
+1
-3
No files found.
library/Solarium/Core/Client/Adapter/Http.php
View file @
b2faf8c8
...
@@ -111,13 +111,25 @@ class Http extends Configurable implements AdapterInterface
...
@@ -111,13 +111,25 @@ class Http extends Configurable implements AdapterInterface
if
(
$method
==
Request
::
METHOD_POST
)
{
if
(
$method
==
Request
::
METHOD_POST
)
{
if
(
$request
->
getFileUpload
())
{
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
(
stream_context_set_option
(
$context
,
$context
,
'http'
,
'http'
,
'content'
,
'content'
,
file_get_contents
(
$request
->
getFileUpload
())
$data
);
);
$request
->
addHeader
(
'Content-Type: multipart/form-data'
);
}
else
{
}
else
{
$data
=
$request
->
getRawData
();
$data
=
$request
->
getRawData
();
if
(
null
!==
$data
)
{
if
(
null
!==
$data
)
{
...
...
library/Solarium/QueryType/Extract/RequestBuilder.php
View file @
b2faf8c8
...
@@ -107,7 +107,6 @@ class RequestBuilder extends BaseRequestBuilder
...
@@ -107,7 +107,6 @@ class RequestBuilder extends BaseRequestBuilder
}
elseif
(
is_readable
(
$file
))
{
}
elseif
(
is_readable
(
$file
))
{
$request
->
setFileUpload
(
$file
);
$request
->
setFileUpload
(
$file
);
$request
->
addParam
(
'resource.name'
,
basename
(
$query
->
getFile
()));
$request
->
addParam
(
'resource.name'
,
basename
(
$query
->
getFile
()));
$request
->
addHeader
(
'Content-Type: multipart/form-data'
);
}
else
{
}
else
{
throw
new
RuntimeException
(
'Extract query file path/url invalid or not available'
);
throw
new
RuntimeException
(
'Extract query file path/url invalid or not available'
);
}
}
...
...
tests/Solarium/Tests/Core/Client/Adapter/HttpTest.php
View file @
b2faf8c8
...
@@ -184,16 +184,20 @@ class HttpTest extends \PHPUnit_Framework_TestCase
...
@@ -184,16 +184,20 @@ class HttpTest extends \PHPUnit_Framework_TestCase
$context
=
$this
->
adapter
->
createContext
(
$request
,
$endpoint
);
$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
(
$this
->
assertEquals
(
array
(
array
(
'http'
=>
array
(
'http'
=>
array
(
'method'
=>
$method
,
'method'
=>
$method
,
'timeout'
=>
$timeout
,
'timeout'
=>
$timeout
,
'content'
=>
file_get_contents
(
__FILE__
),
'header'
=>
'Content-Type: multipart/form-data'
,
)
)
),
),
stream_context_get_options
(
$context
)
$stream_context_get_options
);
);
}
}
...
...
tests/Solarium/Tests/QueryType/Extract/RequestBuilderTest.php
View file @
b2faf8c8
...
@@ -134,9 +134,7 @@ class RequestBuilderTest extends \PHPUnit_Framework_TestCase
...
@@ -134,9 +134,7 @@ class RequestBuilderTest extends \PHPUnit_Framework_TestCase
public
function
testContentTypeHeader
()
public
function
testContentTypeHeader
()
{
{
$headers
=
array
(
$headers
=
array
();
'Content-Type: multipart/form-data'
);
$request
=
$this
->
builder
->
build
(
$this
->
query
);
$request
=
$this
->
builder
->
build
(
$this
->
query
);
$this
->
assertEquals
(
$headers
,
$this
->
assertEquals
(
$headers
,
$request
->
getHeaders
());
$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