Skip to content

Commit 73e5385

Browse files
Set host header based on host URL instead of hardcoding it (#103)
* WIP * Generic solution * Bump version * Clippy * Cargo fmt
1 parent 958d4fd commit 73e5385

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "deepgram"
3-
version = "0.6.4"
3+
version = "0.6.5"
44
authors = ["Deepgram <[email protected]>"]
55
edition = "2021"
66
description = "Community Rust SDK for Deepgram's automated speech recognition APIs."

examples/speak/rest/text_to_speech_to_stream.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,13 @@ impl Linear16AudioSource {
4545
impl Buf for Linear16AudioSource {
4646
type Sample = i16;
4747

48-
type Channel<'this> = LinearChannel<'this, i16>
48+
type Channel<'this>
49+
= LinearChannel<'this, i16>
4950
where
5051
Self: 'this;
5152

52-
type IterChannels<'this> = std::vec::IntoIter<LinearChannel<'this, i16>>
53+
type IterChannels<'this>
54+
= std::vec::IntoIter<LinearChannel<'this, i16>>
5355
where
5456
Self: 'this;
5557

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl<'a> From<&'a Deepgram> for Speak<'a> {
7575
}
7676
}
7777

78-
impl<'a> Transcription<'a> {
78+
impl Transcription<'_> {
7979
/// Expose a method to access the inner `Deepgram` reference if needed.
8080
pub fn deepgram(&self) -> &Deepgram {
8181
self.0

src/listen/websocket.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ impl Transcription<'_> {
131131
///
132132
/// assert_eq!(&builder.urlencoded().unwrap(), "model=nova-2&detect_language=true&no_delay=true")
133133
/// ```
134-
135134
pub fn stream_request_with_options(&self, options: Options) -> WebsocketBuilder<'_> {
136135
WebsocketBuilder {
137136
deepgram: self.0,
@@ -166,7 +165,7 @@ impl Transcription<'_> {
166165
}
167166
}
168167

169-
impl<'a> WebsocketBuilder<'a> {
168+
impl WebsocketBuilder<'_> {
170169
/// Return the options in urlencoded format. If serialization would
171170
/// fail, this will also return an error.
172171
///
@@ -653,13 +652,14 @@ pub struct WebsocketHandle {
653652
impl<'a> WebsocketHandle {
654653
async fn new(builder: WebsocketBuilder<'a>) -> Result<WebsocketHandle> {
655654
let url = builder.as_url()?;
655+
let host = url.host_str().ok_or(DeepgramError::InvalidUrl)?;
656656

657657
let request = {
658658
let http_builder = Request::builder()
659659
.method("GET")
660660
.uri(url.to_string())
661661
.header("sec-websocket-key", client::generate_key())
662-
.header("host", "api.deepgram.com")
662+
.header("host", host)
663663
.header("connection", "upgrade")
664664
.header("upgrade", "websocket")
665665
.header("sec-websocket-version", "13");

0 commit comments

Comments
 (0)