Skip to content

Commit ae8d1f2

Browse files
refactor: remove dead code
1 parent 166b231 commit ae8d1f2

6 files changed

Lines changed: 2 additions & 52 deletions

File tree

rust/src/napi/body.rs

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::store::body_store::{cancel_body, read_body_all, read_body_chunk};
1+
use crate::store::body_store::{cancel_body, read_body_chunk};
22
use neon::prelude::*;
33
use neon::types::JsBuffer;
44

@@ -32,32 +32,13 @@ fn read_body_chunk_js(mut cx: FunctionContext) -> JsResult<JsPromise> {
3232
Ok(promise)
3333
}
3434

35-
fn read_body_all_js(mut cx: FunctionContext) -> JsResult<JsPromise> {
36-
let handle = cx.argument::<JsNumber>(0)?.value(&mut cx) as u64;
37-
38-
let channel = cx.channel();
39-
let (deferred, promise) = cx.promise();
40-
41-
std::thread::spawn(move || {
42-
let result = read_body_all(handle);
43-
44-
deferred.settle_with(&channel, move |mut cx| match result {
45-
Ok(bytes) => JsBuffer::from_slice(&mut cx, &bytes),
46-
Err(error) => cx.throw_error(format!("{:#}", error)),
47-
});
48-
});
49-
50-
Ok(promise)
51-
}
52-
5335
fn cancel_body_js(mut cx: FunctionContext) -> JsResult<JsBoolean> {
5436
let handle = cx.argument::<JsNumber>(0)?.value(&mut cx) as u64;
5537
Ok(cx.boolean(cancel_body(handle)))
5638
}
5739

5840
pub fn register(cx: &mut ModuleContext) -> NeonResult<()> {
5941
cx.export_function("readBodyChunk", read_body_chunk_js)?;
60-
cx.export_function("readBodyAll", read_body_all_js)?;
6142
cx.export_function("cancelBody", cancel_body_js)?;
6243
Ok(())
6344
}

rust/src/store/body_store.rs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -65,28 +65,6 @@ pub fn read_body_chunk(handle: u64, _size: usize) -> Result<(Vec<u8>, bool)> {
6565
Ok((chunk.to_vec(), false))
6666
}
6767

68-
pub fn read_body_all(handle: u64) -> Result<Vec<u8>> {
69-
let Some(body) = remove_body(handle) else {
70-
return Err(anyhow::anyhow!("Unknown body handle: {}", handle));
71-
};
72-
73-
runtime().block_on(async move {
74-
let mut body = body.lock().await;
75-
let mut bytes = Vec::new();
76-
77-
while let Some(chunk) = body
78-
.response
79-
.chunk()
80-
.await
81-
.context("Failed to read response body chunk")?
82-
{
83-
bytes.extend_from_slice(&chunk);
84-
}
85-
86-
Ok::<Vec<u8>, anyhow::Error>(bytes)
87-
})
88-
}
89-
9068
pub fn cancel_body(handle: u64) -> bool {
9169
remove_body(handle).is_some()
9270
}

src/http/request.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,3 @@ export class Request {
228228
return this.#readBodyBytes();
229229
}
230230
}
231-
232-
export function isWreqRequest(value: unknown): value is Request {
233-
return value instanceof Request;
234-
}

src/native/binding.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export type NativeBinding = {
2626
chunk: Buffer;
2727
done: boolean;
2828
}>;
29-
readBodyAll: (handle: number) => Promise<Buffer>;
3029
cancelBody: (handle: number) => boolean;
3130
getProfiles: () => string[];
3231
};

src/native/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export { normalizeMethod } from './methods';
22
export { getProfiles, validateBrowserProfile } from './profiles';
3-
export { nativeCancelBody, nativeReadBodyAll, nativeReadBodyChunk, nativeRequest } from './request';
3+
export { nativeCancelBody, nativeReadBodyChunk, nativeRequest } from './request';
44
export {
55
nativeWebSocketClose,
66
nativeWebSocketConnect,

src/native/request.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,6 @@ export async function nativeReadBodyChunk(
6969
return getBinding().readBodyChunk(handle, size);
7070
}
7171

72-
export async function nativeReadBodyAll(handle: number): Promise<Uint8Array> {
73-
return getBinding().readBodyAll(handle);
74-
}
75-
7672
export function nativeCancelBody(handle: number): boolean {
7773
return getBinding().cancelBody(handle);
7874
}

0 commit comments

Comments
 (0)