code: public function then(callable $onFulfilled = null, callable $onRejected = null)
      {
          $newPromise = new self($this->loop);
  
          $onFulfilled = null !== $onFulfilled ? $onFulfilled : function (ResponseInterface $response) {
              return $response;
          };
  
          $onRejected = null !== $onRejected ? $onRejected : function (Exception $exception) {
              throw $exception;
          };
  
          $this->onFulfilled = function (ResponseInterface $response) use ($onFulfilled, $newPromise) {
              try {
                  $return = $onFulfilled($response);
  
                  $newPromise->resolve(null !== $return ? $return : $response);
              } catch (Exception $exception) {
                  $newPromise->reject($exception);
              }
          };
  
          $this->onRejected = function (Exception $exception) use ($onRejected, $newPromise) {
              try {
                  $newPromise->resolve($onRejected($exception));
              } catch (Exception $exception) {
                  $newPromise->reject($exception);
              }
          };
  
          if (HttpPromise::FULFILLED === $this->state) {
              $this->doResolve($this->response);
          }
  
          if (HttpPromise::REJECTED === $this->state) {
              $this->doReject($this->exception);
          }
  
          return $newPromise;
      }
docs: Allow to apply callable when the promise resolve.
  
  @param callable|null $onFulfilled
  @param callable|null $onRejected
  
  @return Promise