GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Standardize an HTTP Server as a Transform · Issue #186 · nodejs/node

Standardize an HTTP Server as a Transform  #186

New issue
Copy link
New issue
Copy link
Closed
Closed
Standardize an HTTP Server as a Transform #186
olegnn/node
#29
(+2)
Copy link

Description

@formula1
formula1
opened on Dec 20, 2014
Issue body actions

This is a low priority enhancement. But I do believe this is important in general to set a standard. That being said, the http server spans about... 8 different files with a collective 2661 lines (120+145+498+624+198+228+572+276) (some of which is repeated such as http and https). So I completely understand that this idea is going to be taken lightly if not ignored completely. However, seeing from the last TC meeting, you guys really are paying attention. And it warms my icy cold heart.

The problem

Nodejs already set the standard for using stream.Transform in servers, don't.

It can only be found in Crypto and zlib within the source

However, the nodejs implementers guide suggests using the transform for protocols. I'm not here to complain about hipocracy as much as I'm here to complain about how because node didn't lead by example others didn't follow and understand why it wasn't implemented that way.

Consequences

  • tutorials don't teach using transforms
  • The WebSocket Server almost all other WebSocket based servers require does not implement it
  • A Proof of concept Stun Server also does not implement it
  • A common multipart data parser doesn't use a transform
  • Inability to pass these types of socket wrappers and others between processes
  • people not seeing Transforms useful

Other solutions

  • List all transforms that would be nice to have. This will give a hobby for anyone interested in it especially since almost every protocol is specified by w3 (I'm actually slightly interested after my recent work) (Also the most realistic)
  • Specify that transformations for protocols aren't necessary and hardly ever used including within yours/nodes own framework so people don't believe whats on nodejs.org (That is kindof a joke)
  • Giving the ability to send circular logic through child_process (That is kind of a joke)

Psuedocode

function onConnection(socket){
  var res = new httpResponder();
  var req = new httpRequestor();
  res.pipe(socketconnection).pipe(req);
  dostuff(req,res);
}

function dostuff(req,res){
  req.on("error", res.send.bind(res,500));
  req.on("head", function(head){
    authenticateHead(req,res,function(err,bool){
      if(err){
        req.close();
        res.send(500,err);
      });
    });
    if(req.method == get){
      this.dogetstuff(req).pipe(res);
    }
  });
  req.on("body", function(body){
    body.pipe(parser).pipe(this.dobodystuff(req)).pipe(res)
  });
  req.on("part", function(part){
    part.pipe(handlePart).pipe(this.dopartstuff(req)).pipe(res)
  });
}

function sendSocket(req,res,socket,child){
  socket.pause();
  child.send({req:req.export(),res:res.export()}, socket);
}
//Exports closes the stream, sends buffer, state and data the transform wants to send

function implementSocket(data,socket,next){
  res = httpResponder.import(data.res);
  req = httpRequestor.import(data.req,);
  res.pipe(socket).pipe(req);
  socket.resume();
  next(req,res,socket);
}
//imports picks up on the state where it was left off, sets the buffer and sets the current data

Some related Lines

  • https://github.com/iojs/io.js/blob/v0.12/lib/_http_server.js#L241 - Where its obvious node creates a Server
  • https://github.com/iojs/io.js/blob/v0.12/lib/child_process.js#L427 - Where its checking the type of handle to send between processes

Activity

  1. formula1 commented on Dec 20, 2014

    @formula1
    formula1
    on Dec 20, 2014
    Author
    More actions

    This may be more appropiate for Node Forward than here

  2. formula1
    closed this as completedon Dec 20, 2014
  3. syg
    added a commit that references this issue on Jun 20, 2024

    Make test-http-server-keepalive-req-gc robust to GC heuristics (nodej…

    00b17b5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.