Skip to content

Lack of symmetry for streaming media types in WebClient and on the server with MVC #37009

Description

@dsyer

JacksonJsonDecoder has a list of mime types including APPLICATION_NDJSON.
But the ReactiveTypeHandler (used on the server side) has WILDCARD_SUBTYPE_SUFFIXED_BY_NDJSON so it supports a wider range of media types. Ideally they would be the same.

A workaround is to just use application/x-ndjson on the server. Or to replace the default JSON decoder on the client side:

	@BeforeEach
	void setUp(@Autowired WebClient.Builder builder, @LocalServerPort int port) {
		this.rest = builder.codecs(config -> {
			MimeType[] mimeTypes = new MimeType[] {
					MediaType.APPLICATION_JSON,
					new MediaType("application", "*+json"),
					MediaType.APPLICATION_NDJSON,
					MediaType.valueOf("application/*+x-ndjson")
			};
			JacksonJsonDecoder decoder = new JacksonJsonDecoder(JsonMapper.builder(), mimeTypes);
			config.defaultCodecs().jacksonJsonDecoder(decoder);
		}).baseUrl("http://localhost:" + port).build();
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions