string path = urlencode(url.path);
if(path.empty())
path = "/";
- if(!url.query.empty())
- {
- path += '?';
- path += url.query;
- }
+ append(path, "?", url.query);
Request result("GET", path);
result.set_header("Host", url.host);
str += url.scheme+"://";
str += url.host;
str += urlencode(url.path);
- if(!url.query.empty())
- {
- str += '?';
- str += url.query;
- }
- if(!url.fragment.empty())
- {
- str += '#';
- str += url.fragment;
- }
+ append(str, "?", url.query);
+ append(str, "#", url.fragment);
return str;
}
string str;
for(const auto &kvp: query)
{
- if(!str.empty())
- str += '&';
- str += urlencode_plus(kvp.first);
+ append(str, "&", urlencode_plus(kvp.first));
str += '=';
str += urlencode_plus(kvp.second);
}
#include "inet6.h"
#include "platform_api.h"
#include <msp/strings/format.h>
+#include <msp/strings/utils.h>
#include "sockaddr_private.h"
using namespace std;
string result = "[";
for(unsigned i=0; i<16; i+=2)
{
- unsigned short part = (addr[i]<<8) | addr[i+1];
if(i>0)
result += ':';
+ unsigned short part = (addr[i]<<8) | addr[i+1];
result += format("%x", part);
}
result += ']';