Add more specific error messages when receipt is not valid
parent
cabdb94a17
commit
97ab0bcdd2
7
stomp.c
7
stomp.c
|
@ -524,6 +524,7 @@ stomp_frame_t *stomp_read_frame(stomp_t *stomp)
|
||||||
*/
|
*/
|
||||||
int stomp_valid_receipt(stomp_t *stomp, stomp_frame_t *frame) {
|
int stomp_valid_receipt(stomp_t *stomp, stomp_frame_t *frame) {
|
||||||
int success = 1;
|
int success = 1;
|
||||||
|
char error[1024];
|
||||||
char *receipt = NULL;
|
char *receipt = NULL;
|
||||||
if (zend_hash_find(frame->headers, "receipt", sizeof("receipt"), (void **)&receipt) == SUCCESS) {
|
if (zend_hash_find(frame->headers, "receipt", sizeof("receipt"), (void **)&receipt) == SUCCESS) {
|
||||||
stomp_frame_t *res = stomp_read_frame(stomp);
|
stomp_frame_t *res = stomp_read_frame(stomp);
|
||||||
|
@ -535,12 +536,18 @@ int stomp_valid_receipt(stomp_t *stomp, stomp_frame_t *frame) {
|
||||||
&& strlen(receipt) == strlen(receipt_id)
|
&& strlen(receipt) == strlen(receipt_id)
|
||||||
&& !strcmp(receipt, receipt_id)) {
|
&& !strcmp(receipt, receipt_id)) {
|
||||||
success = 1;
|
success = 1;
|
||||||
|
} else {
|
||||||
|
snprintf(error, sizeof(error), "Unexpected receipt id : %s", receipt_id);
|
||||||
|
stomp_set_error(stomp, error, 0);
|
||||||
}
|
}
|
||||||
} else if (0 == strncmp("ERROR", res->command, sizeof("ERROR") - 1)) {
|
} else if (0 == strncmp("ERROR", res->command, sizeof("ERROR") - 1)) {
|
||||||
char *error_msg = NULL;
|
char *error_msg = NULL;
|
||||||
if (zend_hash_find(res->headers, "message", sizeof("message"), (void **)&error_msg) == SUCCESS) {
|
if (zend_hash_find(res->headers, "message", sizeof("message"), (void **)&error_msg) == SUCCESS) {
|
||||||
stomp_set_error(stomp, error_msg, 0);
|
stomp_set_error(stomp, error_msg, 0);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
snprintf(error, sizeof(error), "Receipt not received, unexpected command : %s", res->command);
|
||||||
|
stomp_set_error(stomp, error, 0);
|
||||||
}
|
}
|
||||||
stomp_free_frame(res);
|
stomp_free_frame(res);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue