1 # http\Message http\Message::setRequestUrl(string $url)
3 Set the request URL of the message.
4 See http\Message::getRequestUrl() and http\Message::setRequestMethod().
17 * http\Exception\InvalidArgumentException
18 * http\Exception\BadMethodCallException
23 > The request URL in a request message usually only consists of the path and the querystring.
26 $m = new http\Message;
27 $m->setType(http\Message::TYPE_REQUEST);
28 $m->setRequestMethod("GET");
29 $m->setRequestUrl("http://foo.bar/baz?q");
35 GET http://foo.bar/baz?q HTTP/1.1
37 Maybe you did not really expect this, so let's try this:
40 $m = new http\Message;
41 $u = new http\Url("http://foo.bar/baz?q");
42 $m->setType(http\Message::TYPE_REQUEST);
43 $m->setRequestMethod("GET");
44 $m->setRequestUrl($u->path ."?". $u->query);
45 $m->setHeader("Host", $u->host);