首页 > 分享, 插件开发 > a�?a?�?�?agea�?a??a?�e�?e�?httpa�?a?�?�?

a�?a?�?�?agea�?a??a?�e�?e�?httpa�?a?�?�?

2013年7月15日     浏览数:288 发表评论 阅读评论

a�?a?�?�?agea�?a??a?�e�?e�?httpa�?a?�?�?

    e??e��atscs�http headercs�a?�?�?i??a��a�za�?c�???�a??a�s??�a��a?�i??a?�?��a?zaS�cs�i??a?�e��cs�i??a?�?�?cs�e??a??a�?i??a?�???a??agee?�?��valuea�?a??a�?a�scs�http headercs�a?�?�?cs�e??????????�e?�c��a��c�?a��??�?��a��e�se?�a??replace-header??�a��a�?c�?cs�a?�?�?i??a��age??????x-age???a��c�?a?�e?�c��??�a��cs�a��??�i??a????�e�se?�??�?��a�?a?�a�?cs�??�a��i??a��a��a??a�?a???�?a??atscs�http headercs�?�?a??a��a??a?�a�???�a��a??a��es?a?�a��

a?�e??a��??�c��a??replace header??�a��a�?c�?cs�a?�?�?e??a?????a��c�?agea�?cs�a?�?�?i??a??e?�e�?a??c�???�cs�e�?e��?�?c?�a?sa��a?�c?�a�s
age

  • 0?�?a?�i?se??c�?a�Zc�???�a?�ats
  • 1?�?a?�i?se??c�?a�Zatsa?�???c��
  • 2?�?a?�i?se??c�?a�Z???c��a?�ats
  • 3?�?a?�i?se??c�?a�Zatsa?�c�???�
  • e��a�????TSPluginIniti??i?�a�??��i??a??e?�e�?e????�a��a??e?�e�?a?�?�?a?�e??a�?c�?a��a??a�?a?�i??e�?a?Za?Se??cs�c�???�a?????a��a??cs�i??e??a?????e�?c�?i??c?�a??a???�??�?a?�i??e?�e�?a?�?�?cs�???a?�e??e?�e??a�?c�?i?s

    // 140   TSHttpHookAdd(TS_HTTP_READ_RESPONSE_HDR_HOOK, TSContCreate(replace_header_plugin, NULL));
     140   TSHttpHookAdd(TS_HTTP_SEND_RESPONSE_HDR_HOOK, TSContCreate(replace_header_plugin, NULL));
    

    a�Za?Se??cs�a?�?�?a??a�?c?�a?�i??????SSTS_HTTP_READ_RESPONSE_HDR_HOOK?�????a??a?�TS_HTTP_SEND_RESPONSE_HDR_HOOKi??e?�a?�a??a??a?�i??e?????a�Za?Se??e�?a?�a�?e??e��i??e?�a??READa�?SEND???a??a?�a?Se??cs�2?�?a?�a�?3?�?a?�cs�(a??c?�0?�?a?�a�?1?�?a?�a?Scs�a?�a?�a??READ_REQUESTa�?SEND_REQUEST)i????�a��a?�?�?agea�?a?Za????�a??c�???�c�?e??a�Yc?�a?�i???��a�?a��c�?a?�SENDi??e??c�?3?�?a?�cs�i??c�???�c�?a??a�?c?�a?�i??e?�?��a�?a?Ya??a?sc�?a??atscs�c?�a�?a��a�?a��
    a��?��c�?a?�cs�i???�?a????�a��e�?e??e??e?�e�?a?�?�????3?�?a?�i????�a��a?�a��a��i?s

  • 1a�?replace_header_plugini??i?�cs�case
  • //  87   case TS_EVENT_HTTP_READ_RESPONSE_HDR:
    87   case TS_EVENT_HTTP_SEND_RESPONSE_HDR:
    

  • 2a�?replace_headeri??i?�cs�response header
  • //  49   if (TSHttpTxnServerRespGet(txnp, &resp_bufp, &resp_loc) != TS_SUCCESS) {
    //  50     TSError("couldn't retrieve server response header.\n");
    //  51     goto done;
    //  52   }
      49   if (TSHttpTxnClientRespGet(txnp, &resp_bufp, &resp_loc) != TS_SUCCESS) {
      50     TSError("couldn't retrieve server response header.\n");
      51     goto done;
      52   }
    

    c�?e?�a?�a�?a?Sa?�a??a?�?�?cs�a?�?�?i??aY?c?�cs�a�?a??a��c��???a?sa�?a?�i??cZ�a??a��???e�?c?Y?�?cs�aZ�a?�?�?agee?�a??http headera?�i??a�?e??a�?c�?i??c��a?Ze?�c��e�?e�S

    //  54   field_loc = TSMimeHdrFieldFind(resp_bufp, resp_loc, TS_MIME_FIELD_ACCEPT_RANGES, TS_MIME_LEN_ACCEPT_RANGES);
    54   field_loc = TSMimeHdrFieldFind(resp_bufp, resp_loc, TS_MIME_FIELD_AGE, TS_MIME_LEN_AGE);
      55   if (field_loc == TS_NULL_MLOC) {
      56     /* field was not found */
      57 
      58     /* create a new field in the header */
      59     TSMimeHdrFieldCreate(resp_bufp, resp_loc, &field_loc); /* Probably should check for errors. */
      60     /* set its name */
    //  61     TSMimeHdrFieldNameSet(resp_bufp, resp_loc, field_loc, TS_MIME_FIELD_ACCEPT_RANGES, TS_MIME_LEN_ACCEPT_RANGES);
      61     TSMimeHdrFieldNameSet(resp_bufp, resp_loc, field_loc, "x-age", 5);
      62     /* set its value */
    //  63     TSMimeHdrFieldValueAppend(resp_bufp, resp_loc, field_loc, -1, "none", 4);
      62     /*add default value*/
      63     TSMimeHdrFieldValueIntInsert(resp_bufp, resp_loc, field_loc, -1, 0);
      64     /* insert it into the header */
      65     TSMimeHdrFieldAppend(resp_bufp, resp_loc, field_loc);
      66     TSHandleMLocRelease(resp_bufp, resp_loc, field_loc);
      67     TSHandleMLocRelease(resp_bufp, TS_NULL_MLOC, resp_loc);
      68   } else {
    //  69     /* clear the field */
    //  70     TSMimeHdrFieldValuesClear(resp_bufp, resp_loc, field_loc);
    //  71     /* set the value to "none" */
    //  72     TSMimeHdrFieldValueStringInsert(resp_bufp, resp_loc, field_loc, -1, "none", 4);
    /* Just need to replace its name*/
    TSMimeHdrFieldNameSet(resp_bufp, resp_loc, field_loc, "x-age", 5);
      73     TSHandleMLocRelease(resp_bufp, resp_loc, field_loc);
      74     TSHandleMLocRelease(resp_bufp, TS_NULL_MLOC, resp_loc);
      75   }
    

      a??a?�i???�???�a?Se??a?�?�?cs�a�?c�?e?�c��a��c�?a?�a?�?�?cs�a��a�?i??c��a?�a??a?�?�????54e??i??e?�e�????TSMimeHdrFieldFindi??i?�a�??��i??a��????�?a?�e?�a??http headeri???��a�?e?�e�?a��e�??�????AGEi???SSa?�a??ACCEPT_RANGEe??e�??�????AGEi??e?�?��a��????�?a?�AGEe?�a??a�?aYYa��
      c��a?Za��???a��c?�a?�i??a??e?�e�???�a?�c�???�a��i?sa?�c�?????�?a?�a?�i????�agee?�a??http headeri?�a?�a?�c�????????�?a?�a��e��a�?a��c?�cs�????????�?�?a?�cs�??�a��i???????�?�?a?�cs�e????�a��e?�e�??��aS�e??a�?aYYi??a?�?��aS�a?�a??a??a��a?�a�?i??a?Z?????�a��a?�?�?a?�61e??a�?63e??i??a��a?�c��61e??????��aS�http headercs�a??c��x-agei??a��a??e??http headera??????��a��cs�i??a��?��?????�a??e�?i??a??e?�e�???�a��?????�aZ�c�?a??a�sa?�i???��aS�e?�a??a??e�?i??e�????c�??Z?a��a��??�a��e?�e�?a?�?�???�a?Za?�a??a?�?��i??c��a?�a?????a??a��i??a??x-agei??a?Ze??a?�a??a?�?��???e�?a?�i??x-age?��a��5a??a��c��i??a��?��e�?a?�???5a��a??a��a�?c�??��aS�a?�i??c��a?Za��???a�?a?�i??a??e?�e�?e�?????�?i??x-agea??e�????a?�a??intc��az�cs�i??a��?��e?�e�?a??c�?TSMimeHdrFieldValueIntInserti??i?�a�??��i???��aS�a?�a??Intc��az�cs�a�?i??a??e?�e�?e�?e��e�?c?�???0a��
      c��a?Z????�?a?�cs�??�a��i??a��?z??�?a?�a?�a��a??c��a?�a?�a??e?�e�?a��agea?�?�????x-agea��a??a�?a?�i??a��a��cs�e??a??e?�e�?a?sa��a?�?�?a??i??a��?��a??a�??SS69~72e??cs�?�?a??e??a??e?�e�?a?�i??a��a��e?�e�?e�??��seta?�a?�agecs�namea??x-agea��a??a�?a?�i??e?�e�?a?Ya??e�?a??a?�x-agecs�e�?a?�???5a��
      a??a?�i??a?�e?�e�?a�?c�?cs�a?�?�?a��c��a�????a?�i??c��a?Za��????��e?�??�a��cs�a?�?�????a?�?�?c?�a?�i??c?�e?�a��e?�e????�a��
      make & make install

    c��a?Z???a??plugin.configa?�?��aS�e????�a��i??a??a��c?�e�?a��a?�a?�i????�e?�e�??????�a?�?�?a??a��i??a��?��e?????a?�replace-header.soi???��aS�a�???�a?�a?Ztraffic_line -xa?�a?�a�?a��c�Y?�?a?�i??a??a�?c?�c?�?�??z?a��a��
    1

    分类: 分享, 插件开发 标签:
    1. 本文目前尚无任何评论.
    1. 本文目前尚无任何 trackbacks 和 pingbacks.