def on_headers_complete(headers)
@response_code = @parser.status_code
@headers = headers
@decoder = BaseDecoder.new
if @response_code.to_i == 200
@network_reconnector.reset
@application_reconnector.reset
return
end
@reconnector = @application_reconnector
case @response_code
when 401 then invoke_callback(@client.unauthorized_callback)
when 403 then invoke_callback(@client.forbidden_callback)
when 404 then invoke_callback(@client.not_found_callback)
when 406 then invoke_callback(@client.not_acceptable_callback)
when 413 then invoke_callback(@client.too_long_callback)
when 416 then invoke_callback(@client.range_unacceptable_callback)
when 420 then invoke_callback(@client.enhance_your_calm_callback)
when 503 then invoke_callback(@client.service_unavailable_callback)
else
msg = "Unhandled status code: #{@response_code}."
invoke_callback(@client.error_callback, msg)
end
end