From 0cd3e28b226dc0f9d86935b972526df39e3150a1 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Wed, 22 Dec 2021 13:02:53 +0100 Subject: [PATCH] Use get_epp_response() to read initial greeting --- src/connection.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/connection.rs b/src/connection.rs index dc366da..406499b 100644 --- a/src/connection.rs +++ b/src/connection.rs @@ -16,17 +16,15 @@ pub(crate) struct EppConnection { } impl EppConnection { - pub(crate) async fn new(registry: String, mut stream: IO) -> Result { - let mut buf = vec![0u8; 4096]; - stream.read(&mut buf).await?; - let greeting = str::from_utf8(&buf[4..])?.to_string(); - debug!("{}: greeting: {}", registry, greeting); - - Ok(Self { + pub(crate) async fn new(registry: String, stream: IO) -> Result { + let mut this = Self { registry, stream, - greeting, - }) + greeting: String::new(), + }; + + this.greeting = this.get_epp_response().await?; + Ok(this) } /// Constructs an EPP XML request in the required form and sends it to the server