1// Copyright (c) 2009 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5// The rules for parsing content-types were borrowed from Firefox: 6// http://lxr.mozilla.org/mozilla/source/netwerk/base/src/nsURLHelper.cpp#834 7 8#include "net/http/http_util.h" 9 10#include "base/logging.h" 11#include "net/base/net_util.h" 12 13namespace net { 14 15// static 16std::string HttpUtil::PathForRequest(const GURL& url) { 17 DCHECK(url.is_valid() && (url.SchemeIs("http") || url.SchemeIs("https"))); 18 if (url.has_query()) 19 return url.path() + "?" + url.query(); 20 return url.path(); 21} 22 23// static 24std::string HttpUtil::SpecForRequest(const GURL& url) { 25 // We may get ftp scheme when fetching ftp resources through proxy. 26 DCHECK(url.is_valid() && (url.SchemeIs("http") || 27 url.SchemeIs("https") || 28 url.SchemeIs("ftp"))); 29 return SimplifyUrlForRequest(url).spec(); 30} 31 32} // namespace net 33