`uri_builder` in `windows_request_context::read_headers_io_completion` throws web::uri_exception when the uri contains square brackets.
The encode_uri method handles square brackets as general delimiters and therefor will not encode them.
The encoded uri is passed to the uri_builder that throws the web::uri_exception.
The following code snippet reproduces the exception:
```cpp
auto encodedUri = uri::encode_uri(L"http://localhost/service[1]?param[]=123¶m[]=456");
// assert(encodedUri == L"http://localhost/service%5B1%5D?param%5B%5D=123¶m%5B%5D=456");
uri_builder builder(encodedUri);
```
In compare, the JavaScript `encodeURI` method encodes the square brackets as this exampel shows:
```javascript
console.log(encodeURI("http://localhost/service[1]?param[]=123¶m[]=456"));
// -> http://localhost/service%5B1%5D?param%5B%5D=123¶m%5B%5D=456
```
Is there a reason to keep the brackets unencoded and why is the behavior different to javascript?
Comments: Hi Steve Many thanks for your comment. I agree that the case above is a bit special. But maybe i have to add some more information about how i got into the problem... I use the `http_listener` to provide a simple REST API that handles GET operations. When the REST URI contains the **encoded** square brackets (%5B and %5D), the `http_listener` throws the `uri_exception` and responds with a `InternalError`. The `http_listener` somewhere decodes the URI and encodes it later in the `read_headers_io_completion` method mentioned above. Then the URI is passed to the `uri_builder` where the exception happens... Markus
The encode_uri method handles square brackets as general delimiters and therefor will not encode them.
The encoded uri is passed to the uri_builder that throws the web::uri_exception.
The following code snippet reproduces the exception:
```cpp
auto encodedUri = uri::encode_uri(L"http://localhost/service[1]?param[]=123¶m[]=456");
// assert(encodedUri == L"http://localhost/service%5B1%5D?param%5B%5D=123¶m%5B%5D=456");
uri_builder builder(encodedUri);
```
In compare, the JavaScript `encodeURI` method encodes the square brackets as this exampel shows:
```javascript
console.log(encodeURI("http://localhost/service[1]?param[]=123¶m[]=456"));
// -> http://localhost/service%5B1%5D?param%5B%5D=123¶m%5B%5D=456
```
Is there a reason to keep the brackets unencoded and why is the behavior different to javascript?
Comments: Hi Steve Many thanks for your comment. I agree that the case above is a bit special. But maybe i have to add some more information about how i got into the problem... I use the `http_listener` to provide a simple REST API that handles GET operations. When the REST URI contains the **encoded** square brackets (%5B and %5D), the `http_listener` throws the `uri_exception` and responds with a `InternalError`. The `http_listener` somewhere decodes the URI and encodes it later in the `read_headers_io_completion` method mentioned above. Then the URI is passed to the `uri_builder` where the exception happens... Markus