Set the String of request body data to be sent to the server.

@param input String of request body data to be sent to the server
@return an {@link HttpConnection} for method chaining
169465
public HttpConnection setRequestBody(final String input) {
        try {
            final byte[] inputBytes = input.getBytes("UTF-8");
            return setRequestBody(inputBytes);
        } catch (UnsupportedEncodingException e) {
            // This should never happen as every implementation of the java platform is required
            // to support UTF-8.
            throw new RuntimeException(e);
        }
    }
1250770
public void setBody(String body)
    {
    	String xbody = body;
    	String [] row = xbody.split("\n");
    	for(int i=0; i<row.length; i++){
    		this.m_xbody.add(row[i]);
    	}
    }
229817
@SuppressWarnings("StatementWithEmptyBody")
    public static byte[] decode(final String input) {
        ByteArrayInputStream in = new ByteArrayInputStream(input.getBytes());
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try {
            while (decodeChunk(out, in)) {
                // do nothing
            }
        } catch (IOException ex) {
            throw new RuntimeException(ex);
        }

        return out.toByteArray();
    }
869116
public void send(String uri, String data) {
        Objects.requireNonNull(uri, Required.URI.toString());

        final Set<ServerSentEventConnection> uriConnections = getConnections(uri);
        if (uriConnections != null) {
            uriConnections.stream()
                .filter(ServerSentEventConnection::isOpen)
                .forEach((ServerSentEventConnection connection) -> connection.send(data));
            
       }
    }
577189
@Override
    public StandaloneAhcWSRequest setBody(BodyWritable bodyWritable) {
        this.bodyWritable = bodyWritable;

        String contentType = bodyWritable.contentType();
        if (!headers.containsKey(HttpHeaders.Names.CONTENT_TYPE) && contentType != null) {
            this.addHeader(HttpHeaders.Names.CONTENT_TYPE, bodyWritable.contentType());
        }

        return this;
    }
390977
Response put(URI uri, InputStream instream, String contentType) {
        HttpConnection connection = Http.PUT(uri, contentType);

        connection.setRequestBody(instream);

        return executeToResponse(connection);
    }
224973
public String processInput(String input) {

        JsonObject object;
        try {
            object = gs.fromJson(input, JsonObject.class);
        } catch (Throwable t) {
            return "{ \"status\" : \"fail\", \"error\" : \"Failed to parse input\" }";
        }

        String command = object.get("command").getAsString();
        JsonObject payload;
        if (!object.has("payload")) {
            payload = new JsonObject();
        } else {
            payload = object.get("payload").getAsJsonObject();
        }

        CommandStatus status;

        try {
            status = dispatch(command, payload);
        } catch (Throwable t) {
            status = new CommandStatus();
            status.fail(t).setPayload(payload);
        }

        return status.toString();
    }
507565
public HttpConnection header(String header, String value, boolean isOverride) {
		if (null != this.conn) {
			if (isOverride) {
				this.conn.setRequestProperty(header, value);
			} else {
				this.conn.addRequestProperty(header, value);
			}
		}

		return this;
	}
423212
public static String post(String url, Map<String, String> queryParas, String data, Map<String, String> headers) {
		HttpURLConnection conn = null;
		try {
			conn = getHttpConnection(buildUrlWithQueryString(url, queryParas), POST, headers);
			conn.connect();
			
			OutputStream out = conn.getOutputStream();
			out.write(data != null ? data.getBytes(CHARSET) : null);
			out.flush();
			out.close();
			
			return readResponseString(conn);
		}
		catch (Exception e) {
			throw new RuntimeException(e);
		}
		finally {
			if (conn != null) {
				conn.disconnect();
			}
		}
	}
1186069
InputStream put(URI uri, String contentType) {
        HttpConnection connection = Http.PUT(uri, contentType);
        return executeToInputStream(connection);
    }
544145
private static String readFromConnection(URLConnection connection) throws IOException {
    InputStream stream;
    if (connection instanceof HttpURLConnection) {
      HttpURLConnection httpConnection = (HttpURLConnection) connection;
      try {
        stream = connection.getInputStream();
      } catch (Exception e) {
        stream = httpConnection.getErrorStream();
      }
    } else {
      stream = connection.getInputStream();
    }
    try {
      ByteArrayOutputStream output = new ByteArrayOutputStream();
      byte[] buffer = new byte[1024];
      int read = 0;
      while ((read = stream.read(buffer)) != -1) {
        output.write(buffer, 0, read);
      }
      String charset = connection.getContentEncoding();
      if (charset == null) {
        String mimeType = connection.getContentType();
        String[] parts = mimeType.split(";");
        for (String part : parts) {
          part = part.trim();
          if (part.startsWith("charset=")) {
            charset = part.substring("charset=".length());
            break;
          }
        }
        if (charset == null) {
          charset = "UTF-8";
        }
      }
      return new String(output.toByteArray(), charset);
    } finally {
      stream.close();
    }
  }
61512
@Override
    public Input getInput() {
        return new Input()
                .add("content", String.class, "邮件内容")
                .add("subject", String.class, "邮件标题")
                .add("tos", String.class, "使用逗号分隔的多个邮件地址", REQUIRED);
    }
1115799
public HttpRequest withBody(String content) {
        final byte[] bodyBytes = content.getBytes(StandardCharsets.UTF_8);
        return withBody(bodyBytes);
    }
682626
public synchronized HttpRequestBody readRequestBody(HttpHeader httpHeader) {

		int contentLength = httpHeader.getContentLength();	// -1 = default to unlimited length until connection close
		
		HttpRequestBody body = (contentLength > 0) ? new HttpRequestBody(contentLength) : new HttpRequestBody();
		
		readBody(contentLength, body);
		
		return body;
	}
1126975
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
    private static Request parse(final InputStream input) throws IOException {
        boolean eof = true;
        final Collection<String> head = new LinkedList<>();
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        Opt<Integer> data = new Opt.Empty<>();
        data = RqLive.data(input, data, false);
        while (data.get() > 0) {
            eof = false;
            if (data.get() == '\r') {
                RqLive.checkLineFeed(input, baos, head.size() + 1);
                if (baos.size() == 0) {
                    break;
                }
                data = new Opt.Single<>(input.read());
                final Opt<String> header = RqLive.newHeader(data, baos);
                if (header.has()) {
                    head.add(header.get());
                }
                data = RqLive.data(input, data, false);
                continue;
            }
            baos.write(RqLive.legalCharacter(data, baos, head.size() + 1));
            data = RqLive.data(input, new Opt.Empty<>(), true);
        }
        if (eof) {
            throw new IOException("empty request");
        }
        return new Request() {
            @Override
            public Iterable<String> head() {
                return head;
            }

            @Override
            public InputStream body() {
                return input;
            }
        };
    }
522028
public static String put(String url, String body) {
        return request(HttpRequest.put(replaceLocalHost(url)), body).body();
    }
532806
public HttpConnection setMethod(Method method) {
		// method
		try {
			this.conn.setRequestMethod(method.toString());
		} catch (ProtocolException e) {
			throw new HttpException(e);
		}

		// do input and output
		this.conn.setDoInput(true);
		if (Method.POST.equals(method) //
				|| Method.PUT.equals(method)//
				|| Method.PATCH.equals(method)//
				|| Method.DELETE.equals(method)) {
			this.conn.setDoOutput(true);
			this.conn.setUseCaches(false);
		}
		return this;
	}