microsoft / microsoft/sql-server-samples

CURL @H Header value returns error: Specified value has invalid HTTP Header characters.

Open
#639 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PowerShell
Stars
11.2k
Forks
9.1k
Avg merge
2d 7h
Merged PRs (30d)
14

Description

I have a header which contains both quotes (") and colons (:).
Whenever I include these in my @H variable for use in a CURL XGET select statement, SSMS returns the following error;

Msg 6522, Level 16, State 1, Line 14 A .NET Framework error occurred during execution of user-defined routine or aggregate "XGET": System.ArgumentException: Specified value has invalid HTTP Header characters. Parameter name: name System.ArgumentException: at System.Net.WebHeaderCollection.CheckBadChars(String name, Boolean isHeaderValue) at System.Net.WebHeaderCollection.Add(String header) at Curl.AddHeader(SqlChars H, WebClient client) at Curl.Get(SqlChars H, SqlChars url)

I can retrieve other files when using NULL instead of a @H header.

I can use the generated CURL XGET statement in SQL and pass it to a curl.exe cli which works fine but we're ultimately trying to get rid of that.

I already tried replacing the quotes and colons with their respective CHAR() values but SSMS keeps returning the exact same error message.

Any help on this would be very much appreciated.

Thanks

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure in SSMS with the XGET entry point and inspect the Curl.AddHeader and Curl.Get stack frames named in the error. Compare the @H behavior with the working curl.exe command; done means a header containing quotes and colons can be passed through XGET without the invalid HTTP header exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
sql
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.