Skip to content

Commit

Permalink
Implement sceHttp library
Browse files Browse the repository at this point in the history
  • Loading branch information
anr2me committed Aug 28, 2023
1 parent 5b9bdc1 commit 841de7d
Show file tree
Hide file tree
Showing 9 changed files with 1,133 additions and 83 deletions.
5 changes: 4 additions & 1 deletion Common/Net/HTTPClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ int Client::SendRequestWithData(const char *method, const RequestParams &req, co
return 0;
}

int Client::ReadResponseHeaders(net::Buffer *readbuf, std::vector<std::string> &responseHeaders, net::RequestProgress *progress) {
int Client::ReadResponseHeaders(net::Buffer *readbuf, std::vector<std::string> &responseHeaders, net::RequestProgress *progress, std::string * httpCode) {
// Snarf all the data we can into RAM. A little unsafe but hey.
static constexpr float CANCEL_INTERVAL = 0.25f;
bool ready = false;
Expand Down Expand Up @@ -367,6 +367,9 @@ int Client::ReadResponseHeaders(net::Buffer *readbuf, std::vector<std::string> &
return -1;
}

if (httpCode)
*httpCode = line;

while (true) {
int sz = readbuf->TakeLineCRLF(&line);
if (!sz || sz < 0)
Expand Down
6 changes: 5 additions & 1 deletion Common/Net/HTTPClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class Client : public net::Connection {

int SendRequest(const char *method, const RequestParams &req, const char *otherHeaders, net::RequestProgress *progress);
int SendRequestWithData(const char *method, const RequestParams &req, const std::string &data, const char *otherHeaders, net::RequestProgress *progress);
int ReadResponseHeaders(net::Buffer *readbuf, std::vector<std::string> &responseHeaders, net::RequestProgress *progress);
int ReadResponseHeaders(net::Buffer *readbuf, std::vector<std::string> &responseHeaders, net::RequestProgress *progress, std::string* httpCode = nullptr);
// If your response contains a response, you must read it.
int ReadResponseEntity(net::Buffer *readbuf, const std::vector<std::string> &responseHeaders, Buffer *output, net::RequestProgress *progress);

Expand All @@ -84,6 +84,10 @@ class Client : public net::Connection {
userAgent_ = value;
}

void SetHttpVersion(const char* version) {
httpVersion_ = version;
}

protected:
std::string userAgent_;
const char *httpVersion_;
Expand Down
10 changes: 10 additions & 0 deletions Core/HLE/FunctionWrappers.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,11 @@ template<int func(u32, u32, u32, u32, u32)> void WrapI_UUUUU() {
RETURN(retval);
}

template<int func(u32, const char*, u32, u32, int)> void WrapI_UCUUI() {
int retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), PARAM(3), PARAM(4));
RETURN(retval);
}

template<int func()> void WrapI_V() {
int retval = func();
RETURN(retval);
Expand Down Expand Up @@ -765,6 +770,11 @@ template<u32 func(u32, u32, u32, u32, u32, u32, u32)> void WrapU_UUUUUUU() {
RETURN(retval);
}

template<int func(u32, u32, u32, u32, u32, u32, u32)> void WrapI_UUUUUUU() {
int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5), PARAM(6));
RETURN(retval);
}

template<int func(int, u32, u32, u32, u32, u32, u32)> void WrapI_IUUUUUU() {
int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5), PARAM(6));
RETURN(retval);
Expand Down
Loading

0 comments on commit 841de7d

Please sign in to comment.