Support from Acquia helps fund testing for Drupal Acquia logo

Comments

twistor’s picture

Issue summary: View changes
twistor’s picture

Status: Active » Needs review
FileSize
2.35 KB

This actually still needs work. Specifically around handling context and setting the correct user agent, but I wanted to get feedback before I went too far.

Status: Needs review » Needs work

The last submitted patch, 2: remote_stream_wrapper-use-native-2522056-2.patch, failed testing.

twistor’s picture

Status: Needs work » Needs review
Related issues: +#2522060: Use a temp stream for managing the downloaded content.

Haha, I have a lot of changes in mind. #2522060: Use a temp stream for managing the downloaded content. would make this patch easier, but it's definitely not a blocker.

twistor’s picture

FileSize
645 bytes
2.42 KB

Ugh, this took way to long to debug because of @ usage.

twistor’s picture

This still needs context handling to fix more issues listed in the issue summary as well as setting the user agent.

twistor’s picture

FileSize
1.63 KB
3.56 KB

So this makes the test run with both stream wrappers. Ensuring that we don't break one while testing the other.

twistor’s picture

FileSize
433 bytes
3.71 KB

No really running both sets of tests.

twistor’s picture

This adds proper context handling.

It would make sense for us to add context support for both wrappers for options like timeout and redirects.

Edit: This also adds support for drupal_http_request() proxy handling in the native handler.

twistor’s picture

D.O ate my previous post. Walking it off.

Status: Needs review » Needs work

The last submitted patch, 10: remote_stream_wrapper-use-native-2522056-10.patch, failed testing.

twistor’s picture

twistor’s picture

FileSize
5.72 KB
9.86 KB

So, this fixes #2233159: compress.zlib stream wrapper for a remote file at least for the native stream, and possibly for the drupal_http_request version, but it depends on the PHP version. stream_cast() is required in my testing to get the zlib stream to work. #2522060: Use a temp stream for managing the downloaded content. would make it trivial to implement stream_cast(), so I'm holding off on fixing everything at once.

This fixes #2510642: Request headers missing for both streams and makes the headers accessible in the same way. That's what the ArrayAccess stuff is for. Note: It's not a direct match, since we're using an iterator, and not a regular array, so there still could be problems with other people's code, but it should be easy enough to work around.

#1416564: $http_response_header not set That's some voodoo I don't know.
#2040053: get_headers() does not work with module enabled. I looked into this one actually, and it's broken specifically because we're re-registering the stream not using STREAM_IS_URL or whatever. I think it would still be broken if we changed that (we can't), because get_headers() is checking if wrapper_data is an array. There's no way for us to set wrapper_data, it just gets set to the stream object itself, so there's not much to be done.

The stream wrapper API is terrible.

das-peter’s picture

@twistor Thanks for this patch! I've just come across an issue with Remote stream wrapper and the Mailchimp module.
The latest mailchimp module uses Guzzle and the http stream wrapper of Remote stream wrapper breaks all kinds of things.
This patch seems to help a lot even thought there remain some problems.

The stream wrapper API is terrible.

I concur! ;)

Specifically the handling of $http_response_header - but here we can't do much as this is a php bug: https://bugs.php.net/bug.php?id=63897

So if there's anything that uses Guzzle best bet is to ensure the CURL implementation is used as described in #1416564: $http_response_header not set / #2891977: Acquia Search uses a Solarium adapter that conflicts with the remote_stream_wrapper module

However, I've found another situation in which we can do something. The // Don't allow user-agent overriding. part made some trouble together with guzzle as it sets the header as string and not as array - that makes unset() sad.
The attached patch adds a check to see how that has to be handled.
Further it adds some documentation regarding $http_response_header.