fixes
This commit is contained in:
parent
64739c39d8
commit
9bdf133d0f
12 changed files with 301 additions and 168 deletions
|
|
@ -37,7 +37,7 @@ import std;
|
|||
|
||||
using namespace Crafter;
|
||||
|
||||
ClientHTTP::ClientHTTP(const char* host, std::uint16_t port): client(host, port) {
|
||||
ClientHTTP::ClientHTTP(const char* host, std::uint16_t port): host(host), port(port), client(host, port) {
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -45,14 +45,21 @@ ClientHTTP::ClientHTTP(std::string host, std::uint16_t port): ClientHTTP(host.c_
|
|||
|
||||
}
|
||||
|
||||
HTTPResponse ClientHTTP::Send(const char* request, std::uint32_t length) const {
|
||||
HTTPResponse ClientHTTP::Send(const char* request, std::uint32_t length) {
|
||||
client.Send(request, length);
|
||||
std::vector<char> buffer;
|
||||
HTTPResponse response;
|
||||
std::uint32_t i = 0;
|
||||
std::uint32_t statusStart = 0;
|
||||
while(true) {
|
||||
buffer = client.RecieveSync();
|
||||
try {
|
||||
buffer = client.RecieveSync();
|
||||
} catch(const SocketClosedException& e) {
|
||||
client = ClientTCP(host.c_str(), port);
|
||||
client.Send(request, length);
|
||||
buffer = client.RecieveSync();
|
||||
}
|
||||
|
||||
for(; i < buffer.size(); i++) {
|
||||
if(buffer[i] == ' ') {
|
||||
statusStart = i;
|
||||
|
|
@ -185,6 +192,6 @@ HTTPResponse ClientHTTP::Send(const char* request, std::uint32_t length) const {
|
|||
}
|
||||
return response;
|
||||
}
|
||||
HTTPResponse ClientHTTP::Send(std::string request) const {
|
||||
HTTPResponse ClientHTTP::Send(std::string request) {
|
||||
return Send(request.c_str(), request.size());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue