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().
14 * false, if the message was not of type request.
18 * E_MESSAGE_TYPE, if the message is not of type request.
22 * E_INVALID_PARAM, if the url is of zero length.
26 > **Note:** The request URL in a request message usually only consists of the path and the querystring.
29 $m = new http\Message;
30 $m->setType(http\Message::TYPE_REQUEST);
31 $m->setRequestMethod("GET");
32 $m->setRequestUrl("http://foo.bar/baz?q");
38 GET http://foo.bar/baz?q HTTP/1.1
40 Maybe you did not really expect this, so let's try this:
43 $m = new http\Message;
44 $u = new http\Url("http://foo.bar/baz?q");
45 $m->setType(http\Message::TYPE_REQUEST);
46 $m->setRequestMethod("GET");
47 $m->setRequestUrl($u->path ."?". $u->query);
48 $m->setHeader("Host", $u->host);