Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-77990

http_client shim naively assumes only one HTTP/xx header, resulting in incorrect status code logging for service calls

XMLWordPrintable

      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.

            jaked Jake Dallimore
            jaked Jake Dallimore
            Andrew Lyons Andrew Lyons
            Huong Nguyen Huong Nguyen
            CiBoT CiBoT
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours, 46 minutes
                2h 46m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.