fixed bug: order of logging and sending in http