Skip to content

Infer Content-Type header from producer and operation spec #387

@fredbi

Description

@fredbi

Source Location

File: client/request.go
Line: 301
Function: func (r *request) buildHTTP(mediaType string, basePath string, producers map[string]runtime.Producer, registry strfmt.Registry, auth runtime.ClientAuthInfoWriter) (*http.Request, error)

Context

When building the HTTP request with a payload, the Content-Type header is set to the provided mediaType parameter without further inference.

Analysis

This is related to issue #386. The comment suggests the code should:

  • Analyze the producer being used to determine the actual output format
  • Cross-reference with the operation's declared consumes types
  • Set Content-Type header based on what will actually be produced, not just what was requested

Original Comment

// TODO: infer most appropriate content type based on the producer used,
// and the `consumers` section of the spec/operation

This issue was created to track a TODO comment in the codebase.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions