Giter Club home page Giter Club logo

nginx-http-user-agent's Introduction

# HTTP user_agent module for Tengine
#syntax:

user_agent $variable_name {
    greedy        name;

    name [([+|-]version) | (version1~version2)]  value;
}

if ($variable == value) {
    echo hello;
}


## Introduction

greedy:
We specify the keyword in the user_agent string from right to left, and this is more efficient. As usual, we use the greedy algorithm. It will return immediately after the keyword being found.

E.g 1. "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)", this string is MSIE's user_agent string, we will return when we find the keyword "MSIE". But the truth is not alway like this:
E.g 2. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.20 (KHTML, like Gecko) Chrome/19.0.1036.7 Safari/535.20", This is Chrome's user_agent. We will match Safari frist. If we define safari is greedy, it scans the string in a reverse order. If a keyword is greedy, it will not return when it matches the keyword at the first time. It will continue to scan the string.

default:
set the default value of this variable;

The directive format is like this in the block:
name   version    value;

name: the name of operating_system, browser, crawler and so on;
version: It can be omitted, and it support multiple formats;
value: It is the value filled to the variable;

for example:

user_agent $example {
    #set default value
    default                                             msie;

    #define safari is greedy
    greedy                                             safari;

    #match exact version
    msie                6.0                             1;

    #match interval
    msie                7.0~8.0                         2;

    #match greater than version 9.0
    msie                9.0+                            3;

    #match less than version 4.0 (include 4.0)
    msie                4.0-                            4;

    #match all
    Chrome                                              5;
}

nginx-http-user-agent's People

Contributors

akawhy avatar dinic avatar yaoweibin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nginx-http-user-agent's Issues

r->header_in.user_agent可能为NULL

ngx_http_user_agent_module.c的427行

user_agent = &(r->headers_in.user_agent->value);   

这里字段值可能为NULL

Tengine里面的这个模块判断了这个字段.....

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.