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

Duplicate header keys #19

Closed
pluto-skaalhelarsen opened this issue Jun 1, 2017 · 11 comments
Closed

Duplicate header keys #19

pluto-skaalhelarsen opened this issue Jun 1, 2017 · 11 comments
Labels

Comments

@pluto-skaalhelarsen
Copy link

Thanks for your previous quick response. I have a problem that may actually be in the curl libraries.

A response to a post returns several header values including to values with the same key. I get a seesion key and an xrsf key with the header key string "Set-Cookie". According to the Wireshark traces both these key value pairs are present in the response, but an enumeration from the response returned by Ulfius appears to overwrite the first value with the second and show only that value in the list. When I call PrintResponse(&Response); from your example code, for example, I get a list with one fewer value than was actually sent, and the value of the repeated key is only the second one that was transmitted.

I followed this problem down into your code, but it looks like you are just setting the curl opts and using the returned list. I'm betting you are more familiar with those calls than I am, so I decided to open this issue.

babelouest added a commit that referenced this issue Jun 1, 2017
babelouest added a commit that referenced this issue Jun 1, 2017
@babelouest
Copy link
Owner

Thanks for the bug report, you're right, I was overwriting the previous values like a savage.
I fixed it in the branch 2.1 which is in beta mode, expected to be released soon. If you feel like it, you can run some tests.
https://github.com/babelouest/ulfius/tree/2.1

@babelouest babelouest added the bug label Jun 1, 2017
@babelouest
Copy link
Owner

FYI, to be compatible with the HTTP 1.1 rfc, if multiple header name are sent by the server in the response, the values will be joined in a single header value, separated by a comma ,.

@pluto-skaalhelarsen
Copy link
Author

pluto-skaalhelarsen commented Jun 2, 2017 via email

@babelouest
Copy link
Owner

No, I mean you were right in the first place, there is a bug in the headers management.

The HTTP rfc states that:

  • You can have multiple headers with the same name but it isn't recommended
  • To have multiple values in a single header, you must separate them with a comma ,
  • In case of multiple headers with the same name, the name is case-insensitive

So in the end, with the patch, Ulfius concatenates header values that have the same (case insensitive) name in a single value, separated by a comma, and in case of multiple header names that are case-insensitive equal but case-sensitive different, the header name will be one of them, but I don't guarantee which one.

Can you test if your problem is fixed in the branch 2.1? I'd like to release it soon.

@babelouest babelouest mentioned this issue Jun 3, 2017
@pluto-skaalhelarsen
Copy link
Author

pluto-skaalhelarsen commented Jun 3, 2017 via email

@babelouest
Copy link
Owner

Hi,

Actually I've ran all my tests set and the branch 2.1 passed them all, so I've released it earlier today. This is now in the master branch. All you have to do now is getting the last code and rebuild it. It should be fine. Let me know if you have any other problems with the fix.

And yeah, ulfius was one of the knights of the round table. There is no allegory or meaning of the name, rather than it's my tradition to name my projects among the Arthurian legend. Although some of my other projects try to have a meaningful name somehow, like glewlwyd that is my oauth2 server and was the gatekeeper at Camelot, ulfius when I named it was named like that for now specific reason...

@babelouest
Copy link
Owner

Hi @pluto-skaalhelarsen ,

Any update on this bug?

@pluto-skaalhelarsen
Copy link
Author

pluto-skaalhelarsen commented Jun 7, 2017 via email

@babelouest
Copy link
Owner

I'm not sure I understand everything you say but OK :)

@pluto-skaalhelarsen
Copy link
Author

pluto-skaalhelarsen commented Jun 9, 2017 via email

@babelouest
Copy link
Owner

Yeah, unfortunately I see now there's some lack in the upgrade to Ulfius 2.0 paragraph in the documentation.

Not only Ulfius changed in the last branch, but the underlying libraries too: Orcania and Yder.

This means recompiling/installing orcania and yder before compiling ulfius.

I don't have made packages for ulfius, but for a given version, the lib/ folder is supposed to contain the correct version of underlying libraries.

Whatever the version you want to use, you must run the command git submodule update, then build and install orcania and yder, then install ulfius.

The function ulfius_set_json_body_request is the one up to date, but nstrcmp and nstrdup are deprecated, which suggest you're linking with an old ulfius library but with an up to date orcania library.

So I suggest you reinstall orcania/yder/ulfius from scratch, and try again to recompile your program with the last library.
You can check the version of the library you're using by checking the header files copied in your /usr/local/include directory.
Normally, with the last Ulfius version, you should see the following versions in you files:
Ulfius 2.1: https://github.com/babelouest/ulfius/blob/master/src/ulfius.h#L58
Orcania 1.1: https://github.com/babelouest/orcania/blob/4a25e40705c371d9e95a22ee8d6ab59cf7ebd1de/src/orcania.h#L17
Yder 2.0: https://github.com/babelouest/yder/blob/e9e7e04541407162370aaee8837e218b6a5b9fd3/src/yder.h#L29

babelouest added a commit that referenced this issue Jun 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants