ietf-openproxy
[Top] [All Lists]

RE: Decision on Rules Language

2003-09-21 23:10:45

Hi Alex,

Here is the content transcoding example. I have tried to keep it simple and yet 
functional. Please let me know if its too simple - I tried to simplify things 
since I work with this kind of functionality all the time, so I wasn't sure 
whether it would be difficult/easy for other people to grasp the idea quicky.

Example 4: User-Agent-based content transcoding. The request is parsed for 
User-Agent and subscriber info. This info is used  to authenticate the user and 
forward the request if authenticated. The response data is passed through 
transcoders based on  their content types and finally directed to the client.

        Http := import "http://ietf.org/opes/rules/p/HTTP";;
        Services := import "http://ietf.org/opes/rules/p/Services";;     

        userAgentInfo := request.getUserAgent();
        subscriberInfo := request.getSubscriberAccountInfo();

        if( defined subscriberInfo )
        {       
                /* Check  if the user is a valid subscriber */
                {
                        userAccountingService := 
Services.findOne("opes://isp.net/UserValidatorNAccounting");
                        Services.applyOne(userAccountingService, 
request.header);
                } 
                otherwise
                {
                        /* Use backup service provider in case of failures */
                        userAccountingService := 
Services.findOne("opes://ispbackup.net/BackupUserValidatorNBilling");
                        Services.applyOne(userAccountingService, 
request.header);
                }
                otherwise
                {
                        /* Deny access in case the accounting server is 
inaccessible */
                        request.denyAccess();
                }
                
                if( !request.isAuthorized() )
                {
                        /* respond to the client with an error message since 
user is not authorized*/
                        response.header.setStatus(401, "Unauthorized User");
                        response.setBody("<html>You are not an authorized 
user</html>");
                        sendResponse();
                }
                else
                {
                        /* The user is an authorized user and has access to 
transcoding services */

                        /* forward the request to the content server and wait 
till response received */
                        forwardRequest();
        
                        contentType := Http.response.getContentType();
                        if(contentType begins_with "image/")
                        {
                                transcoderService := 
Services.findOne("opes://ispservices.net/Transcoder");
                                service.setUserDevice( userAgentInfo );
                                Services.applyOne(transcoderService, 
response.body);

                                //track user service record via the accounting 
service
                                Services.applyOne(userAccountingService, 
"Service name = "+transcoderService,  subscriberInfo); 
                        }
                        else if (contentType equals 
"application/x-shockwave-flash")
                        {
                                flashTranscoderService := 
Services.findOne("opes://ispservices.net/Flash2PNG");
                                service.setUserDevice( userAgentInfo );
                                Services.applyOne(flashTranscoderService, 
response.body);               
        
                                //track user service record via the accounting 
service
                                Services.applyOne(userAccountingService, 
"Service name = "+flashTranscoderService,  subscriberInfo);    
                        }
                
                        /* forward the response (possibly modified) to client */
                        sendResponse();
                }
        }

Suggestion 2:
*************

Since string is a primitive type, can we add a binary operator , '+' or 
'append' for string, such that operations such as :
"sampl" + "e" would equal "sample" ? Or is this already covered ?

Thanks,
Anwar

-----Original Message-----
From: Alex Rousskov [mailto:rousskov(_at_)measurement-factory(_dot_)com]
Sent: Sunday, September 21, 2003 4:52 PM
To: Anwar M. Haneef
Cc: ietf-openproxy(_at_)imc(_dot_)org
Subject: Re: Decision on Rules Language



On Sat, 20 Sep 2003, Anwar M. Haneef wrote:

Example 4: User-Agent-based content transcoding - This might be a
more complicated example. In case you are interested, I can write
this up. Being a telecom industry person, this would be more
relevant for my applications.

I would be interested to see this implemented. IMO, at least one
complicated example would be good for both us writing the spec and
folks considering supporting it.

Thanks,

Alex.

P.S. I will work your other examples in, thank you for posting them!



<Prev in Thread] Current Thread [Next in Thread>