Last active
December 19, 2021 17:37
-
-
Save svkrclg/36183b2dcbd1f60b599b726ead739f37 to your computer and use it in GitHub Desktop.
procees POST packet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]; // 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}; | |
} | |
return new String[] {"false", ""}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment