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
22 > **Note:** The request URL in a request message usually only consists of the path and the querystring.
25 $m = new http\Message;
26 $m->setType(http\Message::TYPE_REQUEST);
27 $m->setRequestMethod("GET");
28 $m->setRequestUrl("http://foo.bar/baz?q");
34 GET http://foo.bar/baz?q HTTP/1.1
36 Maybe you did not really expect this, so let's try this:
39 $m = new http\Message;
40 $u = new http\Url("http://foo.bar/baz?q");
41 $m->setType(http\Message::TYPE_REQUEST);
42 $m->setRequestMethod("GET");
43 $m->setRequestUrl($u->path ."?". $u->query);
44 $m->setHeader("Host", $u->host);