add GetVar function for package genv; add DryRun feature for package gdb

This commit is contained in:
John
2020-04-02 20:52:37 +08:00
parent be2d4b080e
commit 7bcc596308
11 changed files with 120 additions and 23 deletions

View File

@ -189,15 +189,9 @@ func (c *Client) DoRequest(method, url string, data ...interface{}) (resp *Clien
req.Header.Set(k, v)
}
}
// For server requests Host specifies the host on which the
// URL is sought. Per RFC 2616, this is either the value of
// the "Host" header or the host name given in the URL itself.
// It may be of the form "host:port".
//
// For client requests Host optionally overrides the Host
// header to send. If empty, the Request.Write method uses
// the value of URL.Host.
if host := req.Header.Get("Host"); host != "" {
// It's necessary set the req.Host if you want to custom the host value of the request.
// It uses the "Host" value of the header.
if host := req.Header.Get("Host"); host != "" && req.Host == "" {
req.Host = host
}
// Custom Cookie.

View File

@ -107,7 +107,7 @@ func (r *Response) WriteJson(content interface{}) error {
switch content.(type) {
case string, []byte:
r.Header().Set("Content-Type", "application/json")
r.Write(content)
r.Write(gconv.String(content))
return nil
}
// Else use json.Marshal function to encode the parameter.
@ -139,7 +139,7 @@ func (r *Response) WriteJsonP(content interface{}) error {
switch content.(type) {
case string, []byte:
r.Header().Set("Content-Type", "application/json")
r.Write(content)
r.Write(gconv.String(content))
return nil
}
// Else use json.Marshal function to encode the parameter.
@ -179,7 +179,7 @@ func (r *Response) WriteXml(content interface{}, rootTag ...string) error {
switch content.(type) {
case string, []byte:
r.Header().Set("Content-Type", "application/xml")
r.Write(content)
r.Write(gconv.String(content))
return nil
}
// Else use gparser.VarToXml function to encode the parameter.