You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficserver.apache.org by "James Peach (Created) (JIRA)" <ji...@apache.org> on 2011/12/08 04:09:43 UTC

[jira] [Created] (TS-1045) PATCH: add new TSFetchHdrGet API

PATCH: add new TSFetchHdrGet API
--------------------------------

                 Key: TS-1045
                 URL: https://issues.apache.org/jira/browse/TS-1045
             Project: Traffic Server
          Issue Type: Improvement
          Components: HTTP
            Reporter: James Peach
            Priority: Minor
         Attachments: 0007-Add-new-public-API-TSFetchHdrGet.patch

TSFetchUrl does not provide any way to get the headers from the result. This patch adds a new API TSFetchHdrGet(), which is analogous to TSFetchRespGet() and returns the headers.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (TS-1045) PATCH: add new TSFetchHdrGet API

Posted by "Brian Geffon (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TS-1045?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13164974#comment-13164974 ] 

Brian Geffon commented on TS-1045:
----------------------------------

You can get headers from a request sent via TSFetchURL using standard ATS APIs, I do it all the time:

 const char *dataStart = TSFetchRespGet(txn, &dataLen);
 const char *dataEnd = dataStart + dataLen;
 TSHttpParser parser = TSHttpParserCreate();
 TSMBuffer buf = TSMBufferCreate();
 TSMLoc hdrLoc = TSHttpHdrCreate(buf);
 TSHttpHdrTypeSet(buf, hdrLoc, TS_HTTP_TYPE_RESPONSE);
 if (TSHttpHdrParseResp(parser, buf, hdrLoc, &dataStart, dataEnd) == TS_PARSE_DONE)
 {
   // you can now access hdrLoc like any other TSMLoc to a header

 }
                
> PATCH: add new TSFetchHdrGet API
> --------------------------------
>
>                 Key: TS-1045
>                 URL: https://issues.apache.org/jira/browse/TS-1045
>             Project: Traffic Server
>          Issue Type: Improvement
>          Components: HTTP
>            Reporter: James Peach
>            Priority: Minor
>         Attachments: 0007-Add-new-public-API-TSFetchHdrGet.patch
>
>
> TSFetchUrl does not provide any way to get the headers from the result. This patch adds a new API TSFetchHdrGet(), which is analogous to TSFetchRespGet() and returns the headers.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (TS-1045) PATCH: add new TSFetchHdrGet API

Posted by "Leif Hedstrom (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TS-1045?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13181723#comment-13181723 ] 

Leif Hedstrom commented on TS-1045:
-----------------------------------

James: Do you want me to review and commit the patch in https://issues.apache.org/jira/secure/attachment/12509025/0001-Add-new-public-API-TSFetchHdrGet.patch ?
                
> PATCH: add new TSFetchHdrGet API
> --------------------------------
>
>                 Key: TS-1045
>                 URL: https://issues.apache.org/jira/browse/TS-1045
>             Project: Traffic Server
>          Issue Type: Improvement
>          Components: HTTP
>            Reporter: James Peach
>            Assignee: Leif Hedstrom
>            Priority: Minor
>             Fix For: 3.1.2
>
>         Attachments: 0001-Add-new-public-API-TSFetchHdrGet.patch, 0007-Add-new-public-API-TSFetchHdrGet.patch, TS-1045-formatting.diff
>
>
> TSFetchUrl does not provide any way to get the headers from the result. This patch adds a new API TSFetchHdrGet(), which is analogous to TSFetchRespGet() and returns the headers.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (TS-1045) PATCH: add new TSFetchHdrGet API

Posted by "James Peach (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TS-1045?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13182343#comment-13182343 ] 

James Peach commented on TS-1045:
---------------------------------

Let's WONTFIX this one. The TSFetchUrl API is a bit weird but you can get the headers when you use right wakeup events, or have an unmodified ATS tree.
                
> PATCH: add new TSFetchHdrGet API
> --------------------------------
>
>                 Key: TS-1045
>                 URL: https://issues.apache.org/jira/browse/TS-1045
>             Project: Traffic Server
>          Issue Type: New Feature
>          Components: HTTP
>            Reporter: James Peach
>            Assignee: Leif Hedstrom
>            Priority: Minor
>             Fix For: 3.1.2
>
>         Attachments: 0001-Add-new-public-API-TSFetchHdrGet.patch, 0007-Add-new-public-API-TSFetchHdrGet.patch, TS-1045-formatting.diff
>
>
> TSFetchUrl does not provide any way to get the headers from the result. This patch adds a new API TSFetchHdrGet(), which is analogous to TSFetchRespGet() and returns the headers.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Issue Comment Edited] (TS-1045) PATCH: add new TSFetchHdrGet API

Posted by "Brian Geffon (Issue Comment Edited) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TS-1045?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13164974#comment-13164974 ] 

Brian Geffon edited comment on TS-1045 at 12/8/11 4:12 AM:
-----------------------------------------------------------

You can get headers from a request sent via TSFetchURL using standard ATS APIs

 const char *dataStart = TSFetchRespGet(txn, &dataLen);
 const char *dataEnd = dataStart + dataLen;
 TSHttpParser parser = TSHttpParserCreate();
 TSMBuffer buf = TSMBufferCreate();
 TSMLoc hdrLoc = TSHttpHdrCreate(buf);
 TSHttpHdrTypeSet(buf, hdrLoc, TS_HTTP_TYPE_RESPONSE);
 if (TSHttpHdrParseResp(parser, buf, hdrLoc, &dataStart, dataEnd) == TS_PARSE_DONE)
 {
   // you can now access hdrLoc like any other TSMLoc to a header

 }
                
      was (Author: briang):
    You can get headers from a request sent via TSFetchURL using standard ATS APIs, I do it all the time:

 const char *dataStart = TSFetchRespGet(txn, &dataLen);
 const char *dataEnd = dataStart + dataLen;
 TSHttpParser parser = TSHttpParserCreate();
 TSMBuffer buf = TSMBufferCreate();
 TSMLoc hdrLoc = TSHttpHdrCreate(buf);
 TSHttpHdrTypeSet(buf, hdrLoc, TS_HTTP_TYPE_RESPONSE);
 if (TSHttpHdrParseResp(parser, buf, hdrLoc, &dataStart, dataEnd) == TS_PARSE_DONE)
 {
   // you can now access hdrLoc like any other TSMLoc to a header

 }
                  
> PATCH: add new TSFetchHdrGet API
> --------------------------------
>
>                 Key: TS-1045
>                 URL: https://issues.apache.org/jira/browse/TS-1045
>             Project: Traffic Server
>          Issue Type: Improvement
>          Components: HTTP
>            Reporter: James Peach
>            Priority: Minor
>         Attachments: 0007-Add-new-public-API-TSFetchHdrGet.patch
>
>
> TSFetchUrl does not provide any way to get the headers from the result. This patch adds a new API TSFetchHdrGet(), which is analogous to TSFetchRespGet() and returns the headers.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (TS-1045) PATCH: add new TSFetchHdrGet API

Posted by "James Peach (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TS-1045?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13168530#comment-13168530 ] 

James Peach commented on TS-1045:
---------------------------------

Oh, does TSFetchPageRespGet() return the whole response object? In that case I guess Brian's suggestion would work?

It's not immediately obvious to me how I would get the response body using the TSMBuffer and TSMLoc.
                
> PATCH: add new TSFetchHdrGet API
> --------------------------------
>
>                 Key: TS-1045
>                 URL: https://issues.apache.org/jira/browse/TS-1045
>             Project: Traffic Server
>          Issue Type: Improvement
>          Components: HTTP
>            Reporter: James Peach
>            Assignee: Leif Hedstrom
>            Priority: Minor
>             Fix For: 3.1.2
>
>         Attachments: 0007-Add-new-public-API-TSFetchHdrGet.patch
>
>
> TSFetchUrl does not provide any way to get the headers from the result. This patch adds a new API TSFetchHdrGet(), which is analogous to TSFetchRespGet() and returns the headers.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (TS-1045) PATCH: add new TSFetchHdrGet API

Posted by "Leif Hedstrom (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TS-1045?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Leif Hedstrom updated TS-1045:
------------------------------

    Attachment: TS-1045-formatting.diff

Suggested changes for formatting, and making the functions more like the other similar APIs.

Maybe this won't be necessary at all, but jpeach will let us know what will be the right solution for these APIs.
                
> PATCH: add new TSFetchHdrGet API
> --------------------------------
>
>                 Key: TS-1045
>                 URL: https://issues.apache.org/jira/browse/TS-1045
>             Project: Traffic Server
>          Issue Type: Improvement
>          Components: HTTP
>            Reporter: James Peach
>            Assignee: Leif Hedstrom
>            Priority: Minor
>             Fix For: 3.1.2
>
>         Attachments: 0007-Add-new-public-API-TSFetchHdrGet.patch, TS-1045-formatting.diff
>
>
> TSFetchUrl does not provide any way to get the headers from the result. This patch adds a new API TSFetchHdrGet(), which is analogous to TSFetchRespGet() and returns the headers.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (TS-1045) PATCH: add new TSFetchHdrGet API

Posted by "Leif Hedstrom (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TS-1045?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13168519#comment-13168519 ] 

Leif Hedstrom commented on TS-1045:
-----------------------------------

Reading this, and the code, I'm starting to wonder if TSFetchPageRespGet() is a broken API ? I mean, the differences between it, and the new TSFetchHdrGet(), is simply getting the header from the response. Is there ever a case when we need all three of these APIs (TSFetchPageRespGet(), TSFetchRespGet() and TSFetchHdrGet() ) ?
                
> PATCH: add new TSFetchHdrGet API
> --------------------------------
>
>                 Key: TS-1045
>                 URL: https://issues.apache.org/jira/browse/TS-1045
>             Project: Traffic Server
>          Issue Type: Improvement
>          Components: HTTP
>            Reporter: James Peach
>            Assignee: Leif Hedstrom
>            Priority: Minor
>             Fix For: 3.1.2
>
>         Attachments: 0007-Add-new-public-API-TSFetchHdrGet.patch
>
>
> TSFetchUrl does not provide any way to get the headers from the result. This patch adds a new API TSFetchHdrGet(), which is analogous to TSFetchRespGet() and returns the headers.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (TS-1045) PATCH: add new TSFetchHdrGet API

Posted by "Leif Hedstrom (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TS-1045?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Leif Hedstrom updated TS-1045:
------------------------------

    Fix Version/s: 3.1.2
    
> PATCH: add new TSFetchHdrGet API
> --------------------------------
>
>                 Key: TS-1045
>                 URL: https://issues.apache.org/jira/browse/TS-1045
>             Project: Traffic Server
>          Issue Type: Improvement
>          Components: HTTP
>            Reporter: James Peach
>            Priority: Minor
>             Fix For: 3.1.2
>
>         Attachments: 0007-Add-new-public-API-TSFetchHdrGet.patch
>
>
> TSFetchUrl does not provide any way to get the headers from the result. This patch adds a new API TSFetchHdrGet(), which is analogous to TSFetchRespGet() and returns the headers.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (TS-1045) PATCH: add new TSFetchHdrGet API

Posted by "Leif Hedstrom (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TS-1045?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13168541#comment-13168541 ] 

Leif Hedstrom commented on TS-1045:
-----------------------------------

I'm honestly not sure what the intention was here... There seems to be overlap for sure. I mean, if TSFetchPageRespGet() returns the full "response", then why do we need TSFetchRespGet()? That's why I'm wondering that we either

a) Keep only TSFetchPageRespGet(), and expose appropriate APIs to get stuff out of it.

or

b) Eliminate TSFetchPageRespGet(), and only keep TSFetchRespGet() and a new TSFetchHdrGet()


Or is there ever a case where we'd need all three ?

                
> PATCH: add new TSFetchHdrGet API
> --------------------------------
>
>                 Key: TS-1045
>                 URL: https://issues.apache.org/jira/browse/TS-1045
>             Project: Traffic Server
>          Issue Type: Improvement
>          Components: HTTP
>            Reporter: James Peach
>            Assignee: Leif Hedstrom
>            Priority: Minor
>             Fix For: 3.1.2
>
>         Attachments: 0007-Add-new-public-API-TSFetchHdrGet.patch
>
>
> TSFetchUrl does not provide any way to get the headers from the result. This patch adds a new API TSFetchHdrGet(), which is analogous to TSFetchRespGet() and returns the headers.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (TS-1045) PATCH: add new TSFetchHdrGet API

Posted by "Brian Geffon (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TS-1045?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13165434#comment-13165434 ] 

Brian Geffon commented on TS-1045:
----------------------------------

Your example is not a TSFetchURL request, it looks like a request from the browser for favicon.ico. It should work if it's a TSFetchURL request.
                
> PATCH: add new TSFetchHdrGet API
> --------------------------------
>
>                 Key: TS-1045
>                 URL: https://issues.apache.org/jira/browse/TS-1045
>             Project: Traffic Server
>          Issue Type: Improvement
>          Components: HTTP
>            Reporter: James Peach
>            Priority: Minor
>         Attachments: 0007-Add-new-public-API-TSFetchHdrGet.patch
>
>
> TSFetchUrl does not provide any way to get the headers from the result. This patch adds a new API TSFetchHdrGet(), which is analogous to TSFetchRespGet() and returns the headers.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (TS-1045) PATCH: add new TSFetchHdrGet API

Posted by "James Peach (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TS-1045?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

James Peach updated TS-1045:
----------------------------

    Attachment: 0001-Add-new-public-API-TSFetchHdrGet.patch

Updated TSFetchHdrGet() patch that adds the error checking from TSFetchPageRespGet().

It also deprecates FSFetchPageRespGet().
                
> PATCH: add new TSFetchHdrGet API
> --------------------------------
>
>                 Key: TS-1045
>                 URL: https://issues.apache.org/jira/browse/TS-1045
>             Project: Traffic Server
>          Issue Type: Improvement
>          Components: HTTP
>            Reporter: James Peach
>            Assignee: Leif Hedstrom
>            Priority: Minor
>             Fix For: 3.1.2
>
>         Attachments: 0001-Add-new-public-API-TSFetchHdrGet.patch, 0007-Add-new-public-API-TSFetchHdrGet.patch, TS-1045-formatting.diff
>
>
> TSFetchUrl does not provide any way to get the headers from the result. This patch adds a new API TSFetchHdrGet(), which is analogous to TSFetchRespGet() and returns the headers.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (TS-1045) PATCH: add new TSFetchHdrGet API

Posted by "James Peach (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TS-1045?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13178266#comment-13178266 ] 

James Peach commented on TS-1045:
---------------------------------

TSFetchPageRespGet() takes a HTTPHdr * and returns a TSMBuffer and TSMLoc that you can use with the TSHttpHdr*() API. However, there is no way to get the HTTPHdr * in the first place. The TSFetch API passes the FetchSM * (cast to a HttpTxn) to the plugin callback. AFAICT there's no way to actually use TSFetchPageRespGet(); even if you could use it, it looks like it returns the HTTPHdr data, since the implementation is almost identical to the proposed TSFetchHdrGet().

Googling for TSFetchPageRespGet only turns up this page, so I expect that no-one has ever attempted to use it ;)
                
> PATCH: add new TSFetchHdrGet API
> --------------------------------
>
>                 Key: TS-1045
>                 URL: https://issues.apache.org/jira/browse/TS-1045
>             Project: Traffic Server
>          Issue Type: Improvement
>          Components: HTTP
>            Reporter: James Peach
>            Assignee: Leif Hedstrom
>            Priority: Minor
>             Fix For: 3.1.2
>
>         Attachments: 0007-Add-new-public-API-TSFetchHdrGet.patch, TS-1045-formatting.diff
>
>
> TSFetchUrl does not provide any way to get the headers from the result. This patch adds a new API TSFetchHdrGet(), which is analogous to TSFetchRespGet() and returns the headers.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (TS-1045) PATCH: add new TSFetchHdrGet API

Posted by "James Peach (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TS-1045?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13179304#comment-13179304 ] 

James Peach commented on TS-1045:
---------------------------------

Looks like I'm carrying a local patch that breaks TSFetchRespGet(), see TS-1043.
                
> PATCH: add new TSFetchHdrGet API
> --------------------------------
>
>                 Key: TS-1045
>                 URL: https://issues.apache.org/jira/browse/TS-1045
>             Project: Traffic Server
>          Issue Type: Improvement
>          Components: HTTP
>            Reporter: James Peach
>            Assignee: Leif Hedstrom
>            Priority: Minor
>             Fix For: 3.1.2
>
>         Attachments: 0001-Add-new-public-API-TSFetchHdrGet.patch, 0007-Add-new-public-API-TSFetchHdrGet.patch, TS-1045-formatting.diff
>
>
> TSFetchUrl does not provide any way to get the headers from the result. This patch adds a new API TSFetchHdrGet(), which is analogous to TSFetchRespGet() and returns the headers.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (TS-1045) PATCH: add new TSFetchHdrGet API

Posted by "James Peach (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TS-1045?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

James Peach updated TS-1045:
----------------------------

    Attachment: 0007-Add-new-public-API-TSFetchHdrGet.patch
    
> PATCH: add new TSFetchHdrGet API
> --------------------------------
>
>                 Key: TS-1045
>                 URL: https://issues.apache.org/jira/browse/TS-1045
>             Project: Traffic Server
>          Issue Type: Improvement
>          Components: HTTP
>            Reporter: James Peach
>            Priority: Minor
>         Attachments: 0007-Add-new-public-API-TSFetchHdrGet.patch
>
>
> TSFetchUrl does not provide any way to get the headers from the result. This patch adds a new API TSFetchHdrGet(), which is analogous to TSFetchRespGet() and returns the headers.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Assigned] (TS-1045) PATCH: add new TSFetchHdrGet API

Posted by "Leif Hedstrom (Assigned) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TS-1045?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Leif Hedstrom reassigned TS-1045:
---------------------------------

    Assignee: Leif Hedstrom
    
> PATCH: add new TSFetchHdrGet API
> --------------------------------
>
>                 Key: TS-1045
>                 URL: https://issues.apache.org/jira/browse/TS-1045
>             Project: Traffic Server
>          Issue Type: Improvement
>          Components: HTTP
>            Reporter: James Peach
>            Assignee: Leif Hedstrom
>            Priority: Minor
>             Fix For: 3.1.2
>
>         Attachments: 0007-Add-new-public-API-TSFetchHdrGet.patch
>
>
> TSFetchUrl does not provide any way to get the headers from the result. This patch adds a new API TSFetchHdrGet(), which is analogous to TSFetchRespGet() and returns the headers.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (TS-1045) PATCH: add new TSFetchHdrGet API

Posted by "James Peach (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TS-1045?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

James Peach updated TS-1045:
----------------------------

    Fix Version/s:     (was: 3.1.2)
    
> PATCH: add new TSFetchHdrGet API
> --------------------------------
>
>                 Key: TS-1045
>                 URL: https://issues.apache.org/jira/browse/TS-1045
>             Project: Traffic Server
>          Issue Type: New Feature
>          Components: HTTP
>            Reporter: James Peach
>            Assignee: James Peach
>            Priority: Minor
>         Attachments: 0001-Add-new-public-API-TSFetchHdrGet.patch, 0007-Add-new-public-API-TSFetchHdrGet.patch, TS-1045-formatting.diff
>
>
> TSFetchUrl does not provide any way to get the headers from the result. This patch adds a new API TSFetchHdrGet(), which is analogous to TSFetchRespGet() and returns the headers.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (TS-1045) PATCH: add new TSFetchHdrGet API

Posted by "James Peach (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TS-1045?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13165819#comment-13165819 ] 

James Peach commented on TS-1045:
---------------------------------

Nope, my example is definitely a TSFetchURL() request. The plugin I'm experimenting with is a simple proxy, so when I get a browser request, I make a corresponding TSFetchURL request.

TSFetchRespGet() returns the response body. If I apply your example code above, TSHttpHdrParseResp() returns TS_PARSE_CONT. This is a bogus result, because at the time of the call I'm handling the TSFetchURL() success event so I actually have all the data. Additionally, I would really expect TSHttpHdrParseResp() to return TS_PARSE_ERROR because it's being asked to return the body.

Hacked up code looks like this:

    TSHttpParser parser = TSHttpParserCreate();
    TSMBuffer buf = TSMBufferCreate();
    TSMLoc hdrLoc = TSHttpHdrCreate(buf);

    body = TSFetchRespGet(txn, &len);
    char * start;
    char * end;

    start = body;
    end = body + len;


    TSHttpHdrTypeSet(buf, hdrLoc, TS_HTTP_TYPE_RESPONSE);
    TSParseResult ret;

    ret = TSHttpHdrParseResp(parser, buf, hdrLoc,
            (const char **)&start, (const char *)end);
    debug_protocol("TSHttpHdrParseResp => %d", ret);
    if (ret != TS_PARSE_DONE) {
        return;
    }

And in the debugger, we see:

Breakpoint 1, send_http_txn_result (stream=0x1014069f0, txn=0x1030a50d0) at stream.cc:297
297	    TSHttpParser parser = TSHttpParserCreate();
(gdb) n
298	    TSMBuffer buf = TSMBufferCreate();
(gdb) n
299	    TSMLoc hdrLoc = TSHttpHdrCreate(buf);
(gdb) n
301	    body = TSFetchRespGet(txn, &len);
(gdb) n
305	    start = body;
(gdb) p body
$1 = 0x101171460 "<html><body><h1>It works!</h1></body></html>"

The code in FetchSM::process_fetch_read() is a bit confusing to me; I'm not very familiar with ATS internals. On TS_EVENT_VCONN_READ_READY, resp_reader consumes bytes twice in process_fetch_read() and then again in client_response_hdr.parse_resp(). By inspection I would have thought that this would over-consume, causing bytes to be skipped but that doesn't seem to happen. At any rate, it reliably returns only the response body.
                
> PATCH: add new TSFetchHdrGet API
> --------------------------------
>
>                 Key: TS-1045
>                 URL: https://issues.apache.org/jira/browse/TS-1045
>             Project: Traffic Server
>          Issue Type: Improvement
>          Components: HTTP
>            Reporter: James Peach
>            Priority: Minor
>         Attachments: 0007-Add-new-public-API-TSFetchHdrGet.patch
>
>
> TSFetchUrl does not provide any way to get the headers from the result. This patch adds a new API TSFetchHdrGet(), which is analogous to TSFetchRespGet() and returns the headers.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Closed] (TS-1045) PATCH: add new TSFetchHdrGet API

Posted by "James Peach (Closed) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TS-1045?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

James Peach closed TS-1045.
---------------------------

    
> PATCH: add new TSFetchHdrGet API
> --------------------------------
>
>                 Key: TS-1045
>                 URL: https://issues.apache.org/jira/browse/TS-1045
>             Project: Traffic Server
>          Issue Type: New Feature
>          Components: HTTP
>            Reporter: James Peach
>            Assignee: James Peach
>            Priority: Minor
>             Fix For: 3.1.2
>
>         Attachments: 0001-Add-new-public-API-TSFetchHdrGet.patch, 0007-Add-new-public-API-TSFetchHdrGet.patch, TS-1045-formatting.diff
>
>
> TSFetchUrl does not provide any way to get the headers from the result. This patch adds a new API TSFetchHdrGet(), which is analogous to TSFetchRespGet() and returns the headers.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (TS-1045) PATCH: add new TSFetchHdrGet API

Posted by "Leif Hedstrom (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TS-1045?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Leif Hedstrom updated TS-1045:
------------------------------

    Issue Type: New Feature  (was: Improvement)
    
> PATCH: add new TSFetchHdrGet API
> --------------------------------
>
>                 Key: TS-1045
>                 URL: https://issues.apache.org/jira/browse/TS-1045
>             Project: Traffic Server
>          Issue Type: New Feature
>          Components: HTTP
>            Reporter: James Peach
>            Assignee: Leif Hedstrom
>            Priority: Minor
>             Fix For: 3.1.2
>
>         Attachments: 0001-Add-new-public-API-TSFetchHdrGet.patch, 0007-Add-new-public-API-TSFetchHdrGet.patch, TS-1045-formatting.diff
>
>
> TSFetchUrl does not provide any way to get the headers from the result. This patch adds a new API TSFetchHdrGet(), which is analogous to TSFetchRespGet() and returns the headers.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (TS-1045) PATCH: add new TSFetchHdrGet API

Posted by "James Peach (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TS-1045?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13164988#comment-13164988 ] 

James Peach commented on TS-1045:
---------------------------------

Thanks Brian, I'll test that out and let you know.

AFAICT from gdb, TSFetchRespGet() returns the request body:

305	    body = TSFetchRespGet(txn, &len);
(gdb) 
306	    if (body) {
(gdb) 
307	        debug_http("body %p is %d bytes", body, len);

[Dec  7 20:36:22.064] Server {0x7fff7b5f9960} DIAG: body 0x10115e800 is 288 bytes

(gdb) p body
$2 = 0x10115e800 "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<html><head>\n<title>404 Not Found</title>\n</head><body>\n<h1>Not Found</h1>\n<p>The requested URL /favicon.ico was not found on this server.</p>\n<hr>\n<"...

                
> PATCH: add new TSFetchHdrGet API
> --------------------------------
>
>                 Key: TS-1045
>                 URL: https://issues.apache.org/jira/browse/TS-1045
>             Project: Traffic Server
>          Issue Type: Improvement
>          Components: HTTP
>            Reporter: James Peach
>            Priority: Minor
>         Attachments: 0007-Add-new-public-API-TSFetchHdrGet.patch
>
>
> TSFetchUrl does not provide any way to get the headers from the result. This patch adds a new API TSFetchHdrGet(), which is analogous to TSFetchRespGet() and returns the headers.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira