Tag: http

Docker HTTP-requests between containers

I’m at the first stage in learning how to use Docker so I’m trying basic things. I’ve created two Node Express services that need to exchange data via HTTP-requests. My docker-compose.yml file networks: isolation-network: driver: bridge services: service1-nodejs: build: context: ./service1/ dockerfile: .docker/node.dockerfile ports: – “10000:9000” – “10001:5858” env_file: ./service1/.docker/env/app.${APP_ENV}.env networks: – isolation-network service2-nodejs: build: […]

how to forward http request in node js

I want to take the a request, forward it to another url and return the result of the forwared request. This is my code: const http = require(‘http’), server = http.createServer().listen(3000); const baseUrl = ‘foo.bar’; server.on(‘request’, (req, res) => { req.headers.host = baseUrl; var connector = http.request(req, (resp) => { resp.pipe(res); }); req.pipe(connector); }); Sadly, […]

Node.js – controlling the size of a POST request

I have a program in Node.JS, using Express. When I do a POST request to this program, what is the maximum accepted size for the data in the request? Is there any way to set this size?

Reusing TCP connection on Node.js HTTP Server

I am using a http.Serverobject of the default http module (-> API). If a client connects the request event is emmited by the server and a http.ServerRequestobject is passed to the event handler. That request object emits the following three events: data (incoming data) end (request ended) close (connection closed) I want to keep the […]

Node.JS: What is the correct way to handle postdata read errors?

If the ServerRequest object emits an error event, that means that the postdata could not be fully received, most likely due to a network failure. This type of network failure is most likely terminal in both directions, right? So, how should I right my code? I could say res.writeHead(400); res.end() But is there a smarter […]

Node.js HTTPS proxy server not working

I would like to create a proxy for HTTPS connections with Node.js. I am using the http-proxy library, which works well. I can get a HTTP proxy to work perfectly, but when I try HTTPS, the request to the proxy just times out. Here is my code (a slightly modified version of the node-http-proxy proxy-https-to-https […]

How to cancel an incoming POST request in NodeJS sending a 4XX but without receiving the entire data?

A client can upload files to my NodeJS server. I want to make sure the client does not abuse the server and upload files that are too large. Therefore I want to cancel the request as soon as I detect a problem, but also return a meaningful status code and response to the client. Assume […]

How to check NTLM type3 message? (node.js)

I want to write a http server with node.js that supports NTLMv2 authentication. Evertything works fine with the handshak (type1, type2, type3 messages) and I get my type3-message from the client (Chrome Browser). In this message that is being sent to the server there is a ntlmv2 response that I can read within my node.js […]

Node.js app continuously consume memory without freeing it

I’m facing a weird situation. I wrote an application that is performing a HTTP GET request every five minutes. Something like this: // pingy ‘use strict’; var https = require(‘https’), url = require(‘url’); exports.ping = function ping (callback) { var options = url.parse(‘https://host.tld/ping’); callback = callback || function () {}; https.get(options, function handler (response) { […]

Node.js HTTP GET request content type

I am trying to do a GET request from node.js. This request is to a REST server which will access Hbase and return the data. The GET request contains all necessary Hbase info (table, key, column-family etc.) in it. Following is the code. var http = require(‘http’); var url = { host: ‘’, port: 8000, […]

Node.js is the Best Javascript runtime in the world.