EUDAT-B2HANDLE / B2HANDLE

B2Handle Python library for interaction with Handle services
https://eudat-b2handle.github.io/
Apache License 2.0
22 stars 24 forks source link

When http instead of https is used, handle creation is not carried out but no error is thrown #84

Closed merretbuurman closed 8 years ago

merretbuurman commented 8 years ago

Behaviour: When http instead of https is used, handle creation is not carried out but NO ERROR IS THROWN (when trying to overwrite existing handles). In case the handles did not exist, a 404 Error is thrown, instead of creating the handle.

Explanation: When a HTTP request is redirected to HTTPS using a 302 code, the python.requests library changed the request verb from GET to PUT, to imitate common browser behaviour (see [0,1,2]). If we try to create a handle that already exist (overwrite), this GET request returns a 200, which the library interprets as creation success. Thus, no error is thrown. If the handle does not exist yet, a 404 is thrown on the GET request - which is confusing for a user, but at least it's a noticeable error.

[0] https://github.com/request/request/issues/29 [1] Code lines in requests.sessions:

Do what the browsers do, despite standards...

    # First, turn 302s into GETs.
    if response.status_code == codes.found and method != 'HEAD':
        method = 'GET'

[2] German Wikipedia says: "Die Browser folgen meist mit einem GET, auch wenn der ursprüngliche Request ein POST war" (browsers usually follow up with a GET even if the original request was a POST.)(https://de.wikipedia.org/wiki/HTTP-Statuscode).

merretbuurman commented 8 years ago

I've fixed this and issued PR #85 . The fix was tested, but is not covered by unit-tests yet.

merretbuurman commented 8 years ago

This issue is fixed and will be closed when the next version is released.

merretbuurman commented 8 years ago

Fixed in release 1.0.3, released on 2016-07-21.