Comments (7)
I don't love the idea of reimplementing go's built-in url escaping logic. Is this lack of ~
escaping actually causing problems for you in practice? Do you have a server that's choking on the ~
character or something? Would it be sufficient to call strings.Replace
to replace that character after encoding the query string?
from go-querystring.
From my post:
This is just one difference between the two RFCs, there are likely others that I've not looked into yet, which is why a naive approach of replacing ~ with %7E isn't the path I want to go down.
from go-querystring.
Thanks, I did see that. But I'm still curious if this is an actual problem or a theoretical problem. And also if less invasive solutions are adequate.
from go-querystring.
There is a real problem where the server can’t handle ~
. The server won’t change because it follows RFC 1738, and nothing says it can’t.
I’m not sure what you mean by “less invasive solutions”, can you elaborate?
from go-querystring.
I’m not sure what you mean by “less invasive solutions”, can you elaborate?
Sure, happy to elaborate. I mean that this package is very small and very focused on converting structs into url.Values
. We rely on the go stdlib for things like url encoding. The Go team apparently decided to follow RFC 3986 for their escaping rules (which certainly seems reasonable given that the rfc was published in 2005). This is the first I've ever heard of that being a problem (at least in connection with go-querystring). Which isn't to dismiss your use-case at all... just to say that it seems to be quite rare.
Supporting a different url escaping scheme would require reimplementing a non-trivial portion of the Go stdlib (looks to be mostly in escape and shouldEscape). That expands the scope, complexity, and maintenance burden of this package beyond what it was intended for. That's what I mean by invasive (sorry if that was a poor word choice).
go-querystring allows structs to implement the query.Encoder
interface which should be sufficient for providing alternate escaping rules for those (seemingly) rare cases where it is needed.
from go-querystring.
Actually, I'm completely wrong! This escaping isn't happening inside go-querystring at all. It's happening as part of the values.Encode call which happens after go-querystring is done. So there's nothing we could change anyway. You'll need to find a different library that can take a url.Values
and encode it using the RFC1738 escaping rules
from go-querystring.
ok, thanks for looking into it.
from go-querystring.
Related Issues (20)
- Encoder interface not respected for `interface{}` types HOT 2
- Allow arbitrary delimiter for slice/array type params
- Parsing query strings into a map HOT 3
- Support for Unmarshaler / Marshaler HOT 2
- "query string" for GitHub search HOT 1
- add `decode` method HOT 1
- Slice (Array) pointer does not result in array query values HOT 1
- Is there a way to write a custom marshaller for my custom type? HOT 1
- Unable to handle nil pointers when implementing Encoder HOT 6
- can you please update the tag? HOT 3
- Querystring not adding [] for the array types HOT 1
- Add support for JSON encoding a struct field
- Different behavior on encoding empty slice with any del tag and without HOT 2
- Supporting slices HOT 2
- Structure fields original order messed up HOT 2
- Custom `String` implementations are not respected HOT 7
- How to encode nested structure by my way? HOT 1
- Support pointer method (*Type)EncodeValues on the Encoder interface HOT 2
- Add support for struct field name casing options
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-querystring.