public function testHeaderParsing() { // given $req = new Request(); $req->addHeader('created', '2010-10-10'); $req->addHeader('expiration', '2010-10-11'); $req->addHeader('custom-header', 'foo'); $ctx = new Context($req, new Response()); $injectable = new MessageInjectableFactory(); // when $msg = $injectable->create($ctx, ''); // then $this->assertEquals($msg->getCreated(), '2010-10-10'); $this->assertEquals($msg->getExpiration(), '2010-10-11'); $this->assertEquals($msg->getHeader('custom-header'), 'foo'); }
public function marshalRoutineRequest(RoutineRequest $req) { $type = $req->getType(); $method = $req->getMethod(); $vos = $this->marshalForMethod($req->getArgs(), $req->getType(), $req->getMethod()); $vos[] = $this->marshalArg($req->getExitChan(), Chan::CLASSNAME); $vos[] = $req->getRetryErrors(); $topicStr = $this->marshalTopicString($req->getNs(), $req->getDc(), $req->getType(), $req->getMethod()); $r = new Request(); $r->addHeader('X-routing-key', $topicStr); $r->setBody(json_encode($vos)); return $r; }
public function createDefault() { $inst = new Request(); $inst->setProtocol(self::getProtocol()); $inst->setHost(self::getHost()); $inst->setUrl(self::getCurrentUrl()); $inst->setHttpMethod(self::getHttpMethod()); $inst->setBody(self::getBody()); $inst->setGetParams(self::getGetParams()); $headers = self::getRequestHeaders(); foreach ($headers as $key => $val) { $inst->addHeader($key, $val); } return $inst; }
public function testTopicFromString() { // given $x = $this->buildRequest('', '', 'Fliglio\\Borg\\TopicTest', 'testTopic'); $x2 = $this->mapper->marshalRoutineRequest($x); $req = new Request(); $req->addHeader("X-routing-key", 'foo.bar.Fliglio.Borg.TopicTest.testTopic'); $req->setBody($x2->getBody()); // when $found = $this->mapper->unmarshalRoutineRequest($req); // then $this->assertEquals('foo', $found->getNs(), 'should match'); $this->assertEquals('bar', $found->getDc(), 'should match'); $this->assertEquals('Fliglio\\Borg\\TopicTest', $found->getType(), 'should match'); $this->assertEquals('testTopic', $found->getMethod(), 'should match'); }