diff --git a/modules/web/http/http_session.cpp b/modules/web/http/http_session.cpp index 8f8739531..40cf38486 100644 --- a/modules/web/http/http_session.cpp +++ b/modules/web/http/http_session.cpp @@ -52,10 +52,16 @@ Ref HTTPSession::get_reference(const String &key) { return Ref(_data[key]); } -int HTTPSession::get_int(const String &key) { +int HTTPSession::get_int(const String &key, const int def) { // don't lock here - return _data[key]; + Variant *v = _data.getptr(key); + + if (!v) { + return def; + } + + return *v; } void HTTPSession::clear() { diff --git a/modules/web/http/http_session.h b/modules/web/http/http_session.h index e44186fbd..3b507d11c 100644 --- a/modules/web/http/http_session.h +++ b/modules/web/http/http_session.h @@ -16,6 +16,8 @@ //Add an api for variants, similar to get set_meta, but rw locked. //Make sure it's obvious that it's not saved. Maybe set_temp_data ... +//Also add an RWLock + class HTTPSession : public Reference { GDCLASS(HTTPSession, Reference); @@ -34,7 +36,7 @@ public: const Variant &get_const(const String &key); Object *get_object(const String &key); Ref get_reference(const String &key); - int get_int(const String &key); + int get_int(const String &key, const int def = 0); void clear(); void reset();