-
Notifications
You must be signed in to change notification settings - Fork 74
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
Allow parse etag without quotes #69
base: master
Are you sure you want to change the base?
Allow parse etag without quotes #69
Conversation
.gitignore
Outdated
# JetBrains GoLand | ||
.idea | ||
*.iml | ||
*.ipr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't commit editor-specific ignore rules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I will remove it.
internal/elements.go
Outdated
@@ -342,7 +342,8 @@ type ETag string | |||
func (etag *ETag) UnmarshalText(b []byte) error { | |||
s, err := strconv.Unquote(string(b)) | |||
if err != nil { | |||
return fmt.Errorf("webdav: failed to unquote ETag: %v", err) | |||
*etag = ETag(b) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, this completely ignores all errors. Not sure this is a great idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. But how we can logged error with warn status?
TBH, maybe we shouldn't do any of the quoting/unquoting stuff. It would be a bit awkward to deal with quoted strings, but at least we wouldn't have this kind of issues and we would handle weak entity tags properly. |
Agree. But what will happen with projects, that already use this library? |
We've already made plenty of breaking changes since the last release. |
ok, changed patch as you said |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String
and MarshalText
should be dropped as well, otherwise ETags will get double-quoted.
.gitignore
Outdated
@@ -11,4 +11,4 @@ | |||
*.out | |||
|
|||
# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736 | |||
.glide/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't change this file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reverted all changes
internal/elements.go
Outdated
@@ -340,11 +340,7 @@ type GetETag struct { | |||
type ETag string | |||
|
|||
func (etag *ETag) UnmarshalText(b []byte) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is now a no-op and can be dropped.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Done |
- Change separated type ETag to String
Hm, this new proposal is error-prone. Library users need to "guess" that they need to double-quote the ETag values they're using. It's very easy to break the RFC with this API. |
That's why I worried about remove String method. |
|
Nope. String() method, that I was removed, is adding quotes to ETag value. |
With your changes, the ETag contains quotes already, no need to add them again. |
Where my changes add quotes in code ? |
Removed wrapper, with call String() method on it. I think it will broke server in setting ETag to headers |
Catched issue same like #50.
Understand that it's needs when server not working strictly by RFC. But some developers will try to use library for "wrong implemented" servers and get the same error.
Think it's possible to make requirement not so strictly in that case.