lib/billy/handlers/cache_handler.rb in puffing-billy-0.9.2 vs lib/billy/handlers/cache_handler.rb in puffing-billy-0.10.0

- old
+ new

@@ -28,10 +28,14 @@ if Billy.config.after_cache_handles_request request = { method: method, url: url, headers: headers, body: body } Billy.config.after_cache_handles_request.call(request, response) end + if Billy.config.cache_simulates_network_delays + Kernel.sleep(Billy.config.cache_simulates_network_delay_time) + end + return response end end nil end @@ -44,11 +48,12 @@ def replace_response_callback(response, url) request_uri = Addressable::URI.parse(url) if request_uri.query params = CGI.parse(request_uri.query) - if params['callback'].any? && response[:content].match(/\w+\(/) - response[:content].sub!(/\w+\(/, params['callback'].first + '(') + callback_name = Billy.config.dynamic_jsonp_callback_name + if params[callback_name].any? && response[:content].match(/\w+\(/) + response[:content].sub!(/\w+\(/, params[callback_name].first + '(') end end end end end