Git Product home page Git Product logo

node-cgi's People

Contributors

fidian avatar puffnfresh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-cgi's Issues

cgi.js change and issue - sys changed to util and listen error

Hi pufuwozu, i think the latest node.js may cause some issues for you.

  • node.js v0.5.10-pre changes sys to util but provides warning to that effect
  • more seriously and possbily related I'm getting and exception on the "this.listen" method where this is 'undefined'
    at [object Object].listen (/crosswiredigitalmedia.com/public/cgi.js:67:9)

hope this is useful
ngo

Request object should become a Readable Stream

I took your project out for a spin because I wanted to use node.js in a shared-host environment, and lured by the promise that I could just replace the http object with node-cgi, thought to try it out. I wrote a script that needed to handle POST data. And it didn't work.

After doing a bit of research on the problem, I learned that when the http object calls a listener, the request object it passes in is a Readable Stream; the stream contains the body of the request (if one is present). What node-cgi does is creates a property Object.

I got myself unstuck by rewriting Request in cgi.js:

var Request = function() {
    var req = process.stdin;
    req.method = process.env['REQUEST_METHOD'];
    req.headers = {
        'host': process.env['HTTP_HOST'],
        'user-agent': process.env['HTTP_USER_AGENT']
    };
    req.url = process.env['REQUEST_URI'];
    return req
};

That code shouldn't go into your cgi class as is without some more work. It's not obvious to me (yet) how to make a copy of process.stdin so that I could add other properties safely.

This code (as well as the original) also lacks all of the headers that might have been passed in from process.env. This would be problematic, for example, if I wanted to add Basic Auth support to my script.

Will you be spending some time making the Request object a bit more powerful?

Please list node-cgi in npm

Would you run npm publish in your node-cgi repo? I figure the author should be the one that publishes this library. Once that is done, I can just list it as a dependency in my project and a npm install will pull in this last library for me.

Thanks!

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.