Skip to content

Instantly share code, notes, and snippets.

@svkrclg
Last active December 19, 2021 17:37
Show Gist options
  • Select an option

  • Save svkrclg/36183b2dcbd1f60b599b726ead739f37 to your computer and use it in GitHub Desktop.

Select an option

Save svkrclg/36183b2dcbd1f60b599b726ead739f37 to your computer and use it in GitHub Desktop.

Revisions

  1. svkrclg revised this gist Dec 19, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion process_post.txt
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ public String[] processData(String request) {
    }
    }

    String body = request.split("\r\n\r\n")[1];
    String body = request.split("\r\n\r\n")[1]; // head and body are seperated through \r\n\r\n. Ref packet format.
    System.out.println("Got body" + body);
    if(body.length() == cl) {
    return new String[] {"true", body};
  2. svkrclg created this gist Dec 19, 2021.
    19 changes: 19 additions & 0 deletions process_post.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    public String[] processData(String request) {
    String lines[] = request.split("\r\n");
    int cl = -1;
    for(String line : lines) {
    System.out.println(line);
    if(line.contains("Content-Length")) {
    String x = line.substring(16);
    cl = Integer.parseInt(x);
    break;
    }
    }

    String body = request.split("\r\n\r\n")[1];
    System.out.println("Got body" + body);
    if(body.length() == cl) {
    return new String[] {"true", body};
    }
    return new String[] {"false", ""};
    }