Graceful shutdown of a node.JS HTTP server

You can control the idle timeout for a connection, so you can set how long a keep-alive connection will remain open. For example: server=require(‘http’).createServer(function(req,res) { //Respond if(req.url.match(/^\/end.*/)) { server.close(); res.writeHead(200,{‘Content-Type’:’text/plain’}); res.end(‘Closedown’); } else { res.writeHead(200,{‘Content-Type’:’text/plain’}); res.end(‘Hello World!’); } }).listen(1088); //Set the idle timeout on any new connection server.addListener(“connection”,function(stream) { stream.setTimeout(4000); }); We can test this … Read more

Is Content-Type mandatory in HTTP post request?

No, it’s not mandatory. Per the HTTP 1.1 specification: Any HTTP/1.1 message containing an entity-body SHOULD include a Content-Type header field defining the media type of that body. If and only if the media type is not given by a Content-Type field, the recipient MAY attempt to guess the media type via inspection of its … Read more

How is HttpContext TraceIdentifier generated in .NET Core?

Kestrel generates the request ID as {ConnectionId}:{Request number}. The connection id is the base32 encoded version of a long using the alphabet 1-9, and A – V. The request count is the number of requests over that connection. The nth request over a specific connection is {ConnectionId}:{n} https://github.com/aspnet/KestrelHttpServer/blob/a48222378b8249a26b093b5b835001c7c7b45815/src/Kestrel.Core/Internal/Infrastructure/CorrelationIdGenerator.cs https://github.com/aspnet/KestrelHttpServer/blob/0aff4a0440c2f393c0b98e9046a8e66e30a56cb0/src/Kestrel.Core/Internal/Http/Http1Connection.cs#L446

Problem using NSURLRequest to POST data to server

You should remove the leading & in myRequestString and the problem is likely that the correct content-type header is not being sent. Try adding a call to [request setValue:@”application/x-www-form-urlencoded” forHTTPHeaderField:@”content-type”]; You should also not pass nil for error, so you can see what the client thinks is going on. Unrelated, but your PHP code is … Read more

Send error message as JSON object

From the HttpServletResponse#sendError() javadoc: The server defaults to creating the response to look like an HTML-formatted server error page containing the specified message, setting the content type to “text/html”, leaving cookies and other headers unmodified. If an error-page declaration has been made for the web application corresponding to the status code passed in, it will … Read more