2

Appear problem when I try to debug http response with default Ruby lib Net::HTTP

Example. I have such piece of code

url = URI.parse("http://nibbler.silktide.com/") # any http resource

req = Net::HTTP.get_response(url) # the same situation with get method of the Net::HTTP module

p req

I set breakpoint on the second line and try to execute it in the Interactive console and got "Timeout: evaluation took longer than 10 seconds."

But when I set breakpoint on the third line (or press F8 to make Step Over) I got correct value in req => #<Net::HTTPOK 200 OK readbody=true>

Why such situation appear? In such way I can't debug response in my code. Could anybody help me?

Environment:

OS - Ubuntu 16.04 x64

RubyMine version - 2017.2.4

Ruby version - 2.4.2p198

ruby-debug-ide (0.6.1.beta10)

Thank you in advance

1 Answers1

0

When you set up the break point in the second line the request has not been submitted yet. Set the break point in the third line and then open the "Evaluate Expression" window to run

req.code 
req.body
...

Or set them up as in the watches frame

Edit to respond to comment: If you evaluate req you get nil because it the request hasn't been submitted. If you copy paste and try to execute the entire line then you get the timeout message. The debugger has a single thread analyzing the http requests this way. In any case to "debug the http request" as you ask you need to place the breakpoint after the request has been submitted.

I hope this helps.

s1mpl3
  • 1,456
  • 1
  • 10
  • 14
  • yep. namely. this solution for my situation... But the main question was "Why second line I can't execute in Interactive console" – user2267897 Jan 18 '18 at 07:48
  • Thanks for your attention! Unfortunately with Ruby 1.9.3 and the same RubyMine version I can execute second line in Interactive Console. Only as you said I can use on current state ( – user2267897 Jan 18 '18 at 15:55