| 313 | } |
| 314 | |
| 315 | void URI::PrintWithoutHost(std::ostream& os) const { |
| 316 | if (_path.empty()) { |
| 317 | // According to rfc2616#section-5.1.2, the absolute path |
| 318 | // cannot be empty; if none is present in the original URI, it MUST |
| 319 | // be given as "/" (the server root). |
| 320 | os << '/'; |
| 321 | } else { |
| 322 | os << _path; |
| 323 | } |
| 324 | if (_initialized_query_map && _query_was_modified) { |
| 325 | bool is_first = true; |
| 326 | for (QueryIterator it = QueryBegin(); it != QueryEnd(); ++it) { |
| 327 | if (is_first) { |
| 328 | is_first = false; |
| 329 | os << '?'; |
| 330 | } else { |
| 331 | os << '&'; |
| 332 | } |
| 333 | os << it->first; |
| 334 | if (!it->second.empty()) { |
| 335 | os << '=' << it->second; |
| 336 | } |
| 337 | } |
| 338 | } else if (!_query.empty()) { |
| 339 | os << '?' << _query; |
| 340 | } |
| 341 | if (!_fragment.empty()) { |
| 342 | os << '#' << _fragment; |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | void URI::InitializeQueryMap() const { |
| 347 | ParseQueries(_query_map, _query); |