sindresorhus / got

🌐 Human-friendly and powerful HTTP request library for Node.js
MIT License
14.27k stars 935 forks source link

Get an empty body or zero length rawBody in some case #1251

Closed fengkx closed 4 years ago

fengkx commented 4 years ago

Describe the bug

Actual behavior

Get an empty body or zero length body

Expected behavior

Get the actual body

Code to reproduce

https://runkit.com/embed/tyzrkbthl3bs

Checklist

Giotino commented 4 years ago

Related to #1234

Got 11 transform http://www.newsmth.net/rss.php?mPicture into http://www.newsmth.net/rss.php?mPicture= which body is empty

Giotino commented 4 years ago

As suggested by @cookch10 this is a temporary workaround

const url = new URL('http://www.newsmth.net/rss.php?mPicture');
const _search = url.search;
Object.defineProperty(url, 'search', {
  get() {
    return _search;
  },
  set() {
  }
});

;(async () => {
    const resp = await got.get(url);
    console.log(resp);
})()
szmarczak commented 4 years ago

Duplicate of #1234