Browse Source

Revert "Send nice error when version number is out of range"

This reverts commit f4151cb744.
master
GeertJohan 10 years ago
parent
commit
d25e20e4a7
2 changed files with 4 additions and 12 deletions
  1. +0
    -4
      main.go
  2. +4
    -8
      version.go

+ 0
- 4
main.go View File

@@ -138,10 +138,6 @@ func handler(resp http.ResponseWriter, req *http.Request) {
var ok bool
repo.Version, ok = parseVersion(m[3])
if !ok {
if repo.Version == TooHighVersion {
sendNotFound(resp, "Version %q contains a number which is out of range.", m[3])
return
}
sendNotFound(resp, "Version %q improperly considered invalid; please warn the service maintainers.", m[3])
return
}


+ 4
- 8
version.go View File

@@ -48,7 +48,6 @@ func (v Version) IsValid() bool {
}

var InvalidVersion = Version{-1, -1, -1}
var TooHighVersion = Version{-2, -2, -2}

func parseVersion(s string) (Version, bool) {
if len(s) < 2 {
@@ -67,20 +66,17 @@ func parseVersion(s string) (Version, bool) {
if len(part) == 0 || part[0] == '0' {
return InvalidVersion, false
}
num, err := strconv.ParseInt(part, 10, 32)
num, err := strconv.Atoi(part)
if err != nil {
if err.(*strconv.NumError).Err == strconv.ErrRange {
return TooHighVersion, false
}
return InvalidVersion, false
}
switch i {
case 0:
v.Major = int(num)
v.Major = num
case 1:
v.Minor = int(num)
v.Minor = num
case 2:
v.Patch = int(num)
v.Patch = num
}
}



Loading…
Cancel
Save