-
-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
get http status code #161
Comments
Thanks! Concerning your idea:
|
Oh, sorry, I've removed it as I realized I need to think it through more and play with some code. Your idea with grouping it as |
Well - technically it works, but does it really make sense to add different functions which do the same? In addition, there isn't an is(NumericStatusCode) function for every common status code. So it gets confusing - the developer has to know that he could use isNotFound/is404 but not isGone/is410. My personal opinion would be to only keep the is2xx/is4xx/is5xx (and maybe is3xx - if there is a way not to auto-follow redirects) - maybe renaming them to isSuccess(2xx)/isServerError(5xx)/isClientError(4xx) - who really needs to check for specific codes and knows what he's doing should do that with e.g. By the way: The way to check if any error occured would be |
Yeah, my first thought was to allow flexibility. But for keeping the interface simple falling back on a simple
Yeah, this would allow to break it down into categories for internal handling. As you've mentioned, detailed handling can be done on the statusCode itself.
The 600+ ranges seem to be used for various purposes atm. Some are caching-related and others are errors. What are you thinking how these should be handled? |
Its more complicated than I thought - I gave it a try: https://github.com/eposjk/PHPScraper/tree/status-codes New insights:
see some demo code at https://github.com/eposjk/PHPScraper/blob/status-codes/demo.php In addition, I would remove isClientError(), isServerError(), isNotFound() and isForbidden(). What is still missing:
|
How do I check if the scraped page is an error page?
It would be helpful to have the http status for that - something like
Just before posting, I found the solution myself:
It would be great to have this added to the documentation.
Or maybe add
$web->status
as shortcut?The text was updated successfully, but these errors were encountered: