Skip to content

Commit

Permalink
Fix bug where duplicated Send tab would stop syncing headers
Browse files Browse the repository at this point in the history
This meant if you duplicated a tab with a body and correct
content-length field, they'd go out of sync.
  • Loading branch information
pimterry committed Nov 20, 2024
1 parent 5ddef60 commit 291715c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/send/send-tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export const SendTabs = observer((props: {
{
type: 'option',
label: 'Duplicate Tab',
callback: () => props.onAddTab(_.cloneDeep(request.request))
callback: () => props.onAddTab(new RequestInput(request.request))
},
{
type: 'option',
Expand Down
9 changes: 7 additions & 2 deletions src/model/send/send-request-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class RequestInput {
url: string,
headers: RawHeaders,
requestContentType: EditableContentType,
rawBody: Buffer
rawBody: Buffer | EditableBody
}
) {
// When deserializing, we need to ensure the body is provided directly
Expand All @@ -49,8 +49,13 @@ export class RequestInput {
this.url = existingData.url;
this.headers = existingData.headers;
this.requestContentType = existingData.requestContentType;

const rawBody = existingData.rawBody instanceof EditableBody
? existingData.rawBody.decoded
: existingData.rawBody;

this.rawBody = new EditableBody(
existingData.rawBody,
rawBody,
undefined,
() => this.headers
);
Expand Down

0 comments on commit 291715c

Please sign in to comment.