This hunk in drupal_http_request() always executes at least twice, because $info['eof'] will be NULL whatever happens during the first request (unless it's actually empty).

It looks like we could use $info['unread_bytes'] instead, and save the second request just to find out we got to the end of the file.

Testing with openid, I didn't see any bugs with this, but let's see what the testbot says.

Found this via profiling both a recieving openid_provider, and a sending openid module on two separate servers.

CommentFileSizeAuthor
drupal_http_request.patch627 bytescatch

Comments

Status: Needs review » Needs work

The last submitted patch, drupal_http_request.patch, failed testing.

tr’s picture

Status: Needs work » Needs review

drupal_http_request.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, drupal_http_request.patch, failed testing.

mikeytown2’s picture

The documentation says that you shouldn't use 'unread_bytes' in stream_get_meta_data(). I was looking at a way to get around this and there is no good way to do it. Coming from #1320222: Bring in other drupal patches if your wondering.

catch’s picture

I think this is probably not worth worrying about. The performance issue I was debugging turned out to be the openid math library used at the other side of the connection.

mikeytown2’s picture

Thinking about this, if chunked transfer encoding is used then you can detect that the stream is done because the last chunk is a zero-length chunk http://en.wikipedia.org/wiki/Chunked_transfer_encoding#Format; Once you see a chunk size of 0 close the connection. One could also close the connection after the Content-Length has been hit.
#106506: drupal_http_request() does not handle 'chunked' responses - Make it support HTTP 1.1

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.