[Issue #1221] Refactoring lock for HTTP error