curlwgetgitweb

curl/wget does not resolve a URL same as a browser when redirected


How do I get the correct redirected URL by curl/wget?

Target URL:

A browser, like Chrome/FireFox, resolves the above target URL to the following URL which includes commit and this is expected result.

However, both curl and wget resolve the target URL to the following URL which includes tree and this is NOT expected behavior.

The deference of redirected URL is including commit or tree, and it might be a gitweb issue instead of curl/wget. How do I get the correct redirected URL by curl/wget? To change a User-Agent is helpless. Any ideas? My curl command is as follows:

$ curl -v -L -o output.html \
https://www.codeaurora.org/gitweb/quic/la/?p=kernel/msm-3.18.git%3Ba=commit%3Bh=430f3805c82634a3cb969d83acc4fc4c0ee6af27

Solution

  • I found that the issue is that you need to url encode the / that is part of the project name. Encoding the ; with %3B broke things for me.

    Also, because the URL contains ;, you need to quote it since this is a command separator.

    In the query string, the p=kernel/msm-3.18 should be p=kernel%2fmsm-3.18

    I was able to make the following two cURL commands work:

    curl -v -L -o output.html \
    'https://www.codeaurora.org/gitweb/quic/la/?p=kernel%2fmsm-3.18.git;a=commit;h=430f3805c82634a3cb969d83acc4fc4c0ee6af27'
    

    Or simply,

    curl -v -L -o output.html \
    'https://www.codeaurora.org/gitweb/quic/la/?p=kernel/msm-3.18.git;a=commit;h=430f3805c82634a3cb969d83acc4fc4c0ee6af27'
    

    This might be because the software reads the raw parameters and does not decode %3B and expects a semi-colon in the query string.

    Hope that helps!