Git Product home page Git Product logo

Comments (4)

ioquatix avatar ioquatix commented on May 21, 2024

That makes sense.

from falcon.

ioquatix avatar ioquatix commented on May 21, 2024

We'd need to copy something like https://github.com/socketry/async-io/blob/c39a819204c18864f66f354f1e1034dab31e2874/lib/async/io/stream.rb#L74-L85

from falcon.

ioquatix avatar ioquatix commented on May 21, 2024

The specification for gets is completely insane:

gets(sep=$/ [, getline_args]) → string or nil click to toggle source
gets(limit [, getline_args]) → string or nil
gets(sep, limit [, getline_args]) → string or nil

Reads the next “line'' from the I/O stream; lines are separated by sep. A separator of nil reads the entire contents, and a zero-length separator reads the input a paragraph at a time (two successive newlines in the input separate paragraphs). The stream must be opened for reading or an IOError will be raised. The line read in will be returned and also assigned to $_. Returns nil if called at end of file. If the first argument is an integer, or optional second argument is given, the returning string would not be longer than the given value in bytes.

from falcon.

ioquatix avatar ioquatix commented on May 21, 2024

I started implementing this. It's a huge abomination.

Then, I wondered, what does the rack spec actually say?

https://www.rubydoc.info/github/rack/rack/master/file/SPEC#The_Input_Stream

The input stream is an IO-like object which contains the raw HTTP POST data. When applicable, its external encoding must be “ASCII-8BIT” and it must be opened in binary mode, for Ruby 1.9 compatibility. The input stream must respond to gets, each, read and rewind.

And specifically:

gets must be called without arguments and return a string, or nil on EOF.

It seems like a conforming implementation just needs to call #read, which is exactly what we are doing already.

Please discuss this if you think this interpretation is incorrect, because as I said, it would be good to get this right. But, implementing IO#gets is really nasty.

from falcon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.