Search code examples
c++http-status-codeshresult

HTTP Status code to HRESULT mapping


I'm looking at developing a COM wrapper library in C++ for an RESTful web service, and would like to know if there is any standard approach for mapping HTTP Status code values to HRESULTs that will be returned over the COM API. I've had a scan through the definitions in WinError.h, but don't see anything that is appropriate. I know that you can define your own range of HRESULT values, but (as always) I'd prefer to go with a standard approach if one exists.

Thanks for any help in advance.


Solution

  • One way is to use BitsMsg.h from Microsoft SDK for a set of HTTP Status codes

    e.g. 404 is defined as:

    #define BG_E_HTTP_ERROR_404              0x80190194L
    // ^^ The requested URL does not exist on the server.
    

    To view these codes online, use the following links: HRESULTS: FACILITY_HTTP or BitsMsg.h