diff --git a/README.md b/README.md index e7d20461..8102eb85 100644 --- a/README.md +++ b/README.md @@ -346,6 +346,7 @@ A brief summary of the available options follows. | OP_VERBOSITY | A bitmask of client constants controlling raw message output to the console. | | OP_COMBINE_COOKIES | A boolean (default: `true`) controlling whether or not cookie headers are combined into a single header when sending requests. | | OP_CRYPTO | An array controlling TLS encryption options. | +| OP_DEFAULT_USER_AGENT | A string set for each request's User-Agent if a UA has not already been provided. | ### Miscellaneous diff --git a/lib/Client.php b/lib/Client.php index 098f3f54..50e39c0f 100644 --- a/lib/Client.php +++ b/lib/Client.php @@ -487,7 +487,7 @@ private function parseSocketData(RequestCycle $cycle) { } else { $this->assignParsedResponse($cycle, $parsedResponseArr); } - + if ($cycle->parser->getBuffer()) { $this->reactor->immediately(function() use ($cycle) { $this->parseSocketData($cycle); @@ -992,6 +992,9 @@ public function setOption($option, $value) { case self::OP_CRYPTO: $this->options[self::OP_CRYPTO] = (array) $value; break; + case self::OP_DEFAULT_USER_AGENT: + $this->options[self::OP_DEFAULT_USER_AGENT] = (string) $value; + break; default: throw new \DomainException( sprintf("Unknown option: %s", $option)