proofgeist / generator

Generator - Store, explore, share and create FileMaker Code
MIT License
35 stars 8 forks source link

Code to find last HTTP Headers not working #6

Closed toddgeist closed 7 years ago

toddgeist commented 7 years ago

The http header response handling is not working for this API: httpheader

I presume that there may be multiple http-headers (due to page forwarding?) and that we are only interested in the last one ... we thus need to find the last LINE starting with "http/":

I have changed the code to set $responseHeaders =

[
s = $responseHeaders;
tag = "http/" ;

p = Position( "¶" & s; "¶" & tag ; Length( s ) ; -1 )
] ;
Right ( s ; Length( s ) + 1 - p )
)

…which works (and using -1 in the pos function is also more efficient)

toddgeist commented 7 years ago

This is the API that was failing https://api.nasa.gov/planetary/apod