Cannot link to BR in another format #95

Open
opened 2025-11-05 17:43:20 +01:00 by michals · 4 comments

According to

#94 (comment)

the BR is provided in multiple formats which are selected by accept header.

As headers cannot be specified in an URL it's not possible to link to results in different formats.

According to https://src.opensuse.org/git-workflow/autogits/issues/94#issuecomment-49668 the BR is provided in multiple formats which are selected by accept header. As headers cannot be specified in an URL it's not possible to link to results in different formats.
Owner

What is the usecase to linking to JSON or XML results where you cannot specify accept header?

I'll entertain a patch for this (eg. via GET parameter) if there's an actual, valid use-case here.

What is the usecase to linking to JSON or XML results where you cannot specify accept header? I'll entertain a patch for this (eg. via GET parameter) **if** there's an actual, valid use-case here.
Author

What is the use case for obfuscating the URLs?

Yes, in most cases (other than linking here for a bug report) the consumer of the JSON and XML will be automation that can specify headers.

However, it can equally specify a query string.

Selecting the content type by query string rather than headers makes the content unambiguous,

I am sure whoever designed this feels very clever about it.

I have seen a protocol specification built around this that made handling the protocol with the mime type infra pretty much impossible.

This is a small technical detail of the whole OBS so it probably does not cause serious problem if it's 'clever' in a stupid way.

Nonetheless, spreading examples of bad design is not great.

Yes, the specification allows this but not everything specifications allow is a good idea.

What is the use case for obfuscating the URLs? Yes, in most cases (other than linking here for a bug report) the consumer of the JSON and XML will be automation that can specify headers. However, it can equally specify a query string. Selecting the content type by query string rather than headers makes the content unambiguous, I am sure whoever designed this feels very clever about it. I have seen a protocol specification built around this that made handling the protocol with the mime type infra pretty much impossible. This is a small technical detail of the whole OBS so it probably does not cause serious problem if it's 'clever' in a stupid way. Nonetheless, spreading examples of bad design is not great. Yes, the specification allows this but not everything specifications allow is a good idea.
Owner

It's seemed to handle in the go library as alternative that popped in my head was file extensions and that is more messy.. And I've only had one case where someone wanted to use this and they don't complain about Accept: header.

http.HandleFunc("GET /status/{Project}/{Package}/{Repository}", func(res http.ResponseWriter, req *http.Request) {

The code is here if you need to improve it. The ParseMimeHeader could probably also handle query parameters without changing any rest of the code.

It's seemed to handle in the go library as alternative that popped in my head was file extensions and that is more messy.. And I've only had one case where someone wanted to use this and they don't complain about `Accept:` header. https://src.opensuse.org/git-workflow/autogits/src/commit/20e1109602e65235afd9ce22dea361b518491c3147cb4d458d3328eaece6d315/obs-status-service/main.go#L328 The code is here if you need to improve it. The ParseMimeHeader could probably also handle query parameters without changing any rest of the code.
Owner

func ParseMimeHeader(req *http.Request) *MimeHeader {

This is the type function.

https://src.opensuse.org/git-workflow/autogits/src/commit/20e1109602e65235afd9ce22dea361b518491c3147cb4d458d3328eaece6d315/obs-status-service/mimeheader.go#L24 This is the type function.
Sign in to join this conversation.
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: git-workflow/autogits#95
No description provided.