Forum Discussion

Roger_Oliver_78's avatar
Roger_Oliver_78
Icon for Nimbostratus rankNimbostratus
Jul 24, 2007

More Custom WAP Irules

I first want to thank everyone that has done WAP before. I liked the Irules I saw and got most of them to work in my test. However I have a problem some of the newer phones do not allow multiple redirects and I'm running into a crunch.

 

 

This is a sample of the code that my "WAP content" provider wants me to use to do the redirection based on the phone. This is not an irule of course but I have to find a way to make it an irule. My site went pure Ruby on Rails so I'm kinda in a bind.

 

 

The problem is they need me to point different phones to different "http://wap.vendor.com/partnergenericURL"

 

 

<% String accept = request.getHeader("accept");

 

if (accept != null) {

 

int i = accept.indexOf("wap");

 

int j = accept.indexOf("vnd.wap.xhtml+xml");

 

if (i > 0 || j > 0)

 

response.sendRedirect("http://wap.vendor.com/partnergenericURL");

 

else

 

//display partner homepage page normally

 

} else {

 

// display partner homepage page normally

 

}

 

%>

 

 

I forgot to add this. This is my current Irule based on the WAP irules I have found here on the site. What they are "saying" is that Nextel and some other vendor do not allow more then one redirect.

 

 

----

 

when HTTP_REQUEST {

 

 

switch -glob [HTTP::header User-Agent] {

 

"*Java/1.4.1_02*" -

 

"*Blazer*" -

 

"*blazer*" -

 

"*palm*" -

 

"*Palm*" -

 

"*SMARTPHONE*" -

 

"*Smartphone*" -

 

"*smartphone*" -

 

"*MOT-*" -

 

"*RAZR*" -

 

"*AUDIOVOX*" -

 

"*Symbian*" -

 

"*symbian*" -

 

"*NOKIA*" -

 

"*Nokia*" -

 

"*Sony Ericsson*" -

 

"*Samsung*" -

 

"*LG 8*" -

 

"*Alcatel 735i*" -

 

"*Nextel*" -

 

"*Windows CE*" -

 

"*BlackBerry*" -

 

"*Blackberry*" -

 

"*NetFront*" {

 

HTTP::redirect "http://wap.vendor.com/foo"

 

return

 

}

 

}

 

 

switch -glob [HTTP::header Accept] {

 

"*text/vnd.wap.wml*" -

 

"*text/vnd.rim.html*" {

 

HTTP::redirect "http://wap.vendor.com/foo/wmlfeed"

 

return

 

}

 

}

 

 

switch -glob [HTTP::header User-Agent] {

 

"*hiptop*" -

 

"*AvantGo*" -

 

"*Danger*" {

 

HTTP::redirect "http://wap2.vendor.com/foo/xmlfeed"

 

return

 

}

 

}

 

 

----

 

 

Thank you all for your help and input. I'm going to continue to search the forums

 

3 Replies

  • For this code

     

     

    <% String accept = request.getHeader("accept");
    if (accept != null) {
    int i = accept.indexOf("wap");
    int j = accept.indexOf("vnd.wap.xhtml+xml");
    if (i > 0 || j > 0)
    response.sendRedirect("http://wap.vendor.com/partnergenericURL");
    else
    //display partner homepage page normally
    } else {
    // display partner homepage page normally
    }
    %>

     

     

    The equivalent iRule would be

     

     

    when HTTP_REQUEST {
      if { [HTTP::header exists "accept"] } {
        switch -glob [HTTP::header "accept"] {
          "*wap*" -
          "*vnd.wap.xhtml+xml*" {
            HTTP::redirect "http://wap.vendor.com/partnergenericURL"
          }
        }
      }
    }

     

     

    -Joe
  • Thank you

     

     

    This is what I got now and it is working better... The problem seems to be that every phone vendor and version of phone has problems, as I change the order I fix one and break another. I will have to keep playing with it however your solution has helped me find a light in the darkness that is the iphone world.

     

     

    Again thank you for the help.

     

     

    when HTTP_REQUEST {

     

     

    switch -glob [HTTP::header User-Agent] {

     

    "*hiptop*" -

     

    "*AvantGo*" -

     

    "*Danger*" {

     

    HTTP::redirect "http://wap.vendor.com/partnergenericURL-D"

     

    return

     

    }

     

    }

     

     

    switch -glob [HTTP::header Accept] {

     

    "*vnd.wap.xhtml+xml*" -

     

    "*vnd.rim.html*" {

     

    HTTP::redirect "http://wap.vendor.com/partnergenericURL-C"

     

    return

     

    }

     

    }

     

     

    switch -glob [HTTP::header Accept] {

     

    "*vnd.wap.html*" {

     

    HTTP::redirect "http://wap.vendor.com/partnergenericURL-B"

     

    return

     

    }

     

    }

     

     

    switch -glob [HTTP::header Accept] {

     

    "*text/vnd.wap.wml*" {

     

    HTTP::redirect "http://wap.vendor.com/partnergenericURL-A"

     

    return

     

    }

     

    }

     

    if { [matchclass [string tolower [HTTP::uri] ] starts_with $::ot_recover] > 0 } {

     

    pool OLD_WEB_POOL

     

    } else {

     

    pool WEB_POOL

     

    }

     

    }

     

     

  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    It looks like you're closer...let's see if I can help a little.

    You're going to want only one switch per header, otherwise you're going to run into issues, especially since you're using redirects and return statements. Try condensing these a bit, like:

    
    when HTTP_REQUEST {
      switch -glob [HTTP::header User-Agent] {
        "*hiptop*" -
        "*AvantGo*" -
        "*Danger*" {
          HTTP::redirect "http://wap.vendor.com/partnergenericURL-D"
          return
        }
      }
      switch -glob [HTTP::header Accept] {
        "*vnd.wap.xhtml+xml*" -
        "*vnd.rim.html*" {
          HTTP::redirect "http://wap.vendor.com/partnergenericURL-C"
          return
        }
        "*vnd.wap.html*" {
          HTTP::redirect "http://wap.vendor.com/partnergenericURL-B"
          return
        }
        "*text/vnd.wap.wml*" {
          HTTP::redirect "http://wap.vendor.com/partnergenericURL-A"
          return
        }
      }
      if { [matchclass [string tolower [HTTP::uri] ] starts_with $::ot_recover] > 0 } {
        pool OLD_WEB_POOL
      } else {
        pool WEB_POOL
      }
    }

    That's a good first step in troubleshooting, anyway. If you still have problems, at least the logic will be a bit more condensed and you won't have to worry about the other switch statements not being evaluated.

    HTH,

    Colin