Restart input stream on retried request

Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com>
This commit is contained in:
automated-signal 2024-07-11 17:59:40 -05:00 committed by GitHub
parent 87f7203141
commit 45425c158d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View file

@ -169,7 +169,7 @@ type PromiseAjaxOptionsType = {
basicAuth?: string;
certificateAuthority?: string;
contentType?: string;
data?: Uint8Array | Readable | string;
data?: Uint8Array | (() => Readable) | string;
disableRetries?: boolean;
disableSessionResumption?: boolean;
headers?: HeaderListType;
@ -299,7 +299,7 @@ async function getFetchOptions(
const fetchOptions = {
method: options.type,
body: options.data,
body: typeof options.data === 'function' ? options.data() : options.data,
headers: {
'User-Agent': getUserAgent(options.version),
'X-Signal-Agent': 'OWD',
@ -1303,7 +1303,7 @@ export type WebAPIType = {
elements: VerifyServiceIdRequestType
) => Promise<VerifyServiceIdResponseType>;
putEncryptedAttachment: (
encryptedBin: Uint8Array | Readable,
encryptedBin: Uint8Array | (() => Readable),
uploadForm: AttachmentV3ResponseType
) => Promise<void>;
putProfile: (
@ -3530,7 +3530,7 @@ export function initialize({
}
async function putEncryptedAttachment(
encryptedBin: Uint8Array | Readable,
encryptedBin: Uint8Array | (() => Readable),
uploadForm: AttachmentV3ResponseType
) {
const { signedUploadLocation, headers } = uploadForm;

View file

@ -146,7 +146,7 @@ export async function uploadFile({
});
} else {
await server.putEncryptedAttachment(
createReadStream(absoluteCiphertextPath),
() => createReadStream(absoluteCiphertextPath),
uploadForm
);
}