code: public function sendResponse($result, $exitWhenDone = false)
      {
          if ($result instanceof Promise) {
              $result->then(function ($actualResult) use ($exitWhenDone) {
                  $this->doSendResponse($actualResult, $exitWhenDone);
              });
          } else {
              $this->doSendResponse($result, $exitWhenDone);
          }
      }
docs: Send response using standard PHP `header()` and `echo`.
  
  @param Promise|ExecutionResult|ExecutionResult[] $result
  @param bool                                      $exitWhenDone
  
  @api