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

new test: 100 continue #8

Open
Geal opened this issue Oct 3, 2018 · 1 comment
Open

new test: 100 continue #8

Geal opened this issue Oct 3, 2018 · 1 comment
Assignees
Labels

Comments

@Geal
Copy link
Member

Geal commented Oct 3, 2018

The 100 HTTP status code needs special handling, because the server will do a first validation and send a response, then the client will send the rest of the response. It can be used when the client wants to send a huge file but check authorization before sending the actual data.

References:
https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.1.1
https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/100

example server code:

const http = require('http');
const net = require('net');
const url = require('url');

const server = http.createServer()

// listen for checkContinue events
server.on('checkContinue', function(req, res) {
  console.log("check_continue")
  req.checkContinue = true;
  handlePostFile(req, res); // call express directly to route the request
});

// example request handler
function handlePostFile(req, res) {
  console.log("handle post file")


  // was this a conditional request?
  if (req.checkContinue === true) {
    req.checkContinue = false;
    // send 100 Continue response
    res.writeContinue();
    
    console.log("wrote continue");
    // client will now send us the request body
  }
  
  // collect request body
  var body = '';
  req.once('readable', function() {
    var chunk;
    console.log("readable()");

    while ((chunk = req.read()) !== null) {
      console.log("read");
      body += chunk;
    }

    // do something with request body
  });
}

server.listen(1029)
@NotBad4U
Copy link
Contributor

NotBad4U commented Oct 5, 2018

A WIP was made in 52fec49
For now, we only assert that we got a HTTP 200 status code on the second response.
The current HTTP client doesn't support multiple responses (100-continue) for a request. We have to find a HTTP client which support that and provide an API to make an assert on status code.

@NotBad4U NotBad4U self-assigned this Oct 5, 2018
@NotBad4U NotBad4U added the wip label Oct 5, 2018
@NotBad4U NotBad4U added this to the first test suite milestone Oct 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants