Open
Description
Now the swifth client assumes ObjectNames are plain for the response and only calls readLines().
The default value of swift is plain, but there are cases where format=json
is used, and support for this case is needed.
How about change readJson() or readLines() depending on "Contect-Type" like below?
// ObjectNames returns a slice of names of objects in a given container.
func (c *Connection) ObjectNames(ctx context.Context, container string, opts *ObjectsOpts) ([]string, error) {
v, h := opts.parse()
resp, _, err := c.storage(ctx, RequestOpts{
Container: container,
Operation: "GET",
Parameters: v,
ErrorMap: ContainerErrorMap,
Headers: h,
})
if err != nil {
return nil, err
}
if resp.Header.Get("Content-Type") == "application/json" {
var objects []Object
err := readJson(resp, &objects)
var names []string
for _, obj := range objects {
names = append(names, obj.Name)
}
return names, err
} else {
return readLines(resp)
}
}
Metadata
Metadata
Assignees
Labels
No labels