Skip to content

OPTIONS stream request requires an empty body to finish successfullyΒ #2394

@alexey-yarmosh

Description

@alexey-yarmosh

Describe the bug

  • Node.js version: 22.12.0
  • OS & version: macOS 15.1.1

OPTIONS stream request requires body: '' to finish the request successfully.

const str = got.stream('https://www.jsdelivr.com', {
  "method": "OPTIONS",
  "body": '', // `RequestError: socket hang up` without that parameter.
});

Actual behavior

Either RequestError: socket hang up, or unnecessary body: '' should be passed.

Expected behavior

Should work fine without body: '' since OPTIONS request doesn't have body.

Code to reproduce

const str = got.stream('https://www.jsdelivr.com', {
  "method": "OPTIONS",
});

str.on('socket', () => { console.log('socket'); });

str.on('end', () => { console.log('end'); });

str.on('retry', (...args) => { console.log('retry', ...args); });

Checklist

  • I have read the documentation.
  • I have tried my code with the latest version of Node.js and Got.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions