THRIFT-5373 HTTP status in case of Protocol/Transport exceptions
Client: netstd
Patch: Jens Geyer
diff --git a/lib/netstd/Thrift/Transport/Server/THttpServerTransport.cs b/lib/netstd/Thrift/Transport/Server/THttpServerTransport.cs
index 7271f50..dd30d3d 100644
--- a/lib/netstd/Thrift/Transport/Server/THttpServerTransport.cs
+++ b/lib/netstd/Thrift/Transport/Server/THttpServerTransport.cs
@@ -116,7 +116,12 @@
catch (TTransportException)
{
if (!context.Response.HasStarted) // if something goes bust, let the client know
- context.Response.StatusCode = 500;
+ context.Response.StatusCode = 500; // internal server error
+ }
+ catch (TProtocolException)
+ {
+ if (!context.Response.HasStarted) // if something goes bust, let the client know
+ context.Response.StatusCode = 400; // bad request, e.g. required field missing
}
finally
{