Fix potential headers-first NPE race