Added condtionals so that the security provider fix only runs when
needed. Added a throw catch to reinsert the security provider even if
the http fails before resending the http