pact-mock_service icon indicating copy to clipboard operation
pact-mock_service copied to clipboard

Raise/assume status code to be 200 if status code is not specified?

Open ivan-kolmychek opened this issue 9 years ago • 2 comments

I'm not sure where to post it - I encountered it when used pact + pact-mock_service, so, I've decided to post it here.

When you accidentaly forget to specify status response option you can get strange result with Net::HTTP:

Net::HTTPBadResponse:
       wrong status line: "HTTP/1.1 0  "

I see such possible solutions:

  • raise an exception if status is not specified - it would be nice because error message can explicitly say "you forgot the status code" instead of assuming it as 0
  • or assume it to be 200 - it's the most common expected response code IMO;

ivan-kolmychek avatar Jun 02 '15 12:06 ivan-kolmychek

I think an error would be best, assumptions can be dangerous.

bethesque avatar Jun 16 '15 05:06 bethesque

@bethesque I agree - it's better to explicitly point to this error instead of assuming anything (0 or 200), but I just wanted to present other possible solution I've thought about anyway.

ivan-kolmychek avatar Jun 16 '15 07:06 ivan-kolmychek