canvas-lms/gems/canvas_http
Evan Battaglia 803c8d028f CanvasHttp: support for a max response body length
Test plan:
- Run the following and check that it raises a ResponseTooLarge error.
  resp = CanvasHttp.get('http://example.com', max_response_length: 1000)
- Run the following and make sure no error is raised and resp.body is a
  String with the full response body:
  resp = CanvasHttp.get('http://example.com', max_response_length: 2000)
- Now let's try to get a file that Net::HTTP splits up into more than
  one chunk. Add a `puts "CHUNK #{chunk.size}"` into the
  `response.read_body` block in `read_body_max_length`.
- Find a big test file on the interwebs (actually the chunk size seems
  to be only a couple kb so it doesn't have to be that big), or possibly
  host one yourself locally with `python -m SimpleHTTPServer 8000`
- Make it fail by setting max_response_length to be less a little than
  the total length. Make sure more than one chunk was fetched.
- Make it succeed by setting max_response_length to be a little more than
  the total length. Make sure more than one chunk was fetched. Make sure
  the body is intact (e.g. fetch without a max_response_length, then
  check resp1.body == resp2.body)

refs INTEROP-6709
flag=none

Change-Id: I0929dfd32a4f4e9bfb6b18c58c5decac265123af
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/263126
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Xander Moffatt <xmoffatt@instructure.com>
QA-Review: Xander Moffatt <xmoffatt@instructure.com>
Product-Review: Evan Battaglia <ebattaglia@instructure.com>
2021-04-19 17:40:03 +00:00
..
lib CanvasHttp: support for a max response body length 2021-04-19 17:40:03 +00:00
spec CanvasHttp: support for a max response body length 2021-04-19 17:40:03 +00:00
Gemfile add frozen_string_literal comment to engines and gems 2021-03-30 18:14:15 +00:00
Rakefile add frozen_string_literal comment to engines and gems 2021-03-30 18:14:15 +00:00
canvas_http.gemspec add frozen_string_literal comment to engines and gems 2021-03-30 18:14:15 +00:00
test.sh simplify gem test harnesses 2016-01-19 17:52:58 +00:00