trevorwang / retrofit.dart

retrofit.dart is an dio client generator using source_gen and inspired by Chopper and Retrofit.
https://mings.in/retrofit.dart/
MIT License
1.06k stars 241 forks source link

`Content-Type` is automatically set when connecting with `Protobuf` #683

Open KyoheiG3 opened 1 month ago

KyoheiG3 commented 1 month ago

Describe the bug Even if setting Content-Type in the @Headers annotation, if the payload conforms to GeneratedMessage, it will be automatically set to application/x-protobuf.

To Reproduce Generates Protobuf request.

@POST('/path/to/endpoint')
@Headers({'Content-Type': 'application/proto'})
Future<void> postMessage({
  @Body() Params message,
});

Expected behavior It should not be automatically set to application/x-protobuf.

Additional context We are using Connect for our server. This framework provides REST and RPC, and when making REST requests with Protobuf, it requires setting the Content-Type to application/proto. Retrofit will automatically set it to application/x-protobuf if the payload inherits to GeneratedMessage. Is there a way to not set this value automatically or to change it to application/proto?

The specification of Content-Type of Connect is here.

Thanks.