Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to read Content-type: text/plain data #293

Open
cinderblock opened this issue Mar 25, 2018 · 3 comments
Open

Is it possible to read Content-type: text/plain data #293

cinderblock opened this issue Mar 25, 2018 · 3 comments

Comments

@cinderblock
Copy link

Hello,

I've been searching around on this issue and haven't found a good answer. I hope I'm not doing something silly.

I have a simple program that periodically generates a block of text data and I need to pass that data to a meteor application and parse the weird text format there.

I'm using curl to send the data to my meteor server; something like: curl -d 'foo\nbar' -H 'Content-Type: text/plain' https://myserver/api/test. The problem is that in the request handler, this.bodyParams is always an empty object.

If other content types are used, restivus tries to parse the data but this doesn't always capture every byte. Notably, if Content-Type header is removed, curl defaults to application/x-www-form-urlencoded which is reversible for the simple example I provided, but not for other more complicated use cases.

Now, it is possible to get at the raw data with something like this: https://stackoverflow.com/questions/35857250/how-can-i-get-post-raw-body-in-meteor-restivus but that sure seems like a convoluted way to get the raw POST data. This is also not possible in my use case as the meteor app that I'm using doesn't expose the raw request object from restivus.

Would it be possible and make sense to add a text/plain parser?

@cinderblock
Copy link
Author

I just noticed #108. Unfortunately the this.request._readableState.buffer.toString() method seems to not work for me. I'm running node v8.5.0. I've seen discussions around changing _readableState as it's supposed to be private. Maybe behavior has changed?

@dkudrin
Copy link

dkudrin commented Apr 29, 2021

@cinderblock Hi! Sorry, have you found any solution? I'm struggling with the same issue.

@cinderblock
Copy link
Author

Gosh, I don't even remember why I was using meteor for... Sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants