@@ -57,8 +57,9 @@ abstract class AbstractClient implements ClientInterface
5757 // retry times, when an error occurred.
5858 'retry ' => 3 ,
5959 'method ' => 'GET ' , // 'POST'
60+ 'version ' => '1.1 ' , // http version
6061 'baseUrl ' => '' ,
61- 'timeout ' => 5 ,
62+ 'timeout ' => 5 , // seconds
6263 // enable SSL verify
6364 'sslVerify ' => false ,
6465 // request headers
@@ -123,6 +124,11 @@ abstract class AbstractClient implements ClientInterface
123124 */
124125 protected array $ cookies = [];
125126
127+ /**
128+ * @var array Record debug info on $options['debug'] = true
129+ */
130+ private array $ _debugInfo = [];
131+
126132 /**************************************************************************
127133 * response data
128134 *************************************************************************/
@@ -186,11 +192,9 @@ public static function driverName(): string
186192 }
187193
188194 /**
189- * SimpleCurl constructor.
190- *
191- * @param array $options
195+ * Class constructor.
192196 *
193- * @throws RuntimeException
197+ * @param array $options = self::$defaultOptions
194198 */
195199 public function __construct (array $ options = [])
196200 {
@@ -692,12 +696,15 @@ protected function resetOptions(): static
692696 }
693697
694698 /**
699+ * reset request: headers, cookies, debugInfo
700+ *
695701 * @return $this
696702 */
697703 public function resetRequest (): static
698704 {
699- $ this ->headers = [];
700- $ this ->cookies = [];
705+ $ this ->headers = $ this ->cookies = [];
706+
707+ $ this ->_debugInfo = [];
701708 return $ this ;
702709 }
703710
@@ -729,10 +736,20 @@ public function resetResponse(): static
729736 return $ this ;
730737 }
731738
739+ /**
740+ * Reset the request and response info.
741+ *
742+ * @return static
743+ */
744+ public function resetRuntime (): static
745+ {
746+ return $ this ->resetRequest ()->resetResponse ();
747+ }
748+
732749 /**
733750 * Reset the last time headers,cookies,options,response data.
734751 *
735- * @return $this
752+ * @return static
736753 */
737754 public function reset (): static
738755 {
@@ -844,6 +861,24 @@ public function setDebug(mixed $debug): static
844861 return $ this ;
845862 }
846863
864+ /**
865+ * add debug info
866+ */
867+ public function addDebugInfo (string $ key , mixed $ value ): void
868+ {
869+ $ this ->_debugInfo [$ key ] = $ value ;
870+ }
871+
872+ /**
873+ * Get debug info on options.debug=true
874+ *
875+ * @return array
876+ */
877+ public function getDebugInfo (): array
878+ {
879+ return $ this ->_debugInfo ;
880+ }
881+
847882 /**
848883 * @param int $retry
849884 *
0 commit comments