diff --git a/api/python_cffi.slurp b/api/python_cffi.slurp index 6f2532a65..dbfe0162b 100644 --- a/api/python_cffi.slurp +++ b/api/python_cffi.slurp @@ -4539,6 +4539,14 @@ void void zhttp_request_reset_content (zhttp_request_t *self); +// Set the request username +void + zhttp_request_set_username (zhttp_request_t *self, const char *username); + +// Set the request password +void + zhttp_request_set_password (zhttp_request_t *self, const char *password); + // Match the path of the request. // Support wildcards with '%s' symbol inside the match string. // Matching wildcards until the next '/', '?' or '\0'. diff --git a/bindings/jni/czmq-jni/src/main/c/org_zeromq_czmq_ZhttpRequest.c b/bindings/jni/czmq-jni/src/main/c/org_zeromq_czmq_ZhttpRequest.c index a3fec2834..8e5b522ed 100644 --- a/bindings/jni/czmq-jni/src/main/c/org_zeromq_czmq_ZhttpRequest.c +++ b/bindings/jni/czmq-jni/src/main/c/org_zeromq_czmq_ZhttpRequest.c @@ -132,6 +132,22 @@ Java_org_zeromq_czmq_ZhttpRequest__1_1resetContent (JNIEnv *env, jclass c, jlong zhttp_request_reset_content ((zhttp_request_t *) (intptr_t) self); } +JNIEXPORT void JNICALL +Java_org_zeromq_czmq_ZhttpRequest__1_1setUsername (JNIEnv *env, jclass c, jlong self, jstring username) +{ + char *username_ = (char *) (*env)->GetStringUTFChars (env, username, NULL); + zhttp_request_set_username ((zhttp_request_t *) (intptr_t) self, username_); + (*env)->ReleaseStringUTFChars (env, username, username_); +} + +JNIEXPORT void JNICALL +Java_org_zeromq_czmq_ZhttpRequest__1_1setPassword (JNIEnv *env, jclass c, jlong self, jstring password) +{ + char *password_ = (char *) (*env)->GetStringUTFChars (env, password, NULL); + zhttp_request_set_password ((zhttp_request_t *) (intptr_t) self, password_); + (*env)->ReleaseStringUTFChars (env, password, password_); +} + JNIEXPORT jboolean JNICALL Java_org_zeromq_czmq_ZhttpRequest__1_1match (JNIEnv *env, jclass c, jlong self, jstring method, jstring path) { diff --git a/bindings/jni/czmq-jni/src/main/java/org/zeromq/czmq/ZhttpRequest.java b/bindings/jni/czmq-jni/src/main/java/org/zeromq/czmq/ZhttpRequest.java index 930a5b4a3..82ab02801 100644 --- a/bindings/jni/czmq-jni/src/main/java/org/zeromq/czmq/ZhttpRequest.java +++ b/bindings/jni/czmq-jni/src/main/java/org/zeromq/czmq/ZhttpRequest.java @@ -154,6 +154,20 @@ public void resetContent () { __resetContent (self); } /* + Set the request username + */ + native static void __setUsername (long self, String username); + public void setUsername (String username) { + __setUsername (self, username); + } + /* + Set the request password + */ + native static void __setPassword (long self, String password); + public void setPassword (String password) { + __setPassword (self, password); + } + /* Match the path of the request. Support wildcards with '%s' symbol inside the match string. Matching wildcards until the next '/', '?' or '\0'. diff --git a/bindings/lua_ffi/czmq_ffi.lua b/bindings/lua_ffi/czmq_ffi.lua index 8025e3466..15fdc8ac0 100644 --- a/bindings/lua_ffi/czmq_ffi.lua +++ b/bindings/lua_ffi/czmq_ffi.lua @@ -4534,6 +4534,14 @@ void void zhttp_request_reset_content (zhttp_request_t *self); +// Set the request username +void + zhttp_request_set_username (zhttp_request_t *self, const char *username); + +// Set the request password +void + zhttp_request_set_password (zhttp_request_t *self, const char *password); + // Match the path of the request. // Support wildcards with '%s' symbol inside the match string. // Matching wildcards until the next '/', '?' or '\0'. diff --git a/bindings/nodejs/README.md b/bindings/nodejs/README.md index 2e2368e86..4e729d0be 100644 --- a/bindings/nodejs/README.md +++ b/bindings/nodejs/README.md @@ -4952,6 +4952,18 @@ nothing my_zhttp_request.resetContent () Set the content to NULL +``` +nothing my_zhttp_request.setUsername (String) +``` + +Set the request username + +``` +nothing my_zhttp_request.setPassword (String) +``` + +Set the request password + ``` boolean my_zhttp_request.match (String, String) ``` diff --git a/bindings/nodejs/binding.cc b/bindings/nodejs/binding.cc index eb9c426e7..24e025e1e 100644 --- a/bindings/nodejs/binding.cc +++ b/bindings/nodejs/binding.cc @@ -9249,6 +9249,8 @@ NAN_MODULE_INIT (ZhttpRequest::Init) { Nan::SetPrototypeMethod (tpl, "setContent", _set_content); Nan::SetPrototypeMethod (tpl, "setContentConst", _set_content_const); Nan::SetPrototypeMethod (tpl, "resetContent", _reset_content); + Nan::SetPrototypeMethod (tpl, "setUsername", _set_username); + Nan::SetPrototypeMethod (tpl, "setPassword", _set_password); Nan::SetPrototypeMethod (tpl, "match", _match); Nan::SetPrototypeMethod (tpl, "test", _test); @@ -9416,6 +9418,36 @@ NAN_METHOD (ZhttpRequest::_reset_content) { zhttp_request_reset_content (zhttp_request->self); } +NAN_METHOD (ZhttpRequest::_set_username) { + ZhttpRequest *zhttp_request = Nan::ObjectWrap::Unwrap (info.Holder ()); + char *username; + if (info [0]->IsUndefined ()) + return Nan::ThrowTypeError ("method requires a `username`"); + else + if (!info [0]->IsString ()) + return Nan::ThrowTypeError ("`username` must be a string"); + //else { // bjornw: remove brackets to keep scope + Nan::Utf8String username_utf8 (info [0].As()); + username = *username_utf8; + //} //bjornw end + zhttp_request_set_username (zhttp_request->self, (const char *)username); +} + +NAN_METHOD (ZhttpRequest::_set_password) { + ZhttpRequest *zhttp_request = Nan::ObjectWrap::Unwrap (info.Holder ()); + char *password; + if (info [0]->IsUndefined ()) + return Nan::ThrowTypeError ("method requires a `password`"); + else + if (!info [0]->IsString ()) + return Nan::ThrowTypeError ("`password` must be a string"); + //else { // bjornw: remove brackets to keep scope + Nan::Utf8String password_utf8 (info [0].As()); + password = *password_utf8; + //} //bjornw end + zhttp_request_set_password (zhttp_request->self, (const char *)password); +} + NAN_METHOD (ZhttpRequest::_match) { ZhttpRequest *zhttp_request = Nan::ObjectWrap::Unwrap (info.Holder ()); char *method; diff --git a/bindings/nodejs/binding.h b/bindings/nodejs/binding.h index 82aa43a73..45d739ac3 100644 --- a/bindings/nodejs/binding.h +++ b/bindings/nodejs/binding.h @@ -1076,6 +1076,8 @@ class ZhttpRequest: public Nan::ObjectWrap { static NAN_METHOD (_set_content); static NAN_METHOD (_set_content_const); static NAN_METHOD (_reset_content); + static NAN_METHOD (_set_username); + static NAN_METHOD (_set_password); static NAN_METHOD (_match); static NAN_METHOD (_test); }; diff --git a/bindings/python/czmq/_czmq_ctypes.py b/bindings/python/czmq/_czmq_ctypes.py index 3aea44304..4c768f3bb 100644 --- a/bindings/python/czmq/_czmq_ctypes.py +++ b/bindings/python/czmq/_czmq_ctypes.py @@ -9190,6 +9190,10 @@ def test(verbose): lib.zhttp_request_set_content_const.argtypes = [zhttp_request_p, c_char_p] lib.zhttp_request_reset_content.restype = None lib.zhttp_request_reset_content.argtypes = [zhttp_request_p] +lib.zhttp_request_set_username.restype = None +lib.zhttp_request_set_username.argtypes = [zhttp_request_p, c_char_p] +lib.zhttp_request_set_password.restype = None +lib.zhttp_request_set_password.argtypes = [zhttp_request_p, c_char_p] lib.zhttp_request_match.restype = c_bool lib.zhttp_request_match.argtypes = [zhttp_request_p, c_char_p, c_char_p] lib.zhttp_request_test.restype = None @@ -9346,6 +9350,18 @@ def reset_content(self): """ return lib.zhttp_request_reset_content(self._as_parameter_) + def set_username(self, username): + """ + Set the request username + """ + return lib.zhttp_request_set_username(self._as_parameter_, username) + + def set_password(self, password): + """ + Set the request password + """ + return lib.zhttp_request_set_password(self._as_parameter_, password) + def match(self, method, path, *args): """ Match the path of the request. diff --git a/bindings/python_cffi/czmq_cffi/ZhttpRequest.py b/bindings/python_cffi/czmq_cffi/ZhttpRequest.py index 978e09dad..c60662865 100644 --- a/bindings/python_cffi/czmq_cffi/ZhttpRequest.py +++ b/bindings/python_cffi/czmq_cffi/ZhttpRequest.py @@ -127,6 +127,18 @@ def reset_content(self): """ utils.lib.zhttp_request_reset_content(self._p) + def set_username(self, username): + """ + Set the request username + """ + utils.lib.zhttp_request_set_username(self._p, utils.to_bytes(username)) + + def set_password(self, password): + """ + Set the request password + """ + utils.lib.zhttp_request_set_password(self._p, utils.to_bytes(password)) + def match(self, method, path, *path_args): """ Match the path of the request. diff --git a/bindings/python_cffi/czmq_cffi/cdefs.py b/bindings/python_cffi/czmq_cffi/cdefs.py index a87b7e5e0..71d96ef90 100644 --- a/bindings/python_cffi/czmq_cffi/cdefs.py +++ b/bindings/python_cffi/czmq_cffi/cdefs.py @@ -4541,6 +4541,14 @@ void zhttp_request_reset_content (zhttp_request_t *self); +// Set the request username +void + zhttp_request_set_username (zhttp_request_t *self, const char *username); + +// Set the request password +void + zhttp_request_set_password (zhttp_request_t *self, const char *password); + // Match the path of the request. // Support wildcards with '%s' symbol inside the match string. // Matching wildcards until the next '/', '?' or '\0'. diff --git a/bindings/qml/src/QmlZhttpRequest.cpp b/bindings/qml/src/QmlZhttpRequest.cpp index ad9fa3027..fb9ab3ec9 100644 --- a/bindings/qml/src/QmlZhttpRequest.cpp +++ b/bindings/qml/src/QmlZhttpRequest.cpp @@ -114,6 +114,18 @@ void QmlZhttpRequest::resetContent () { zhttp_request_reset_content (self); }; +/// +// Set the request username +void QmlZhttpRequest::setUsername (const QString &username) { + zhttp_request_set_username (self, username.toUtf8().data()); +}; + +/// +// Set the request password +void QmlZhttpRequest::setPassword (const QString &password) { + zhttp_request_set_password (self, password.toUtf8().data()); +}; + /// // Match the path of the request. // Support wildcards with '%s' symbol inside the match string. diff --git a/bindings/qml/src/QmlZhttpRequest.h b/bindings/qml/src/QmlZhttpRequest.h index 01eba1808..cdb9c8eb4 100644 --- a/bindings/qml/src/QmlZhttpRequest.h +++ b/bindings/qml/src/QmlZhttpRequest.h @@ -84,6 +84,12 @@ public slots: // Set the content to NULL void resetContent (); + // Set the request username + void setUsername (const QString &username); + + // Set the request password + void setPassword (const QString &password); + // Match the path of the request. // Support wildcards with '%s' symbol inside the match string. // Matching wildcards until the next '/', '?' or '\0'. diff --git a/bindings/qt/src/qzhttprequest.cpp b/bindings/qt/src/qzhttprequest.cpp index 50f0b2cdd..9610d24cc 100644 --- a/bindings/qt/src/qzhttprequest.cpp +++ b/bindings/qt/src/qzhttprequest.cpp @@ -152,6 +152,22 @@ void QZhttpRequest::resetContent () } +/// +// Set the request username +void QZhttpRequest::setUsername (const QString &username) +{ + zhttp_request_set_username (self, username.toUtf8().data()); + +} + +/// +// Set the request password +void QZhttpRequest::setPassword (const QString &password) +{ + zhttp_request_set_password (self, password.toUtf8().data()); + +} + /// // Self test of this class. void QZhttpRequest::test (bool verbose) diff --git a/bindings/qt/src/qzhttprequest.h b/bindings/qt/src/qzhttprequest.h index 2d5a58541..bc06536f1 100644 --- a/bindings/qt/src/qzhttprequest.h +++ b/bindings/qt/src/qzhttprequest.h @@ -74,6 +74,12 @@ class QT_CZMQ_EXPORT QZhttpRequest : public QObject // Set the content to NULL void resetContent (); + // Set the request username + void setUsername (const QString &username); + + // Set the request password + void setPassword (const QString &password); + // Self test of this class. static void test (bool verbose); diff --git a/bindings/ruby/lib/czmq/ffi.rb b/bindings/ruby/lib/czmq/ffi.rb index 54d927ef1..f1e1e8492 100644 --- a/bindings/ruby/lib/czmq/ffi.rb +++ b/bindings/ruby/lib/czmq/ffi.rb @@ -962,6 +962,8 @@ def self.attach_function(name, *rest) attach_function :zhttp_request_set_content, [:pointer, :pointer], :void, **opts attach_function :zhttp_request_set_content_const, [:pointer, :string], :void, **opts attach_function :zhttp_request_reset_content, [:pointer], :void, **opts + attach_function :zhttp_request_set_username, [:pointer, :string], :void, **opts + attach_function :zhttp_request_set_password, [:pointer, :string], :void, **opts attach_function :zhttp_request_match, [:pointer, :string, :string, :varargs], :bool, **opts attach_function :zhttp_request_test, [:bool], :void, **opts diff --git a/bindings/ruby/lib/czmq/ffi/zhttp_request.rb b/bindings/ruby/lib/czmq/ffi/zhttp_request.rb index 622a2aade..8e3b71766 100644 --- a/bindings/ruby/lib/czmq/ffi/zhttp_request.rb +++ b/bindings/ruby/lib/czmq/ffi/zhttp_request.rb @@ -269,6 +269,28 @@ def reset_content() result end + # Set the request username + # + # @param username [String, #to_s, nil] + # @return [void] + def set_username(username) + raise DestroyedError unless @ptr + self_p = @ptr + result = ::CZMQ::FFI.zhttp_request_set_username(self_p, username) + result + end + + # Set the request password + # + # @param password [String, #to_s, nil] + # @return [void] + def set_password(password) + raise DestroyedError unless @ptr + self_p = @ptr + result = ::CZMQ::FFI.zhttp_request_set_password(self_p, password) + result + end + # Match the path of the request. # Support wildcards with '%s' symbol inside the match string. # Matching wildcards until the next '/', '?' or '\0'.