Changed code for work with HTTP protocol