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

Extra Headers are not taking JSON payloads #345

Open
Djurrez opened this issue Dec 12, 2023 · 1 comment
Open

Extra Headers are not taking JSON payloads #345

Djurrez opened this issue Dec 12, 2023 · 1 comment

Comments

@Djurrez
Copy link

Djurrez commented Dec 12, 2023

        public void Initialize()
        {
            var client = new SocketIOClient.SocketIO("http://mywebsocket", new SocketIOOptions
            {
                ExtraHeaders = new Dictionary<string, string>
                {
                    {"Authorization", "{\"id\":123, \"first_name\":\"A\", \"last_name\":\"A\", \"username\":\"A\", \"auth_date\":123, \"hash\":\"gjsdkgbskjdgbkasjdbgjkasbdjgkasdgbjkasbdkagjk\"}"},
                    {"SessionID", "test" }
                }
            });

            client.ConnectAsync().Wait();

        }

Seems like ExtraHeaders are not taking any stringified JSON data. Once you do this it stops sending out any requests.

@doghappy
Copy link
Owner

doghappy commented Dec 14, 2023

the reason is that the header "Authorization" is a special header. when you try to add it, .NET will try to validate value first. Sure the value you provided is invalid.

the issue same as #300

so how to solve it?

  1. try to use another header name
  2. allow "authorization" header.
    private static readonly HashSet<string> allowedHeaders = new HashSet<string>
    {
    "user-agent",
    };

for option2, actually I have implemented but I need to do some research.

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