From 9799f0e547c59ff7090bfd0a718ff345334adbb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tibor=20B=C5=91sze?= Date: Wed, 2 Mar 2016 19:35:06 +0100 Subject: [PATCH] rpcserver: Improve JSON-RPC compatibility In order to avoid compatibility issues with software relying on Core's behavior, terminate HTTP POST JSON-RPC responses with a newline. --- rpcserver.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rpcserver.go b/rpcserver.go index 44ab3170..4f7a1e6c 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -4036,6 +4036,11 @@ func (s *rpcServer) jsonRPCRead(w http.ResponseWriter, r *http.Request, isAdmin if _, err := buf.Write(msg); err != nil { rpcsLog.Errorf("Failed to write marshalled reply: %v", err) } + + // Terminate with newline to maintain compatibility with Bitcoin Core. + if err := buf.WriteByte('\n'); err != nil { + rpcsLog.Errorf("Failed to append terminating newline to reply: %v", err) + } } // jsonAuthFail sends a message back to the client if the http auth is rejected.