koajs / bodyparser

Koa body parsing middleware
MIT License
1.31k stars 116 forks source link

raw-body doesn't seem to work #73

Closed felixsanz closed 5 years ago

felixsanz commented 7 years ago

I parsed the body and it works, but if i dump the rawBody i get nothing.

the order was:

  1. middleware
  2. console log body <- works
  3. console log rawBody <- nothing
dead-horse commented 7 years ago

can you provide the version and the minimum reproduce code?

dead-horse commented 7 years ago

it is ok in the test case: https://github.com/koajs/bodyparser/blob/master/test/middleware.test.js#L39

felixsanz commented 7 years ago

The version is latest, 4.2.0.

The code... I sent a string compressed with gzip to koa, and the body had the string decompressed, but the rawBody had nothing (console.log it was giving me an empty new line). I was expecting a buffer (raw bytes of the compressed body)

i5ting commented 7 years ago

it will happen when no enableTypes matched in koa-bodyparser module

rlataguerra commented 7 years ago

@i5ting do you think its normal ? If for some reason bodyparser cant parse a format, why would it doesnt put it inside rawBody ?

ralyodio commented 5 years ago

I'm also getting undefined for rawBody.

DMXL commented 5 years ago

Same here. Parsed result was correctly presented, which means one of the enableTypes was hit, right?

libook commented 5 years ago

Happens to me.

I found that the request body is text; and the parser doesn't process text on default.

The parser provided "enableTypes" option so that I can let it process text body.

app.use(bodyParser({
        "enableTypes": ['json', 'form', 'text'],
    }));