Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If the Header content is a String, quotes are added #11

Closed
lthms opened this issue Sep 20, 2016 · 8 comments
Closed

If the Header content is a String, quotes are added #11

lthms opened this issue Sep 20, 2016 · 8 comments

Comments

@lthms
Copy link
Contributor

lthms commented Sep 20, 2016

Regarding the Header combinator, if its content is a String, Servant reads the raw string as far as I know. Hovewer, servant generated code call the settings encodeURLPieces (see

<+> "encodeURLPiece spOpts_'" <+> psVar argText
)

The example uses gShow (or I think I saw gDefaultEncodeURLPieces or something), but gShow adds quotes to a string. My string is a token, so you guess it is not a good idea to mess with token content…

Do you have any idea on how we can fix that? One idée could be to add the ToHttpApiData type class to mimic Servant? Then change the Generic a => a -> String to the new typeclass? It might be less flexible, though.

Thanks by advance!

@eskimor
Copy link
Owner

eskimor commented Sep 20, 2016

Do I understand correctly: servant has an implementation for FromHttpApiData String/Text and it does not encode with quotes there? That sucks.

I don't use plain strings as headers but my own data types - there it is easy to implement parseHeader with jsonParseHeader which is compatible with servant-purescript's encoding.

You can use this workaround in the meantime (if appropriate), while I am trying to find a good fix for this problem.

@eskimor
Copy link
Owner

eskimor commented Sep 20, 2016

Should be fixed with version 3.0.1 of purescript-servant-support - please try and re-open if it does not work.
Best regards,
Robert

@eskimor eskimor closed this as completed Sep 20, 2016
@eskimor
Copy link
Owner

eskimor commented Sep 20, 2016

Thank you for your bug report and have a pleasant stay.

@lthms
Copy link
Contributor Author

lthms commented Sep 20, 2016

Thanks! I had a look, I fear a similar issue might happen with other prim types such as Int, for instance. Anyway, I will try it as soon as I come back home.

@eskimor
Copy link
Owner

eskimor commented Sep 20, 2016

Numbers and bool should be fine. Here http-api-data is compatible with our JSON encoding. There is a default encoding for time, maybe and either which are incompatible - ok - I am going to need some more special cases.

@eskimor
Copy link
Owner

eskimor commented Sep 20, 2016

I added a corresponding issue: eskimor/purescript-servant-support#2

@lthms
Copy link
Contributor Author

lthms commented Sep 20, 2016

Great! Thanks a lot for that, I will try to help if I find something else (:

@lthms
Copy link
Contributor Author

lthms commented Sep 20, 2016

Okay so now I have another issue. If my String contains a special character, such as / or +, they are translated into %20 or whatever (I do not remember the exact numbers).

I am still searching in the purescript-servant-support the reason of this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants