Forum Discussion

Scott_Pemrick_8's avatar
Scott_Pemrick_8
Icon for Nimbostratus rankNimbostratus
Nov 30, 2010

iRule using WURFL API

Has anyone attempted an iRule for mobile user agent detection using a WURFL API? I was contemplating using pywurfl (python API). I have an idea of what I need to do, just curious if anyone had done any work in this area.

 

  • Hi Scott,

     

     

    Are you just trying to identify a mobile client by user-agent? If so, here is a recent discussion:

     

     

    Detecting mobile/wap browsers via user-agent and other headers

     

    http://devcentral.f5.com/Forums/tabid/1082223/asg/50/showtab/groupforums/aff/5/aft/86313/afv/topic/Default.aspx86381

     

     

    Or if you need the full capability reporting of WURFL, making an API call would probably be best. If the database size is ~12Mb and millions of records, you probably wouldn't want to load it into an LTM iRule table. In current LTM versions for querying an outside resource from an iRule are somewhat limited. You could use HTTP::retry to make an HTTP request to a webservice and then use logic in the iRule to handle the client's HTTP request. Deb wrote an article on this a while back:

     

     

    Conditioning iRule Logic on External Information - 01 - HTTP::retry

     

    http://devcentral.f5.com/Default.aspx?tabid=63&articleType=ArticleView&articleId=105

     

     

    Aaron
  • Aaron,

     

     

    Yes, I'm looking for the capability reporting from WURFL. The HTTP::retry is an interesting idea, thanks. Reading Deb's article, has "exec" been disabled as a command within an iRule? That might throw off my api approach.

     

     

    Scott
  • HTTP::retry is probably the easiest, supported method for doing this in current versions. Yes, exec is disabled:

     

     

    http://devcentral.f5.com/wiki/default.aspx/iRules/DisabledTclCommands.html

     

     

    Aaron
  • Thanks Aaron. One more question, and I can search for it, but do you have any examples handy on HTTP:retry to a webservice? Deb's article was calling a cgi.

     

     

    Scott
  • In Deb's example, the request which is retried to the webservice is set on this line:

    set LB_request [HTTP::request]

    So instead of using the client's original HTTP request, you could set it to something custom. If this was the request you wanted to send:

    
    POST /StockQuote HTTP/1.1
    Host: www.stockquoteserver.com
    Content-Type: text/xml; charset="utf-8"
    Content-Length: nnnn
    SOAPAction: "Some-URI"
    
    
        
            
                DIS
            
        
    
    

    Here is something you could try testing:

    
    set LB_request {POST /StockQuote HTTP/1.1
    Host: www.stockquoteserver.com
    Content-Type: text/xml; charset="utf-8"
    Content-Length: nnnn
    SOAPAction: "Some-URI"
    
    
        
            
                DIS
            
        
    }
    

    You'd need to manually calculate the payload length and set the content-length header accordingly.

    Aaron
  • Thanks Aaron. I really appreciate the responses. I was able to get the pywurfl working w/ an OOB request to a cgi. Then either redirect to the mobile site or use the HTTP:retry to process the original request. I trimmed down Deb's irule a little by having the cgi set a header. That way I could skip collecting and interrogating the response data. Just checked the header on the response. Thanks again.

     

     

    Scott
  • Hi Scott,

     

     

    Glad to hear it's working for you. For future reference, would you mind posting a sanitized copy of our rule?

     

     

    Thanks, Aaron