Implementing POST Servers
Implementing a POST server is similar to implementing a GET server. In fact, you may end up implementing them together in the same code for the sake of convenience. POST servers are handy if you need to send data to the server to be updated, as with form submissions. To serve a POST request, you need to implement code in the request handler that reads the contents of the post body out and processes the contents.
Once you have processed the data, you dynamically populate the data you want to send back to the client, write it out to the response, and then call end() to finalize the response and flush the Writable stream. Just as with a dynamic GET server, the output of a POST request may be a webpage, an HTTP snippet, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access