crlib: use real status codes for http
graph: allow uploading from hlds console.
This commit is contained in:
parent
3070a7c404
commit
ee3f9e7538
4 changed files with 81 additions and 27 deletions
|
|
@ -38,19 +38,81 @@
|
||||||
# include <ws2tcpip.h>
|
# include <ws2tcpip.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// TODO: make this work with real HTTP responses
|
|
||||||
|
|
||||||
// status codes for http client
|
// status codes for http client
|
||||||
CR_DECLARE_SCOPED_ENUM (HttpClientResult,
|
CR_DECLARE_SCOPED_ENUM (HttpClientResult,
|
||||||
OK = 0,
|
Continue = 100,
|
||||||
NotFound,
|
SwitchingProtocol = 101,
|
||||||
Forbidden,
|
Processing = 102,
|
||||||
SocketError,
|
EarlyHints = 103,
|
||||||
ConnectError,
|
|
||||||
HttpOnly,
|
Ok = 200,
|
||||||
Undefined,
|
Created = 201,
|
||||||
NoLocalFile = -1,
|
Accepted = 202,
|
||||||
LocalFileExists = -2
|
NonAuthoritativeInformation = 203,
|
||||||
|
NoContent = 204,
|
||||||
|
ResetContent = 205,
|
||||||
|
PartialContent = 206,
|
||||||
|
MultiStatus = 207,
|
||||||
|
AlreadyReported = 208,
|
||||||
|
ImUsed = 226,
|
||||||
|
|
||||||
|
MultipleChoice = 300,
|
||||||
|
MovedPermanently = 301,
|
||||||
|
Found = 302,
|
||||||
|
SeeOther = 303,
|
||||||
|
NotModified = 304,
|
||||||
|
UseProxy = 305,
|
||||||
|
TemporaryRedirect = 307,
|
||||||
|
PermanentRedirect = 308,
|
||||||
|
|
||||||
|
BadRequest = 400,
|
||||||
|
Unauthorized = 401,
|
||||||
|
PaymentRequired = 402,
|
||||||
|
Forbidden = 403,
|
||||||
|
NotFound = 404,
|
||||||
|
MethodNotAllowed = 405,
|
||||||
|
NotAcceptable = 406,
|
||||||
|
ProxyAuthenticationRequired = 407,
|
||||||
|
RequestTimeout = 408,
|
||||||
|
Conflict = 409,
|
||||||
|
Gone = 410,
|
||||||
|
LengthRequired = 411,
|
||||||
|
PreconditionFailed = 412,
|
||||||
|
PayloadTooLarge = 413,
|
||||||
|
UriTooLong = 414,
|
||||||
|
UnsupportedMediaType = 415,
|
||||||
|
RangeNotSatisfiable = 416,
|
||||||
|
ExpectationFailed = 417,
|
||||||
|
ImaTeapot = 418,
|
||||||
|
MisdirectedRequest = 421,
|
||||||
|
UnprocessableEntity = 422,
|
||||||
|
Locked = 423,
|
||||||
|
FailedDependency = 424,
|
||||||
|
TooEarly = 425,
|
||||||
|
UpgradeRequired = 426,
|
||||||
|
PreconditionRequired = 428,
|
||||||
|
TooManyRequests = 429,
|
||||||
|
RequestHeaderFieldsTooLarge = 431,
|
||||||
|
UnavailableForLegalReasons = 451,
|
||||||
|
|
||||||
|
InternalServerError = 500,
|
||||||
|
NotImplemented = 501,
|
||||||
|
BadGateway = 502,
|
||||||
|
ServiceUnavailable = 503,
|
||||||
|
GatewayTimeout = 504,
|
||||||
|
HttpVersionNotSupported = 505,
|
||||||
|
VariantAlsoNegotiates = 506,
|
||||||
|
InsufficientStorage = 507,
|
||||||
|
LoopDetected = 508,
|
||||||
|
NotExtended = 510,
|
||||||
|
NetworkAuthenticationRequired = 511,
|
||||||
|
|
||||||
|
SocketError = -1,
|
||||||
|
ConnectError = -2,
|
||||||
|
HttpOnly = -3,
|
||||||
|
Undefined = -4,
|
||||||
|
NoLocalFile = -5,
|
||||||
|
LocalFileExists = -6
|
||||||
)
|
)
|
||||||
|
|
||||||
CR_NAMESPACE_BEGIN
|
CR_NAMESPACE_BEGIN
|
||||||
|
|
@ -81,7 +143,7 @@ public:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool connect (StringRef hostname) {
|
bool connect (StringRef hostname) {
|
||||||
addrinfo hints, *result = nullptr;
|
addrinfo hints {}, *result = nullptr;
|
||||||
plat.bzero (&hints, sizeof (hints));
|
plat.bzero (&hints, sizeof (hints));
|
||||||
|
|
||||||
constexpr auto NumericServ = 0x00000008;
|
constexpr auto NumericServ = 0x00000008;
|
||||||
|
|
@ -265,15 +327,7 @@ private:
|
||||||
String respCode = response.substr (responseCodeStart + 9, 3);
|
String respCode = response.substr (responseCodeStart + 9, 3);
|
||||||
respCode.trim ();
|
respCode.trim ();
|
||||||
|
|
||||||
if (respCode == "200") {
|
return static_cast <HttpClientResult> (respCode.int_ ());
|
||||||
return HttpClientResult::OK;
|
|
||||||
}
|
|
||||||
else if (respCode == "403") {
|
|
||||||
return HttpClientResult::Forbidden;
|
|
||||||
}
|
|
||||||
else if (respCode == "404") {
|
|
||||||
return HttpClientResult::NotFound;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return HttpClientResult::NotFound;
|
return HttpClientResult::NotFound;
|
||||||
}
|
}
|
||||||
|
|
@ -319,7 +373,7 @@ public:
|
||||||
SmallArray <uint8> buffer (chunkSize_);
|
SmallArray <uint8> buffer (chunkSize_);
|
||||||
statusCode_ = parseResponseHeader (buffer.data ());
|
statusCode_ = parseResponseHeader (buffer.data ());
|
||||||
|
|
||||||
if (statusCode_ != HttpClientResult::OK) {
|
if (statusCode_ != HttpClientResult::Ok) {
|
||||||
socket_.disconnect ();
|
socket_.disconnect ();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -349,7 +403,7 @@ public:
|
||||||
file.close ();
|
file.close ();
|
||||||
|
|
||||||
socket_.disconnect ();
|
socket_.disconnect ();
|
||||||
statusCode_ = HttpClientResult::OK;
|
statusCode_ = HttpClientResult::Ok;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -444,7 +498,7 @@ public:
|
||||||
statusCode_ = parseResponseHeader (buffer.data ());
|
statusCode_ = parseResponseHeader (buffer.data ());
|
||||||
socket_.disconnect ();
|
socket_.disconnect ();
|
||||||
|
|
||||||
return statusCode_ == HttpClientResult::OK;
|
return statusCode_ == HttpClientResult::Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ private:
|
||||||
|
|
||||||
union {
|
union {
|
||||||
UniquePtr <LambdaFunctorWrapper> functor_;
|
UniquePtr <LambdaFunctorWrapper> functor_;
|
||||||
uint8 small_[LamdaSmallBufferLength];
|
uint8 small_[LamdaSmallBufferLength] { };
|
||||||
};
|
};
|
||||||
|
|
||||||
bool ssoObject_ = false;
|
bool ssoObject_ = false;
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ public:
|
||||||
int32 dist = 0;
|
int32 dist = 0;
|
||||||
|
|
||||||
if (maxMatch >= MinMatch) {
|
if (maxMatch >= MinMatch) {
|
||||||
const int32 limit = cr::max <int32> (cur - WindowSize, EmptyHash);
|
const auto limit = cr::max <int32> (cur - WindowSize, EmptyHash);
|
||||||
|
|
||||||
int32 chainLength = MaxChain;
|
int32 chainLength = MaxChain;
|
||||||
int32 lookup = hashTable_[hash32 (&in[cur])];
|
int32 lookup = hashTable_[hash32 (&in[cur])];
|
||||||
|
|
|
||||||
|
|
@ -270,7 +270,7 @@ int BotControl::cmdNode () {
|
||||||
enum args { root, alias, cmd, cmd2 };
|
enum args { root, alias, cmd, cmd2 };
|
||||||
|
|
||||||
// graph editor supported only with editor
|
// graph editor supported only with editor
|
||||||
if (game.isDedicated () && !graph.hasEditor () && strValue (cmd) != "acquire_editor") {
|
if (game.isDedicated () && !graph.hasEditor () && strValue (cmd) != "acquire_editor" && strValue (cmd) != "upload") {
|
||||||
msg ("Unable to use graph edit commands without setting graph editor player. Please use \"graph acquire_editor\" to acquire rights for graph editing.");
|
msg ("Unable to use graph edit commands without setting graph editor player. Please use \"graph acquire_editor\" to acquire rights for graph editing.");
|
||||||
return BotCommandResult::Handled;
|
return BotCommandResult::Handled;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue