if (ct.starts_with("grpc")) { if (ct.size() == (size_t)4 || ct[4] == ';') { if (is_grpc_ct) { *is_grpc_ct = true; } // assume that the default content type for grpc is proto. return HTTP_CONTENT_PROTO; } elseif (ct[4] == '+') { ct.remove_prefix(5); if (is_grpc_ct) { *is_grpc_ct = true; } } // else don't change ct. Note that "grpcfoo" is a valid but non-grpc // content-type in the sense of format. }
HttpContentType type = HTTP_CONTENT_OTHERS; if (ct.starts_with("json")) { type = HTTP_CONTENT_JSON; ct.remove_prefix(4); } elseif (ct.starts_with("proto-text")) { type = HTTP_CONTENT_PROTO_TEXT; ct.remove_prefix(10); } elseif (ct.starts_with("proto")) { type = HTTP_CONTENT_PROTO; ct.remove_prefix(5); } elseif (ct.starts_with("x-protobuf")) { type = HTTP_CONTENT_PROTO; ct.remove_prefix(10); } else { return HTTP_CONTENT_OTHERS; } return (ct.empty() || ct.front() == ';') ? type : HTTP_CONTENT_OTHERS;