HTTP vs gRPC

HTTP 200 OK vs gRPC 0 OK

HTTP 200 and gRPC OK both mean success, but gRPC OK travels inside an HTTP/2 200 response as a trailer. A gRPC call always returns HTTP 200 at the transport level — the actual success or failure is encoded in the grpc-status trailer, where 0 means OK.

คำอธิบาย

The request succeeded. The meaning depends on the HTTP method: GET returns the resource, POST reports the action result, HEAD returns headers only.

เมื่อคุณพบเห็น

The most common HTTP response — indicates the request was processed successfully.

วิธีแก้ไข

No fix needed. The request succeeded as expected.

0 OK
gRPC

คำอธิบาย

The operation completed successfully. Not an error; returned on success.

เมื่อคุณพบเห็น

The RPC completed without any issues. This is the expected response for every successful gRPC call.

วิธีแก้ไข

No fix needed — this indicates everything worked correctly.

ความแตกต่างหลัก

1.

HTTP 200 is the transport-level status; gRPC 0 OK is the application-level status in the grpc-status trailer.

2.

A gRPC error (e.g., NOT_FOUND) still arrives as HTTP 200 — you must check the grpc-status trailer for the real status.

3.

HTTP 200 implies the response body contains useful data; gRPC 0 OK means the protobuf response is valid.

4.

gRPC uses HTTP/2 under the hood, so every gRPC call is technically an HTTP/2 request returning 200.

5.

Monitoring gRPC services by HTTP status code alone will miss all gRPC errors — always check grpc-status.

ควรใช้อันไหนเมื่อไร

In HTTP REST APIs, return 200 for successful requests. In gRPC services, return status code 0 (OK) for successful RPCs. If you operate an API gateway that translates gRPC to HTTP, map gRPC 0 OK to HTTP 200 and ensure monitoring tools inspect grpc-status trailers, not just HTTP codes.

เรียนรู้เพิ่มเติม