Don't sent scheme and hostname in request

This commit is contained in:
Jean Flach 2017-09-06 16:01:02 +02:00
parent a8bac0a42e
commit de51966f52
4 changed files with 12 additions and 10 deletions

View File

@ -49,7 +49,7 @@ public:
return false; return false;
pUrl = f.GetUrl(); pUrl = f.GetUrl();
url = pUrl->Format(true); url = pUrl->Format(false, true);
wUrl = url; wUrl = url;
config.Write("url", wUrl); config.Write("url", wUrl);
} else { } else {

View File

@ -165,7 +165,7 @@ void HttpRequest::AddHeader(const String& key, const String& value)
void HttpRequest::FinishHeaders(void) void HttpRequest::FinishHeaders(void)
{ {
if (m_State == HttpRequestStart) { if (m_State == HttpRequestStart) {
String rqline = RequestMethod + " " + RequestUrl->Format() + " HTTP/1." + (ProtocolVersion == HttpVersion10 ? "0" : "1") + "\n"; String rqline = RequestMethod + " " + RequestUrl->Format(true) + " HTTP/1." + (ProtocolVersion == HttpVersion10 ? "0" : "1") + "\n";
m_Stream->Write(rqline.CStr(), rqline.GetLength()); m_Stream->Write(rqline.CStr(), rqline.GetLength());
m_State = HttpRequestHeaders; m_State = HttpRequestHeaders;
} }

View File

@ -227,17 +227,19 @@ void Url::SetFragment(const String& fragment) {
m_Fragment = fragment; m_Fragment = fragment;
} }
String Url::Format(bool print_credentials) const String Url::Format(bool onlyPathAndQuery, bool printCredentials) const
{ {
String url; String url;
if (!onlyPathAndQuery) {
if (!m_Scheme.IsEmpty()) if (!m_Scheme.IsEmpty())
url += m_Scheme + ":"; url += m_Scheme + ":";
if (print_credentials && !GetAuthority().IsEmpty()) if (printCredentials && !GetAuthority().IsEmpty())
url += "//" + GetAuthority(); url += "//" + GetAuthority();
else if (!GetHost().IsEmpty()) else if (!GetHost().IsEmpty())
url += "//" + GetHost() + (!GetPort().IsEmpty() ? ":" + GetPort() : ""); url += "//" + GetHost() + (!GetPort().IsEmpty() ? ":" + GetPort() : "");
}
if (m_Path.empty()) if (m_Path.empty())
url += "/"; url += "/";

View File

@ -44,7 +44,7 @@ public:
Url(); Url();
Url(const String& url); Url(const String& url);
String Format(bool print_credentials = false) const; String Format(bool onlyPathAndQuery = false, bool printCredentials = false) const;
String GetScheme(void) const; String GetScheme(void) const;
String GetAuthority(void) const; String GetAuthority(void) const;