Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8151589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:26:06+00:00 2026-06-06T15:26:06+00:00

I have a custom implementation of a RESTful API for a PHP application that

  • 0

I have a custom implementation of a RESTful API for a PHP application that returns json data, and in order to communicate the status of the operation, ie whether there were failures in the request, I’m setting a custom HTTP Header with a (very tiny) json object as a string. This works well since I can send responses and easily retrieve them client side without messing with the actual data sent.

The question is, are there any drawbacks I may not have realized of using this method? It doesn’t seem to be very common for applications to set custom http headers, so I’m wondering whether it is a bad practice or bad “taste” somehow.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T15:26:09+00:00Added an answer on June 6, 2026 at 3:26 pm

    This is an interesting question. There shouldn’t be any reason for it to be a problem, but you should take a few things into account:

    1. The headers need to be unique to your application. Not just now, but forever. You should ensure you’re prefixing them, e.g. X-MyApplication-Foo: Bar. Not doing this might cause conflicts in future.
    2. Firewalls are sometimes (rarely) a little overzealous with filtering unknown HTTP headers. This shouldn’t be a problem, but it’s something to keep in mind.
    3. Older browsers have smaller limitations on header field sizes than modern browsers, so you need to test across as many as you can get hold of.

    Is there are reason you can’t use the standard HTTP error codes? I understand that you might want to provide stack traces or other useful debugging information, but in the case of an error, wouldn’t you just return a JSON blob that contains the error information, rather than the normal “result” JSON data? You could easily detect the difference based on the HTTP error code and handle the two cases differently.

    The reason I’m concerned by your suggested approach is that headers are used to alter or cause browser behaviour – they’re not intended to be a data storage mechanism.

    Pseudo-code example:

    switch(httpResponseCode)
    {
        case 200:
            parseResult(json);
            break;
        case 403:
            parseForbidden(json);
            break;
        case 500:
            parseServerError(json);
            break;
        default:
            // bad response code, handle appropriately
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For my application, I have a custom implementation of SharedPreferences . In API level
I have an application, which uses a custom implementation of MyLocationOverlay . In the
I have a custom windows implementation in a WPF app that hooks WM_GETMINMAXINFO as
I have a custom NSTableRowView implementation to display my data cells. The table also
Based on the Spring Data Document documentation , I have provided a custom implementation
We are using Spring Security 3. We have a custom implementation of PermissionEvaluator that
In MVC3 application I have my custom implementation of IPrincipal. I want to register
I have a custom JTree implementation that implemts convertValueToText . This implementation depends on
I have a custom implementation of IDataServiceMetadataProvider / IDataServiceQueryProvider / IDataServiceUpdateProvider, put together from
We have a custom QLPreviewController implementation, so we can control the buttons presented to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.