44
55namespace SimPod \ClickHouseClient \Client \Http ;
66
7+ use GuzzleHttp \Psr7 \MultipartStream ;
78use InvalidArgumentException ;
89use Psr \Http \Message \RequestFactoryInterface ;
910use Psr \Http \Message \RequestInterface ;
10- use Psr \Http \Message \StreamFactoryInterface ;
1111use Psr \Http \Message \UriFactoryInterface ;
1212use Psr \Http \Message \UriInterface ;
1313
@@ -24,7 +24,6 @@ final class RequestFactory
2424 /** @throws InvalidArgumentException */
2525 public function __construct (
2626 private RequestFactoryInterface $ requestFactory ,
27- private StreamFactoryInterface $ streamFactory ,
2827 UriFactoryInterface |null $ uriFactory = null ,
2928 UriInterface |string $ uri = '' ,
3029 ) {
@@ -50,8 +49,6 @@ public function prepareRequest(RequestOptions $requestOptions): RequestInterface
5049 PHP_QUERY_RFC3986 ,
5150 );
5251
53- $ body = $ this ->streamFactory ->createStream ($ requestOptions ->sql );
54-
5552 if ($ this ->uri === null ) {
5653 $ uri = $ query === '' ? '' : '? ' . $ query ;
5754 } else {
@@ -64,8 +61,14 @@ public function prepareRequest(RequestOptions $requestOptions): RequestInterface
6461 }
6562
6663 $ request = $ this ->requestFactory ->createRequest ('POST ' , $ uri );
64+
65+ $ streamElements = [['name ' => 'query ' , 'contents ' => $ requestOptions ->sql ]];
66+
6767 try {
68- $ request = $ request ->withBody ($ body );
68+ $ body = new MultipartStream ($ streamElements );
69+ $ request = $ request
70+ ->withHeader ('Content-Type ' , 'multipart/form-data; boundary= ' . $ body ->getBoundary ())
71+ ->withBody ($ body );
6972 } catch (InvalidArgumentException ) {
7073 absurd ();
7174 }
0 commit comments