summaryrefslogtreecommitdiff
path: root/chromium/net/http/http_util_icu.cc
blob: 64e7424df1442e015c8b5061d9e0a16a15fe7d78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// The rules for parsing content-types were borrowed from Firefox:
// http://lxr.mozilla.org/mozilla/source/netwerk/base/src/nsURLHelper.cpp#834

#include "net/http/http_util.h"

#include "base/logging.h"
#include "net/base/net_util.h"

namespace net {

// static
std::string HttpUtil::PathForRequest(const GURL& url) {
  DCHECK(url.is_valid() && (url.SchemeIs("http") || url.SchemeIs("https")));
  if (url.has_query())
    return url.path() + "?" + url.query();
  return url.path();
}

// static
std::string HttpUtil::SpecForRequest(const GURL& url) {
  // We may get ftp scheme when fetching ftp resources through proxy.
  DCHECK(url.is_valid() && (url.SchemeIs("http") ||
                            url.SchemeIs("https") ||
                            url.SchemeIs("ftp")));
  return SimplifyUrlForRequest(url).spec();
}

}  // namespace net