Uploaded image for project: 'Traffic Server'
  1. Traffic Server
  2. TS-1980

Provide API for a plugin to also specify which body factory template to use for errors

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • 7.2.0
    • TS API
    • None

    Description

      Right now, there are only two APIs that allows plugins to set the HTTP status code and body message:

        tsapi void TSHttpTxnSetHttpRetBody(TSHttpTxn txnp, const char* body_msg, int plain_msg);
        tsapi void TSHttpTxnSetHttpRetStatus(TSHttpTxn txnp, TSHttpStatus http_retstatus);
      

      Since the body factory ("templates") are now the only way to produce error messages from within ATS itself, these APIs are now lacking a way to specify which template to use. I imagine three possibilities (at least):

      1) Make the last argument to TSHttpTxnSetHttpRetBody() be a multi-value variable, with the semantics of

      0 - body is HTML
      1 - body is plain text
      2 - body is a factory template name (e.g. "access#denied" or "shrek#ogre").

      This is probably pretty safe, but perhaps not super pretty.

      2) Make TSHttpTxnSetHttpRetStatus() also take a body factory argument, e.g.

        tsapi void TSHttpTxnSetHttpRetStatus(TSHttpTxn txnp, TSHttpStatus http_retstatus, const char* factory);
      

      factory should probably be a string here, and not constants, because users can put in arbitrary file names into the body factory. The string really is the filename. This would break compatibility of the APIs I think.

      3) We add a new API, e.g.

        tsapi void TSHttpTxnSetHttpFactory(TSHttpTxn txnp, const char* factory);
      

      Attachments

        Issue Links

          Activity

            People

              jaript Jari Alhonen
              zwoop Leif Hedstrom
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated: