Fix Bug #68497 Stomp client doesn't parse ERROR response on CONNECT

v1.1
Lorenzo Fontana 2014-12-02 19:28:20 +01:00
parent beb86e70fe
commit 8e18eb079d
3 changed files with 54 additions and 1 deletions

28
.gitignore vendored Normal file
View File

@ -0,0 +1,28 @@
.deps
.libs/
Makefile
Makefile.fragments
Makefile.global
Makefile.objects
acinclude.m4
aclocal.m4
autom4te.cache/
config.guess
config.h
config.h.in
config.log
config.nice
config.status
config.sub
configure
configure.in
install-sh
libtool
ltmain.sh
missing
mkinstalldirs
modules/
php_stomp.lo
run-tests.php
stomp.la
stomp.lo

View File

@ -538,11 +538,22 @@ PHP_FUNCTION(stomp_connect)
stomp_send(stomp, &frame TSRMLS_CC);
CLEAR_FRAME(frame);
/* Retreive Response */
res = stomp_read_frame(stomp);
if (NULL == res) {
STOMP_ERROR(0, PHP_STOMP_ERR_SERVER_NOT_RESPONDING);
} else if (0 == strncmp("ERROR", res->command, sizeof("ERROR") - 1)) {
char *error_msg = NULL;
if (zend_hash_find(res->headers, "message", sizeof("message"), (void **)&error_msg) == SUCCESS) {
zval *excobj = zend_throw_exception_ex(stomp_ce_exception, 0 TSRMLS_CC, error_msg);
if (res->body) {
zend_update_property_string(stomp_ce_exception, excobj, "details", sizeof("details")-1, (char *) res->body TSRMLS_CC);
}
stomp_free_frame(res);
RETURN_FALSE;
}
} else if (0 != strncmp("CONNECTED", res->command, sizeof("CONNECTED")-1)) {
if (stomp->error) {
STOMP_ERROR_DETAILS(stomp->errnum, stomp->error, stomp->error_details);

View File

@ -0,0 +1,14 @@
--TEST--
Test stomp_connect() - Test error on CONNECT
--SKIPIF--
<?php if (!extension_loaded("stomp")) print "skip"; ?>
--FILE--
<?php
try {
$stomp = new Stomp('tcp://localhost', 'anotpresentusername1234');
} catch (Exception $e) {
var_dump(get_class($e));
}
?>
--EXPECTF--
string(14) "StompException"