public function __callback_testBeforeSendEmitsErrorEvent_1(puzzle_event_BeforeEvent $e) { $this->assertSame($this->_closure_testBeforeSendEmitsErrorEvent_request, $e->getRequest()); $this->assertSame($this->_closure_testBeforeSendEmitsErrorEvent_client, $e->getClient()); $this->_closure_testBeforeSendEmitsErrorEvent_beforeCalled++; throw $this->_closure_testBeforeSendEmitsErrorEvent_ex; }
public function onBefore(puzzle_event_BeforeEvent $event) { $request = $event->getRequest(); // Set the appropriate Content-Type for a request if one is not set and // there are form fields if (!($body = $request->getBody())) { return; } $this->addContentLength($request, $body); if ($body instanceof puzzle_post_PostBodyInterface) { // Synchronize the POST body with the request's headers $body->applyRequestHeaders($request); } elseif (!$request->hasHeader('Content-Type')) { $this->addContentType($request, $body); } $this->addExpectHeader($request, $body); }
/** * @throws OutOfBoundsException|Exception */ public function onBefore(puzzle_event_BeforeEvent $event) { if (!($item = array_shift($this->queue))) { throw new OutOfBoundsException('Mock queue is empty'); } elseif ($item instanceof puzzle_exception_RequestException) { throw $item; } // Emulate the receiving of the response headers $request = $event->getRequest(); $transaction = new puzzle_adapter_Transaction($event->getClient(), $request); $transaction->setResponse($item); $request->getEmitter()->emit('headers', new puzzle_event_HeadersEvent($transaction)); // Emulate reading a response body if ($this->readBodies && $request->getBody()) { while (!$request->getBody()->eof()) { $request->getBody()->read(8096); } } $event->intercept($item); }
public function onBefore(puzzle_event_BeforeEvent $event) { $this->cookieJar->addCookieHeader($event->getRequest()); }