Skip to content

Commit

Permalink
Change the message task to the new error interface
Browse files Browse the repository at this point in the history
  • Loading branch information
durner committed Mar 5, 2024
1 parent 2aaf5fb commit b1f7a5b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/network/http_message.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "network/http_message.hpp"
#include "network/http_response.hpp"
#include "network/message_result.hpp"
#include "utils/data_vector.hpp"
#include "utils/timer.hpp"
Expand Down Expand Up @@ -98,8 +99,13 @@ MessageState HTTPMessage::execute(IOUringSocket& socket)
socket.disconnect(request->fd, originalMessage->hostname, originalMessage->port, &tcpSettings, static_cast<uint64_t>(sendBufferOffset + receiveBufferOffset));
originalMessage->result.size = info->length;
originalMessage->result.offset = info->headerLength;
state = MessageState::Finished;
return MessageState::Finished;
if (info->response.code == HttpResponse::Code::OK_200) {
state = MessageState::Finished;
} else {
originalMessage->result.failureCode |= static_cast<uint16_t>(MessageFailureCode::HTTP);
state = MessageState::Aborted;
}
return state;
}
} catch (exception&) {
originalMessage->result.failureCode |= static_cast<uint16_t>(MessageFailureCode::HTTP);
Expand Down
6 changes: 6 additions & 0 deletions src/network/https_message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ MessageState HTTPSMessage::execute(IOUringSocket& socket)
if (HttpHelper::finished(receive.data(), static_cast<uint64_t>(receiveBufferOffset), info)) {
originalMessage->result.size = info->length;
originalMessage->result.offset = info->headerLength;
if (info->response.code == HttpResponse::Code::OK_200) {
state = MessageState::TLSShutdown;
} else {
originalMessage->result.failureCode |= static_cast<uint16_t>(MessageFailureCode::HTTP);
reset(socket, true);
}
state = MessageState::TLSShutdown;
return execute(socket);
} else {
Expand Down

0 comments on commit b1f7a5b

Please sign in to comment.