In Java, i only want to read the body information, not the headers, from a curl command.
Currently, i'm using this as the curl command:
curl -H 'Content-Type: text/plain; charset=UTF-8' -F file=@last_commit_log.txt -X POST "http://localhost:8888/dashboard?token=blah"
where the context of last_commit_log.txt
is simply something like "WIP"
However, the actual contents of what i'm seeing is:
--------------------------0697da5b51372910
Content-Disposition: form-data; name="file"; filename="last_commit_log.txt"
Content-Type: text/plain WIP
when all i want to see is just the message "WIP"
This is my Java code:
Scanner scanner = new Scanner(request.getInputStream());
StringBuilder sb = new StringBuilder();
while (scanner.hasNextLine()) {
sb.append(scanner.nextLine()).append("\n");
}
System.out.println(sb.toString());
where the request is the HttpRequest incoming
How do I only read the body of the request and strip the headers?