1) Fix race condition in AppendableByteArrayInputStream.
2) Fix port setting on Host header