@@ -226,20 +226,6 @@ class HttpRequest
226226 */
227227 public $ websocketCompression = false ;
228228
229- /**
230- * 代理认证方式.
231- *
232- * @var array
233- */
234- public static $ proxyAuths = [];
235-
236- /**
237- * 代理类型.
238- *
239- * @var array
240- */
241- public static $ proxyType = [];
242-
243229 /**
244230 * 自动扩展名标志.
245231 */
@@ -912,6 +898,7 @@ protected function parseRequestBody($requestBody, $contentType)
912898 }
913899 }
914900 $ body = http_build_query ($ body , '' , '& ' );
901+ break ;
915902 }
916903 }
917904 else
@@ -943,9 +930,8 @@ public function buildRequest($url = null, $requestBody = null, $method = null, $
943930 $ method = $ this ->method ;
944931 }
945932 list ($ body , $ files ) = $ this ->parseRequestBody (null === $ requestBody ? $ this ->content : $ requestBody , $ contentType );
946- $ request = new Request ($ url , $ this ->headers , $ body , $ method );
947933 $ saveFileOption = $ this ->saveFileOption ;
948- $ request = $ request ->withUploadedFiles ($ files )
934+ $ request = ( new Request ( $ url , $ this -> headers , $ body , $ method )) ->withUploadedFiles ($ files )
949935 ->withCookieParams ($ this ->cookies )
950936 ->withAttribute (Attributes::MAX_REDIRECTS , $ this ->maxRedirects )
951937 ->withAttribute (Attributes::IS_VERIFY_CA , $ this ->isVerifyCA )
@@ -1127,7 +1113,7 @@ public function download($fileName, $url = null, $requestBody = null, $method =
11271113 $ result = $ this ->saveFile ($ fileName )->send ($ url , $ requestBody , $ method );
11281114 if ($ isAutoExt )
11291115 {
1130- self ::parseDownloadAutoExt ($ result , $ fileName );
1116+ $ result = self ::parseDownloadAutoExt ($ result , $ fileName );
11311117 }
11321118 $ this ->saveFileOption = [];
11331119
@@ -1174,9 +1160,9 @@ public static function checkDownloadIsAutoExt($fileName, &$tempFileName)
11741160 * @param \Yurun\Util\YurunHttp\Http\Response $response
11751161 * @param string $tempFileName
11761162 *
1177- * @return void
1163+ * @return \Yurun\Util\YurunHttp\Http\Response
11781164 */
1179- public static function parseDownloadAutoExt (& $ response , $ tempFileName )
1165+ public static function parseDownloadAutoExt ($ response , $ tempFileName )
11801166 {
11811167 $ ext = MediaType ::getExt ($ response ->getHeaderLine ('Content-Type ' ));
11821168 if (null === $ ext )
@@ -1185,23 +1171,7 @@ public static function parseDownloadAutoExt(&$response, $tempFileName)
11851171 }
11861172 $ savedFileName = substr ($ tempFileName , 0 , -\strlen (self ::AUTO_EXT_TEMP_EXT )) . '. ' . $ ext ;
11871173 rename ($ tempFileName , $ savedFileName );
1188- $ response = $ response ->withSavedFileName ($ savedFileName );
1189- }
1190- }
11911174
1192- if (\extension_loaded ('curl ' ))
1193- {
1194- // 代理认证方式
1195- HttpRequest::$ proxyAuths = [
1196- 'basic ' => \CURLAUTH_BASIC ,
1197- 'ntlm ' => \CURLAUTH_NTLM ,
1198- ];
1199-
1200- // 代理类型
1201- HttpRequest::$ proxyType = [
1202- 'http ' => \CURLPROXY_HTTP ,
1203- 'socks4 ' => \CURLPROXY_SOCKS4 ,
1204- 'socks4a ' => 6 , // CURLPROXY_SOCKS4A
1205- 'socks5 ' => \CURLPROXY_SOCKS5 ,
1206- ];
1175+ return $ response ->withSavedFileName ($ savedFileName );
1176+ }
12071177}
0 commit comments