Forum Discussion

Jonathan_Edgewo's avatar
Jonathan_Edgewo
Icon for Nimbostratus rankNimbostratus
Mar 10, 2007

http 204 response with http::close statement

When using a rule that responds to http requests with a 204 response code, if it use the http::close statement after the response statement, I get this error in the log:

 

TCL error: Rule http_204 HTTP_REQUEST - Operation not supported line 2 invoked from within HTTP::close

 

 

I was also getting this error in the local traffic log while the http::close statement was in the irule.

 

 

Once i removed http::close, there were no more errors. Anyone have an idea why this wouldn't work?

 

 

an example of the iRule is:

 

 

when HTTP_REQUEST {

 

HTTP::respond 204

 

HTTP::close

 

}
  • bl0ndie_127134's avatar
    bl0ndie_127134
    Historic F5 Account
    HTTP::close has some problems when running with HTTP::respond. Try using TCP::close instead (it won't advertise 'Connection: close' but it does do the right thing). HTTP::respond is being enhanced in the next release to allow you to specify a close in that rule.
  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    Hi bl0ndie,

    What's the functional difference between using HTTP::close compared with TCP::close in 9.4.5? What is an HTTP connection? Is it only supposed to set the Connection header to Close versus FIN'ing the connection with a TCP::close?

    Also, it looks like the HTTP::close command still doesn't work in 9.4.5 in HTTP_RESPONSE:

     
     when HTTP_RESPONSE { 
      
        HTTP::respond 200 content "responded" 
        HTTP::respond 200 content "responded" Connection Close 
      
        log local0. "TCP close" 
        TCP::close 
      
        log local0. "HTTP close" 
        HTTP::close 
     } 
     

    Log error:

    Sep 15 17:18:47 tmm tmm[1805]: Rule hooleya_tcp_http_close_rule : HTTP close

    Sep 15 17:18:47 tmm tmm[1805]: 01220001:3: TCL error: hooleya_tcp_http_close_rule - Illegal argument. Can't execute in the current context. (line 7) invoked from within "HTTP::close"

    Aaron
  • Will the first example not close the connection?

     

    Can this irule be used?

     

     

    when HTTP_REQUEST {

     

    HTTP::respond 204

     

    HTTP::close

     

    }
  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    Here is the feedback on HTTP::close I received from F5 Support in C462406:

    HTTP::close semantics are "close the connection after this request/response has been processed". Since HTTP::respond effectively completes the request/response, HTTP::close cannot be used after HTTP::respond. TCP::close can be used to gracefully close the connection after HTTP::respond, if using Connection::close is not acceptable - use of clientside is required to close the clientside if in server-side event, i.e. HTTP_RESPONSE.

    So it would probably be best to use TCP::close in HTTP_REQUEST and clientside {TCP::close} in HTTP_RESPONSE (or other events in the serverside context):

     
     when HTTP_REQUEST { 
        HTTP::respond 204 
        TCP::close 
     } 
     

     
     when HTTP_RESPONSE { 
        HTTP::respond 200 content "test" 
        clientside {TCP::close} 
     } 
     

    Aaron