rymanluk closed pull request #50: oic: Allow to provide GET query parameters URL: https://github.com/apache/mynewt-newtmgr/pull/50
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/Gopkg.lock b/Gopkg.lock index aaad4de..f359aec 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -7,6 +7,12 @@ revision = "f006c2ac4710855cf0f916dd6b77acf6b048dc6e" version = "v1.0.3" +[[projects]] + name = "github.com/cheggaaa/pb" + packages = ["."] + revision = "657164d0228d6bebe316fdf725c69f131a50fb10" + version = "v1.0.18" + [[projects]] branch = "master" name = "github.com/currantlabs/ble" @@ -55,6 +61,12 @@ revision = "fc9e8d8ef48496124e79ae0df75490096eccf6fe" version = "v0.0.2" +[[projects]] + name = "github.com/mattn/go-runewidth" + packages = ["."] + revision = "9e777a8366cce605130a531d2cd6363d07ad7317" + version = "v0.0.2" + [[projects]] branch = "master" name = "github.com/mgutz/ansi" @@ -95,7 +107,7 @@ branch = "master" name = "github.com/runtimeco/go-coap" packages = ["."] - revision = "e869704e8ca4a662cdde0e67e006daadd523b2b3" + revision = "f5efd2025d000a399e47f715c29ec93b6faa8913" [[projects]] name = "github.com/spf13/cast" @@ -166,6 +178,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "e608391fefffe106d6f8148f2c92789f96ee5425c775a3437266586da886dff7" + inputs-digest = "6a7245247cf11745348daa479eb65c063d23b755b400d35003cac58f621d8f0f" solver-name = "gps-cdcl" solver-version = 1 diff --git a/nmxact/nmcoap/nmcoap.go b/nmxact/nmcoap/nmcoap.go index a5e2aaf..bcf14f3 100644 --- a/nmxact/nmcoap/nmcoap.go +++ b/nmxact/nmcoap/nmcoap.go @@ -21,9 +21,10 @@ package nmcoap import ( "fmt" - "sync" "github.com/runtimeco/go-coap" + "strings" + "sync" ) var messageIdMtx sync.Mutex @@ -64,6 +65,8 @@ func Encode(m coap.Message) ([]byte, error) { } func CreateGet(isTcp bool, resUri string, token []byte) (coap.Message, error) { + var q []string + if err := validateToken(token); err != nil { return nil, err } @@ -75,7 +78,12 @@ func CreateGet(isTcp bool, resUri string, token []byte) (coap.Message, error) { } m := buildMessage(isTcp, p) - m.SetPathString(resUri) + + q = strings.SplitN(resUri, "?", 2) + m.SetPathString(q[0]) + if len(q) > 1 { + m.SetURIQuery(q[1]) + } return m, nil } diff --git a/vendor/github.com/mattn/go-runewidth/runewidth.go b/vendor/github.com/mattn/go-runewidth/runewidth.go index a16f1af..2164497 100644 --- a/vendor/github.com/mattn/go-runewidth/runewidth.go +++ b/vendor/github.com/mattn/go-runewidth/runewidth.go @@ -55,7 +55,6 @@ var private = table{ var nonprint = table{ {0x0000, 0x001F}, {0x007F, 0x009F}, {0x00AD, 0x00AD}, {0x070F, 0x070F}, {0x180B, 0x180E}, {0x200B, 0x200F}, - {0x2028, 0x2029}, {0x202A, 0x202E}, {0x206A, 0x206F}, {0xD800, 0xDFFF}, {0xFEFF, 0xFEFF}, {0xFFF9, 0xFFFB}, {0xFFFE, 0xFFFF}, } diff --git a/vendor/github.com/mattn/go-runewidth/runewidth_test.go b/vendor/github.com/mattn/go-runewidth/runewidth_test.go index fb38243..b0378a1 100644 --- a/vendor/github.com/mattn/go-runewidth/runewidth_test.go +++ b/vendor/github.com/mattn/go-runewidth/runewidth_test.go @@ -52,13 +52,10 @@ var runewidthtests = []struct { {'\x00', 0, 0}, {'\x01', 0, 0}, {'\u0300', 0, 0}, - {'\u2028', 0, 0}, - {'\u2029', 0, 0}, } func TestRuneWidth(t *testing.T) { c := NewCondition() - c.EastAsianWidth = false for _, tt := range runewidthtests { if out := c.RuneWidth(tt.in); out != tt.out { t.Errorf("RuneWidth(%q) = %d, want %d", tt.in, out, tt.out) @@ -124,16 +121,15 @@ var stringwidthtests = []struct { func TestStringWidth(t *testing.T) { c := NewCondition() - c.EastAsianWidth = false for _, tt := range stringwidthtests { if out := c.StringWidth(tt.in); out != tt.out { - t.Errorf("StringWidth(%q) = %d, want %d", tt.in, out, tt.out) + t.Errorf("StringWidth(%q) = %q, want %q", tt.in, out, tt.out) } } c.EastAsianWidth = true for _, tt := range stringwidthtests { if out := c.StringWidth(tt.in); out != tt.eaout { - t.Errorf("StringWidth(%q) = %d, want %d", tt.in, out, tt.eaout) + t.Errorf("StringWidth(%q) = %q, want %q", tt.in, out, tt.eaout) } } } @@ -141,7 +137,7 @@ func TestStringWidth(t *testing.T) { func TestStringWidthInvalid(t *testing.T) { s := "?????\x00??" if out := StringWidth(s); out != 14 { - t.Errorf("StringWidth(%q) = %d, want %d", s, out, 14) + t.Errorf("StringWidth(%q) = %q, want %q", s, out, 14) } } diff --git a/vendor/github.com/runtimeco/go-coap/message.go b/vendor/github.com/runtimeco/go-coap/message.go index cb473c7..c80841b 100644 --- a/vendor/github.com/runtimeco/go-coap/message.go +++ b/vendor/github.com/runtimeco/go-coap/message.go @@ -349,6 +349,7 @@ type Message interface { PathString() string SetPathString(s string) SetPath(s []string) + SetURIQuery(s string) SetPayload(p []byte) RemoveOption(opID OptionID) AddOption(opID OptionID, val interface{}) @@ -459,6 +460,11 @@ func (m *MessageBase) SetPath(s []string) { m.SetOption(URIPath, s) } +// Set URIQuery attibute to the message +func (m *MessageBase) SetURIQuery(s string) { + m.AddOption(URIQuery, s) +} + // SetPayload func (m *MessageBase) SetPayload(p []byte) { m.payload = p ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services