-
Bug
-
Resolution: Fixed
-
Major
-
4.0.7, 4.1.2
-
MOODLE_400_STABLE, MOODLE_401_STABLE
-
MOODLE_401_STABLE
-
MDL-77990-401 -
As discussed in https://moodle.org/mod/forum/discuss.php?d=445863#p1792397
In a nutshell, I think my http_client shim code is buggy. An exception is thrown for 4xx level status codes (the status we get from curlclient->get_info()). This exception includes the status code in it's message. But, because of some dumb code I wrote, it uses the status code being parsed from the headers, not the one it should be using from curl.
So, we're throwing an exception based on 4xx in the right situation - that part's fine. The problem is with the naive header parsing. This code assumes that their is only one line with an HTTP/1.1 XX XXX status. In some cases (proxies, I think?), where HTTP/1.1 Continue is used, we'll see something like this in the response headers:
HTTP/1.1 100 Continue |
|
HTTP/1.1 4xx SomeError |
etc..
|
Clearly the first line isn't the real status code we want.
The result is that for a service call being made from enrol_lti, it might fail (due to a 'real' 4xx level code), but it will report the failure as being related to a 100 Continue, which isn't helpful in tracking down anything.
This http_client shim has been removed in 4.2, since we're now using the Guzzle client, but this is still a problem in 4.0 and 4.1, so we'll need to fix it there.