Skip to content

Can't call service that requires trailing slash #1503

@gatesn

Description

@gatesn

What happened?

The readme suggests I can use Dialogue to call non-Conjure servers, but I've run into a bit of trouble: https://github.com/palantir/dialogue/tree/96ae91db83aa9ccdc5939a934ab84b33691ec240#dialogue-annotations-processor-generated-client-bindings

Internally, Dialogue passes paths around as a list of segments, throwing away information about whether or not a trailing slash exists:

This results in the server issuing a 301 redirect to the path ending in a slash. However, the Apache client is configured to ignore redirects:

I thought about implementing a channel to handle the 301 and resubmit the request with the slash, but I think the Channel API is too high-level since it also talks in terms of UrlBuilders, and therefore path segments.

It also seems there's a lot of logic wrapped up in ApacheHttpClientChannels.ClientBuilder that I don't (or can't, due to being package-private) want to replicate to enable redirects on the Apache client.

What did you want to happen?

I think I agree with the principle of no redirects, so it perhaps makes sense to support trailing slashes rather than 301s in this case?

My proposal might be to have HttpPath capture whether or not there exists a trailing slash (special-casing trailing slashes, vs any other duplicate slashes in the path). PathTemplate can then have a method to append a slash, templated in to the generated classes by the EndpointsEnumGenerator.

Unfortunately, I imagine this could be a breaking change for anyone relying on the current path template parsing behaviour...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions