Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Http] Implement sceHttp library #18003

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
5 changes: 4 additions & 1 deletion Common/Net/HTTPClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,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 *statusLine) {
// 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 @@ -404,6 +404,9 @@ int Client::ReadResponseHeaders(net::Buffer *readbuf, std::vector<std::string> &
return -1;
}

if (statusLine)
*statusLine = 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 *statusLine = 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_;
double dataTimeout_ = 900.0;
Expand Down
15 changes: 15 additions & 0 deletions Core/HLE/FunctionWrappers.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,16 @@ 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(u32, int, const char*, u32, u32)> void WrapI_UICUU() {
int retval = func(PARAM(0), PARAM(1), Memory::GetCharPointer(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 +775,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
Loading