func (c *Action) SubDomains() string {
	parts := strings.Split(c.Host(), ".")
	return strings.Join(parts[len(parts)-2:], ".")
}
SubDomains returns sub domain string.
if aa.bb.domain.com, returns aa.bb .
package xweb
import (
	"bytes"
	"compress/flate"
	"compress/gzip"
	"crypto/hmac"
	"crypto/md5"
	"crypto/sha1"
	"encoding/base64"
	"encoding/hex"
	"encoding/json"
	"encoding/xml"
	"errors"
	"fmt"
	"html/template"
	"io"
	"io/ioutil"
	"mime"
	"mime/multipart"
	"net/http"
	"net/url"
	"os"
	"path"
	"reflect"
	"strconv"
	"strings"
	"time"
	"github.com/go-xweb/httpsession"
	"github.com/go-xweb/log"
	"github.com/go-xweb/uuid"
)
type ActionOption struct {
	AutoMapForm bool
	CheckXsrf   bool
}
type Action struct {
	Request *http.Request
	App     *App
	Option  *ActionOption
	http.ResponseWriter
	C            reflect.Value
	session      *httpsession.Session
	T            T
	f            T
	RootTemplate *template.Template
	RequestBody  []byte
	StatusCode   int
}
type Mapper struct {
}
type T map[string]interface{}
func XsrfName() string {
	return XSRF_TAG
}
func (c *Action) Protocol() string {
	return c.Request.Proto
}
func (c *Action) Uri() string {
	return c.Request.RequestURI
}
func (c *Action) Url() string {
	return c.Request.URL.String()
}
func (c *Action) Site() string {
	return c.Scheme() + "://" + c.Domain()
}
func (c *Action) Scheme() string {
	if c.Request.URL.Scheme != "" {
		return c.Request.URL.Scheme
	} else if c.Request.TLS == nil {
		return "http"
	} else {
		return "https"
	}
}
func (c *Action) Domain() string {
	return c.Host()
}
func (c *Action) Host() string {
	if c.Request.Host != "" {
		hostParts := strings.Split(c.Request.Host, ":")
		if len(hostParts) > 0 {
			return hostParts[0]
		}
		return c.Request.Host
	}
	return "localhost"
}
func (c *Action) Is(method string) bool {
	return c.Method() == method
}
func (c *Action) IsAjax() bool {
	return c.Header("X-Requested-With") == "XMLHttpRequest"
}
func (c *Action) IsSecure() bool {
	return c.Scheme() == "https"
}
func (c *Action) IsWebsocket() bool {
	return c.Header("Upgrade") == "websocket"
}
func (c *Action) IsUpload() bool {
	return c.Request.MultipartForm != nil
}
func (c *Action) IP() string {
	ips := c.Proxy()
	if len(ips) > 0 && ips[0] != "" {
		return ips[0]
	}
	ip := strings.Split(c.Request.RemoteAddr, ":")
	if len(ip) > 0 {
		if ip[0] != "[" {
			return ip[0]
		}
	}
	return "127.0.0.1"
}
func (c *Action) Proxy() []string {
	if ips := c.Header("X-Forwarded-For"); ips != "" {
		return strings.Split(ips, ",")
	}
	return []string{}
}
func (c *Action) Refer() string {
	return c.Header("Referer")
}