Apolo
Apolo

Reputation: 4050

I get HTTP 500 and HTML content, what's wrong?

When I got on this page (same with lots of articles on this website) : http://thereasonmag.com/9231-2/

I get an error HTTP 500 (see in the Chrome Dev Tools) AND the article.

Well, I'm a bit lost with this. Do you know why it is designed like this ?

That's a problem for my crawler which is designed to avoid processing HTTP 5xx error responses.

Upvotes: 0

Views: 42

Answers (2)

Gomes
Gomes

Reputation: 3330

1) Looks it is an expected behavior since PHP version 5.2.4.

2) The above url is using X-Powered-By: PHP/5.4.45 (wordpress app)

3) root cause could be,one of the wordpress plugin in the above site is having wrong string thatt ph eval() could not parse it.

4) more info look at the link a) wordpress discussion

5) from ph forum

Finally, i don't think so you can do anything here.

Upvotes: 1

aprok
aprok

Reputation: 1157

I would say that this is hardly can be called "designed" and possible when somebody has an error in backend code/logic. Actually this is the first time I see anything like this, but I can think only of workaround for you in this case.

Because this response has 500 error AND correct HTTP body with html, you can avoid in your code processing 5xx error WITHOUT body with correct html.. How to determine if this html is correct? This is pretty risky to guess.. You can research their html and find some global variables or some comment tags/classes in html which won't be returned if real error page is returned.

Important: I understand (and sure you too) that my suggestion is absolutely crazy workaround just to make your code work. What I would do in your place, I would write those guys and ask them to fix their backend. Seems like this is the only place with some email at the bottom..

Try to write them, otherwise you will definitely face a case, where you will fail to meet the criteria of if (res.errorCode === 500 && res.body.anyPossiblePredicateYouMayThinkToCheckRightHTMLBody) {// show the post on your page }

Upvotes: 1

Related Questions