The curious case of …http status code 505
Today I learned that there was such a thing as http status code 505. Well, I’ve been in software development for quite some time, but 505 was a new for me.
TL; DR;
There was a space in the URL and this results in an error 505
Details
The curious case started with an error when we were checking that some links on the platform are valid. This is what happened:
Message: "Error: The link https://www.fllcasts.com/competitions/ returned status code 505!
Error: The link https://www.fllcasts.com/competitions/ returned status code 505!
Error: The link http://www.fllcasts.com/courses/19-moving-straight-with-lego-mindstorms-ev3-robots returned status code 505!
Error: The link http://www.fllcasts.com/courses/6-box-robot-two-fewer-parts-and-one-motor-simplifying-a-robot returned status code 505! "
Strange. A quick curl revealed that the url was correct and curl was returning a correct result. wget also showed that it is working.
It took me about one hour. One hour looking and the problem was the following:
When the HTML document was constructed it had the following content
<a href="{{ competitions_link }} "><img..
Note the space. The space after }} and before “. The space right here <a href=”{{ competitions_link }}HERE”>. This took an hour today. And the solution is just to strip.
Test
If interested here is the test for this problem:
it "strips url and then checks them to avoid error 505" do
link = ' https://www.fllcasts.com '
stub_request(:head, "https://www.fllcasts.com").to_return(status: 201)
success, message = UrlChecker::check_link link, true
expect(success).to be_truthy
expect(message).to be_empty
end
Reply
You must be logged in to post a comment.