@@ -350,18 +350,26 @@ protected function write()
350
350
*/
351
351
protected function authResponse (MethodConnectionStartFrame $ start )
352
352
{
353
- if (strpos ($ start ->mechanisms , "AMQPLAIN " ) === false ) {
354
- throw new ClientException ("Server does not support AMQPLAIN mechanism (supported: {$ start ->mechanisms }). " );
353
+ if (strpos ($ start ->mechanisms , "AMQPLAIN " ) !== false ) {
354
+ $ responseBuffer = new Buffer ();
355
+ $ this ->writer ->appendTable ([
356
+ "LOGIN " => $ this ->options ["user " ],
357
+ "PASSWORD " => $ this ->options ["password " ],
358
+ ], $ responseBuffer );
359
+ $ responseBuffer ->discard (4 );
360
+
361
+ return $ this ->connectionStartOk ([], "AMQPLAIN " , $ responseBuffer ->read ($ responseBuffer ->getLength ()), "en_US " );
362
+ } else if (strpos ($ start ->mechanisms , "PLAIN " ) !== false ) {
363
+ $ responseBuffer = new Buffer ();
364
+ $ responseBuffer ->appendUint8 (0 );
365
+ $ responseBuffer ->append ($ this ->options ["user " ]);
366
+ $ responseBuffer ->appendUint8 (0 );
367
+ $ responseBuffer ->append ($ this ->options ["password " ]);
368
+
369
+ return $ this ->connectionStartOk ([], "PLAIN " , $ responseBuffer ->read ($ responseBuffer ->getLength ()), "en_US " );
355
370
}
356
371
357
- $ responseBuffer = new Buffer ();
358
- $ this ->writer ->appendTable ([
359
- "LOGIN " => $ this ->options ["user " ],
360
- "PASSWORD " => $ this ->options ["password " ],
361
- ], $ responseBuffer );
362
- $ responseBuffer ->discard (4 );
363
-
364
- return $ this ->connectionStartOk ($ this ->options ['client_properties ' ], "AMQPLAIN " , $ responseBuffer ->read ($ responseBuffer ->getLength ()), "en_US " );
372
+ throw new ClientException ("Server does not support either AMQPLAIN or PLAIN mechanism (supported: {$ start ->mechanisms }). " );
365
373
}
366
374
367
375
/**
0 commit comments