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.
This commit is contained in:
Tibor Bősze 2016-03-02 19:35:06 +01:00 committed by Dave Collins
parent 0e71867dfe
commit 9799f0e547

View file

@ -4036,6 +4036,11 @@ func (s *rpcServer) jsonRPCRead(w http.ResponseWriter, r *http.Request, isAdmin
if _, err := buf.Write(msg); err != nil { if _, err := buf.Write(msg); err != nil {
rpcsLog.Errorf("Failed to write marshalled reply: %v", err) 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. // jsonAuthFail sends a message back to the client if the http auth is rejected.