<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi team,<div><br></div><div>writing this email to describe the issues I faced with the current iOS API trying to add a paging test case for Reddit and the changes I made to support it.&nbsp;</div><div><br></div><div>a)</div><div>To explain better I will start with the reddit response:</div><div><br></div><div><pre class="line-pre" style="line-height: 16px; word-wrap: break-word; width: 744px; margin-top: 0px; margin-bottom: 0px; padding: 0px; background-color: rgb(255, 255, 255); position: static; z-index: auto; "><div class="line" id="file-gistfile1-txt-LC1" style="font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; "><span style="font-family: Menlo; font-size: small; ">{</span></div><div class="line" id="file-gistfile1-txt-LC2"><font face="Menlo" size="2">    "data": {</font></div><div class="line" id="file-gistfile1-txt-LC3"><font face="Menlo" size="2">        "after": "t4_a7k1lt",</font></div><div class="line" id="file-gistfile1-txt-LC4"><font face="Menlo" size="2">        "before": t3_13j5ks,</font></div><div class="line" id="file-gistfile1-txt-LC5"><font face="Menlo" size="2">        "children": [</font></div><div class="line" id="file-gistfile1-txt-LC6"><font face="Menlo" size="2">            {</font></div><div class="line" id="file-gistfile1-txt-LC7"><font face="Menlo" size="2">                "data": {</font></div><div class="line" id="file-gistfile1-txt-LC8"><font face="Menlo" size="2">         /*snip*/</font></div><div class="line" id="file-gistfile1-txt-LC9"><font face="Menlo" size="2">   }</font></div><div class="line" id="file-gistfile1-txt-LC10"><font face="Menlo" size="2">            }</font></div><div class="line" id="file-gistfile1-txt-LC11"><font face="Menlo" size="2">        ],</font></div><div class="line" id="file-gistfile1-txt-LC12"><font face="Menlo" size="2">        "modhash": ""</font></div><div class="line" id="file-gistfile1-txt-LC13"><font face="Menlo" size="2">    },</font></div><div class="line" id="file-gistfile1-txt-LC14"><font face="Menlo" size="2">    "kind": "Listing"</font></div></pre><div><br></div></div><div>Currently in the iOS API with our default paging mechanisms (body and header), we don't support page parameters to be deeply nested in the body. &nbsp;Here the "after" and "before" params reside nested in the parent "data" element. Further, the value of those parameters are not 'query params', just simple strings pointing to the next and previous page.</div><div><br></div><div>For the Reddit case and for others that may come in the future which may have "unknown" paging mechanisms, I followed the approach Android does and introduced a PageExtractor interface. It's only purpose is to parse the appropriate content and return us with the "next" and "previous" links. Existing header/body mechanisms were refactored to separate classes that implement the PageExtractor interface. Further an additional &nbsp;configuration option in the PipeConfig &nbsp;was added [setPageExtractor] that set the appropriate extractor class.&nbsp;</div><div><br></div><div>Important to state is that&nbsp;this config option is&nbsp;entirely&nbsp;<b>optional. &nbsp;</b>Internally if not set, we will still use the appropriate page/header mechanism (still depending on the metadataLocation config option). Having this option will allow different and "exotic" page extractors to be plugged in by the users if necessary or if not still rely on our defaults.</div><div><br></div><div>You can see the Reddit page extractor in the test case&nbsp;<a href="https://github.com/cvasilak/aerogear-ios-integration/blob/AEROGEAR-1051.reddit-attempt-2/AeroGear-iOS-Integration/AeroGear-iOS-IntegrationTests/AGPagingBody_Reddit.m#L146">here</a></div><div><br></div><div>b)</div><div><br></div><div>Reddit authentication relies on setting more than one headers in the request, named "Cookie" and "modhash". &nbsp;The way these headers are set :</div><div><br></div><div>--&gt; client issues a login request</div><div>&lt;-- reddit responds with 'cookie' and 'modhash' elements in the <b>body of the response</b></div><div><br></div><div>The client then post process the response. That is, it creates two headers, the&nbsp;'Cookie' header &nbsp;with the value prefixed to "reddit_session=&lt;cookie value from the previous step.&gt;' &nbsp;and the 'modhash' from the previous step.</div><div><br></div><div>Our existing AGRestAuthenticator couldn't support this. Here there is more than one header returned in the body of the response and further it requires a small post-processing on the 'Cookie' element to add a 'reddit_session=' prefix. &nbsp;In order to support this, a new&nbsp;AGRedditAuthenticationModule was created that follows the AGAuthenticationModule interface. You can see it&nbsp;<a href="https://github.com/cvasilak/aerogear-ios-integration/blob/AEROGEAR-1051.reddit-attempt-2/AeroGear-iOS-Integration/AeroGear-iOS-IntegrationTests/AGPagingBody_Reddit.m#L25">here</a></div><div>I've seen that a similar approach is followed in Android too.</div><div><br></div><div>Thanks</div><div>Christos</div></body></html>