automatic extension update can't handle zip file from github?

房东的猫 提交于 2019-12-08 00:57:23

问题


I have an extension hosted on github, for which I want to provide automatic updates. However, when I provide the URL to a file attached to a release, Joomla just reports the following on trying to automatically update:

Fehler beim Verbindungsaufbau zum Server: Error Unknown
Ungültige Webadresse

Translation

Error in connecting to server: Error Unknown
Invalid web address

It's the same when trying to install from the web address via the Extensions - Install page. From the browser, I can download the file just fine however. Anybody got an idea why that is? Is it an error on github side, or on Joomla's? Or is it some "safety" or "security" mechanism on github side? What can I do to avoid it? Or do those two just not play along?

Example URL: https://github.com/codeling/bfstop/releases/download/1.2.0/pkg_bfstop-1.2.0.zip

Edit:

Inserted the patch for downloadPackage method (gist.github.com/piotr-cz/8316210) mentioned by piotr_cz in the comments below the answer into my Joomla installation now.

URL passed into the method after resolving the redirect: https://s3.amazonaws.com/github-cloud/releases/6794712/f2aa5eb4-7838-11e3-837a-c6be2639e4ca.zip?response-content-disposition=attachment%3B%20filename%3Dpkg_bfstop-1.2.0.zip&AWSAccessKeyId=AKIAISTNZFOVBIJMK3TQ&Expires=1389455424&Signature=Nnyl6TnWueTqK8bPkPXUidM8UzQ%3D

URL after the newly inserted lines: https://s3.amazonaws.com/github-cloud/releases/6794712/f2aa5eb4-7838-11e3-837a-c6be2639e4ca.zip?response-content-disposition=attachment; filename=pkg_bfstop-1.2.0.zip&AWSAccessKeyId=AKIAISTNZFOVBIJMK3TQ&Expires=1389455424&Signature=Nnyl6TnWueTqK8bPkPXUidM8UzQ=

The response is still a 505 error:

response: JHttpResponse Object
(
    [code] => 505
    [headers] => Array
        (
            [Date] => Sat, 11 Jan 2014 15:49:24 GMT
            [Connection] => close
            [Server] => AmazonS3
        )

    [body] =>
)

So I suppose the encoding doesn't matter. The error 505 would indeed indicate http version problems? Why would Joomla and Amazon disagree on HTTP versions? Definitely not an HTTP expert here but version 1.1 should be the unchanged standard version since more than 10 years now?


回答1:


Conclusions:

  1. Automatically generated downloads by GitHub's Tags and Releases are compatible with Joomla Installer at this moment (Jan 2014) as long as the repository name matches extension name (element). Joomla Installer is able to work with an extension which:

    • Have files and folders located directly:

      mod_mymodule.zip:
      
      /mod_mymodule.xml
      /mod_mymodule.php
      
    • Or have files and folders located in a folder of the same name as the archive (see JInstallerHelper::unpack):

      mod_mymodule.zip:
      
      /mod_mymodule
      /mod_mymodule/mod_mymodule.xml
      /mod_mymodule/mod_mymodule.php
      

      This is how GitHub Tags and Releases are built now. Automatically generated downloads of repository mod_mymodule results in mod_mymodule-[tag/branch].zip archive with mod_mymodule-[tag/branch] subfolder. Say when we tag extension 1.0.0-beta:

      mod_mymodule-1.0.0-beta.zip:
      
      /mod_mymodule-1.0.0-beta
      /mod_mymodule-1.0.0-beta/mod_mymodule.xml 
      /mod_mymodule-1.0.0-beta/mod_mymodule.php
      

      Note: There were some changes in how archive is built (see Automatic Extension Update: Unknown Archive type)

  2. Manually attached Binaries added to a GitHub Release are hosted in the Amazon Web Services. Request to download these by JInstallerHelper::downloadPackage results in an response 505 HTTP Version Not Supported and we didn't find a working solution for this problem yet.

In the end one may use GitHub as an Joomla Extensions Update server (it's pretty convenient), as long as you use automatically generated downloads.

GitHub provides Version Control service, not an Update server so the way how downloadable archive is built may change again in future.

Until we find out a way how to download Attached Binaries (where one have full control over archive's name and structure) using Joomla Installer, GitHub should not be perceived as a reliable tool for Joomla extension updates. I believe there's a way to patch the JInstaller package to be compatible with the AWS (download works fine using command-line curl).

Thanks for ccpl and RandolphCarter on getting information for this answer.




回答2:


It would appear that URL is redirected to an S3 location:

https://s3.amazonaws.com/github-cloud/releases/6794712/6c173582-77ef-11e3-9aec-c8994b691269.zip?response-content-disposition=attachment%3B%20filename%3Dpkg_bfstop-1.2.0.zip&AWSAccessKeyId=AKIAISTNZFOVBIJMK3TQ&Expires=1389163120&Signature=c4RdRTAUZ5%2FDHlpg0vR2ivK6lQQ%3D`

As a guess I would say this breaks the install from web.

Updated

Doing a bit further tracking, I can see the downloadPackage() method does catch the 302 Found and try to get the file from the new URL. At this point it does a new curl request with some basic options:

$options = array("10036" => "GET",
"10065" => "/Users/cppl/Sites/jdev/libraries/joomla/http/transport/cacert.pem",
"10002" => "https://s3.amazonaws.com/github-cloud/releases/6794712/f2aa5eb4-7838-11e3-837a-c6be2639e4ca.zip?response-content-disposition=attachment; filename=pkg_bfstop-1.2.0.zip&AWSAccessKeyId=AKIAISTNZFOVBIJMK3TQ&Expires=1389170600&Signature=BVlqH0hVhYGjbeKn6w/9nDn+kDg=",
"42" => "1",
"19913" => "1")

Unfortunately the S3 service is returning a 505

HTTP/1.1 505 HTTP Version Not Supported
Date: Wed, 08 Jan 2014 08:47:59 GMT
Connection: close
Server: AmazonS3

Hacking around in \JHttpTransportCurl\request I tried

  1. forcing CURL_HTTP_VERSION_1_1
  2. disabling SSL verification CURLOPT_SSL_VERIFYPEER (useful in other S3 situations)
  3. updating the cacert.pem to the current one
  4. all together

Nothing worked.

So far it all appears to be on AWS side, I'm not aware of all the S3 access controls possibly there's something in the GitHub setup of their S3 buckets.




回答3:


I haven't got the direct approach to work (to use the release assets for automatic update), therefore I am now implementing the workaround solution by putting the files into the git repository.

Not an ideal solution, I know, but at least that works.



来源:https://stackoverflow.com/questions/20984019/automatic-extension-update-cant-handle-zip-file-from-github

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!