SERVER-14268: Improve server message parsing

(cherry picked from commit dac9ac4a46348a67296b8b3ff11c58e522bd1b0b)
Merge remote-tracking branch 'upstream/v2.6' into v2.6