50 : m_valid(false) {
51 std::string::const_iterator it;
52 std::string::const_iterator temp;
53
55
56 it = uri_string.begin();
57 size_t uri_len = uri_string.length();
58
59 if (uri_len >= 7 && std::equal(it,it+6,"wss://")) {
60 m_secure = true;
61 m_scheme = "wss";
62 it += 6;
63 } else if (uri_len >= 6 && std::equal(it,it+5,"ws://")) {
64 m_secure = false;
65 m_scheme = "ws";
66 it += 5;
67 } else if (uri_len >= 8 && std::equal(it,it+7,"http://")) {
68 m_secure = false;
69 m_scheme = "http";
70 it += 7;
71 } else if (uri_len >= 9 && std::equal(it,it+8,"https://")) {
72 m_secure = true;
73 m_scheme = "https";
74 it += 8;
75 } else {
76 return;
77 }
78
79
80
81
82
83 if (*it == '[') {
84 ++it;
85
86
87
88
89
90
91 temp = it;
92 while (temp != uri_string.end()) {
93 if (*temp == ']') {
94 break;
95 }
96 ++temp;
97 }
98
99 if (temp == uri_string.end()) {
100 return;
101 } else {
102
103
104 m_host.append(it,temp);
105 }
106 it = temp+1;
107 if (it == uri_string.end()) {
109 } else if (*it == '/') {
111 ++it;
112 } else if (*it == ':') {
114 ++it;
115 } else {
116
117 return;
118 }
119 } else {
120
121
123 if (it == uri_string.end()) {
125 break;
126 } else if (*it == '/') {
128 } else if (*it == ':') {
129
131 } else {
132 m_host += *it;
133 }
134 ++it;
135 }
136 }
137
138
139 std::string port;
141 if (it == uri_string.end()) {
142
143
144
145
146 break;
147 } else if (*it == '/') {
149 } else {
150 port += *it;
151 }
152 ++it;
153 }
154
155 lib::error_code ec;
156 m_port = get_port_from_string(port, ec);
157
158 if (ec) {
159 return;
160 }
161
162 m_resource = "/";
163 m_resource.append(it,uri_string.end());
164
165
166 m_valid = true;
167 }