Forum Discussion

Bob_10976's avatar
Bob_10976
Icon for Nimbostratus rankNimbostratus
Feb 24, 2011

iRule Error for HTTP::respond 404

Hello all,

 

 

I'm attempting to create an iRule that will block Microsoft Office Protocol Discovery User Agent from a specfic list of VS and I keep coming up with the error:

 

 

line 4: [wrong args] [HTTP::respond]

 

 

I'm still pretty green to iRule so if anyone has any thoughts on where I'm messing up please let me know. I have the posted the code below.

 

 


when HTTP_REQUEST {
switch -glob [string tolower [HTTP::header "User-Agent"]] {
"Microsoft Office Protocol Discovery"
HTTP::respond 404
 }
}

 

 

Thanks,

 

Bob
  • Hi Bob,

     

     

    Which LTM version are you testing on?

     

     

    I thought HTTP::respond accepted just a status code. Can you try this instead:

     

     

    HTTP::respond 404 content ""

     

     

    Aaron
  • Aaron,

    I'm using version 10.2.x

    Also I attempted your change, but received the following error:

    line 4: [wrong args] [HTTP::respond]

    line 4: [undefined procedure: content] [content]

    
    when HTTP_REQUEST {
    switch -glob [string tolower [HTTP::header "user-agent"]] {
    "microsoft office protocol discovery"
    HTTP::respond 404 content ""
    }
    }
    

  • Sorry, I wasn't reading your rule closely enough. There are a couple of brackets missing:

    
    when HTTP_REQUEST {
       switch -glob [string tolower [HTTP::header "user-agent"]] {
          "*microsoft office protocol discovery*" {
             HTTP::respond 404
          }
       }
    }
    

    Aaron
  • Thanks Aaron.. I see it now.. Btw just a quick follow up.. The iRule is working, I can use Fiddler and see a 404 response on the User Agent for microsoft office protocol discovery, however I'm finding that I also need to block the Microsoft-WebDAV-MiniRedir/6.1.7600 User Agent as well. I believe what I have below is correct, syntax wise but since its not blocking as I would expected I wanted to run it by this group to confirm its sound and maybe I'm looking over something else...

    
    
    when HTTP_REQUEST {
       switch -glob [string tolower [HTTP::header "user-agent"]] {
        "*microsoft office protocol discovery*" -
        "*microsoft-webdAV-miniredir/6.1.7600*" {
             HTTP::respond 404
          }
       }
    }
    
    

    Thanks,

    Bob
  • Make sure to set all characters in the user-agent pattern to lower case as you're setting the user-agent header value to lower case.

     

     

    "*microsoft-webdAV-miniredir/6.1.7600*" {

     

     

    Aaron
  • Wow!! Its always the little things that getcha.. Thanks a ton for all the help Aaron.

     

     

    Bob