misc fixes

This commit is contained in:
Peter Thorson
2011-11-13 20:46:54 -06:00
parent 4ed86a7c30
commit 40a42dd637
7 changed files with 115 additions and 45 deletions

View File

@@ -26,6 +26,7 @@
*/
#include "network_utilities.hpp"
#include "websocket_constants.hpp"
#include <sstream>
#include "md5/md5.h"
@@ -153,7 +154,7 @@ bool websocketpp::ws_uri::parse(const std::string& uri) {
host = what[2];
if (what[3] == "") {
port = (secure ? 443 : 80);
port = (secure ? DEFAULT_SECURE_PORT : DEFAULT_PORT);
} else {
unsigned int t_port = atoi(std::string(what[3]).substr(1).c_str());
@@ -182,7 +183,7 @@ std::string websocketpp::ws_uri::base() {
s << "ws" << (secure ? "s" : "") << "://" << host;
if (port != (secure ? 443 : 80)) {
if (port != (secure ? DEFAULT_SECURE_PORT : DEFAULT_PORT)) {
s << ":" << port;
}
@@ -190,6 +191,19 @@ std::string websocketpp::ws_uri::base() {
return s.str();
}
std::string websocketpp::ws_uri::str() {
std::stringstream s;
s << "ws" << (secure ? "s" : "") << "://" << host;
if (port != (secure ? DEFAULT_SECURE_PORT : DEFAULT_PORT)) {
s << ":" << port;
}
s << resource;
return s.str();
}
void md5_hash_string(char *string,char *hash) {
md5_state_t state;