-
Notifications
You must be signed in to change notification settings - Fork 62
Prevent cleanUrl from adding equal sign to query parameters #612
Conversation
According to RFE3986 the query component may be any form, not necessarily in the form of key=value pairs. The existing implementation of cleanUrl added an equal sign (=) to data not in the form of key=value pairs. This lead to infinite redirects in a HEAD request in the SLUB API and is fixed now to leave query data without an equal sign as is. Move tests for cleanUrl from ApacheBaseApiTest to BaseApiTest as it's a method of the BaseApi.
The problem is much more serious than I thought. While the above fix is valid and still should be merged it doesn't resolve my problem. Everything works fine for unit tests on the JVM. But as soon as I use android the following line again adds an opacclient/opacclient/libopac/src/main/java/de/geeksfactory/opacclient/apis/BaseApi.java Line 491 in 2040420
The reason is that android uses an old implementation of
Apache version 4.5.12 used by JVM in unit tests:
I experimented a bit with So the only workaround I could find is to not clean the url in calls to |
This is a workaround as the only possibility to add links to other detailed items from a detailed item. It's possible as we can display volumes and copies at the same time. References are some kind of details which is why the display order of copies and volumes was swapped: first show volumes (which may be references) right after the details and only then copies. Increase volumes text view to maximum two lines high to be able to put the title of the reference and the reference itself on different lines for better readability. Change resolution of bc or rsn and the new libero identifiers to following head redirects and retrieving the final url to get the id identifier. This requires one request more than the old method (get location parameter from non-redirecting head request) but is much shorter to implement. IDs of references have a single query component (e.g. ?libero_mab21364775) and no key=value pairs. The URLEncodedUtils.format implementation used by Android has a bug and adds a trailing equal sign (=) to the query component which leads to infinite redirects, see opacapp#612 for details. The prevent this we use cleanUrl only if there are any = signs in the url, otherwise we use the raw url in head requests.
I'm a little bit worried this breaks things for other APIs… Maybe it makes sense to refactor |
This is certainly an option, although I think a more fundamental solution would be to:
Still we don't know if some API relies on key-only parameters being in the form of So making this change in After all these considerations I agree with you that it's best to make |
Agreed
My gut feeling says that no API relies on this, but it's really just a gut feeling and hard to tell. I'd be more catious of any API relying on some behavior that might be different with OkHttp's HttpUrl. As you mentioned, it's unfortunately really hard to test…
Yup! |
According to RFE3986 the query component may be any form, not necessarily
in the form of key=value pairs. The existing implementation of cleanUrl
added an equal sign (=) to data not in the form of key=value pairs. This
lead to infinite redirects in a HEAD request in the SLUB API and is fixed
now to leave query data without an equal sign as is.
Move tests for cleanUrl from ApacheBaseApiTest to BaseApiTest as it's a
method of the BaseApi.
see also #595 (comment)