Add function Mouth::send_soap_xml

This commit is contained in:
flyingscorpio@clevo 2023-01-08 14:01:08 +01:00
parent 8b848a6fc0
commit 24bd6e50ef

View file

@ -1,6 +1,6 @@
//! Holds the elements pertaining to Mouth, a sender object.
use std::{fmt::Display, io::Write, net::TcpStream};
use std::{fmt::Display, fs, io::Write, net::TcpStream};
use serde::Serialize;
use serde_json::Value;
@ -38,7 +38,15 @@ impl<'a> Mouth<'a> {
let contents = data.to_string();
let length = contents.len();
let response = format!("{status_code}\r\nContent-Type: application/json\r\nContent-Length: {length}\r\n\r\n{contents}");
self.stream.write_all(response.as_bytes()).unwrap();
}
/// Send response data in SOAP XML to a client.
fn send_soap_xml(&mut self) {
let status_code = Status::OK;
let contents = fs::read_to_string("soap/hello.xml").unwrap();
let length = contents.len();
let response = format!("{status_code}\r\nContent-Type: application/soap-xml\r\nContent-Length: {length}\r\n\r\n{contents}");
self.stream.write_all(response.as_bytes()).unwrap();
}