From 1eb17061665f76f8f761e8e9a51899e389b7f2b5 Mon Sep 17 00:00:00 2001 From: Redkale <8730487+redkale@users.noreply.github.com> Date: Tue, 16 Jun 2020 11:12:51 +0800 Subject: [PATCH] --- .../redkale/net/http/HttpSimpleRequest.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/org/redkale/net/http/HttpSimpleRequest.java b/src/org/redkale/net/http/HttpSimpleRequest.java index ca3e472a9..bd3582d5c 100644 --- a/src/org/redkale/net/http/HttpSimpleRequest.java +++ b/src/org/redkale/net/http/HttpSimpleRequest.java @@ -86,12 +86,42 @@ public class HttpSimpleRequest implements java.io.Serializable { return this; } + public HttpSimpleRequest header(String key, JsonConvert convert, Object value) { + if (value == null) return this; + if (this.headers == null) this.headers = new HashMap<>(); + if (convert == null) convert = JsonConvert.root(); + this.headers.put(key, convert.convertTo(value)); + return this; + } + + public HttpSimpleRequest header(String key, Object value) { + if (value == null) return this; + if (this.headers == null) this.headers = new HashMap<>(); + this.headers.put(key, JsonConvert.root().convertTo(value)); + return this; + } + public HttpSimpleRequest param(String key, String value) { if (this.params == null) this.params = new HashMap<>(); this.params.put(key, value); return this; } + public HttpSimpleRequest param(String key, JsonConvert convert, Object value) { + if (value == null) return this; + if (this.params == null) this.params = new HashMap<>(); + if (convert == null) convert = JsonConvert.root(); + this.params.put(key, convert.convertTo(value)); + return this; + } + + public HttpSimpleRequest param(String key, Object value) { + if (value == null) return this; + if (this.params == null) this.params = new HashMap<>(); + this.params.put(key, JsonConvert.root().convertTo(value)); + return this; + } + public HttpSimpleRequest body(byte[] body) { this.body = body; return this;