java - How to initialize a char array to accommodate the HTTP POST Content-Length -


i'm writing http server (for learning purposes). once receive http post request, want print parameters sent client, problem i'm sending "name=marcelo" , i'm getting incomplete result.

content length: 12 char 0:  char 1:   char 2: n char 3: char 4: m char 5: e char 6: = char 7: m char 8: char 9: r char 10: c char 11: e 

here's code (js java, i.e., nashorn):

//initialize array of characters                         var content = new chararray(contentlength); print('content length: ' + content.length);  bufreader.read(content);  for(var c in content) {     print('char ' + c + ': ' + content[c]); } 

i understand content-length number of bytes of request content data (not number of characters) so, efficient way construct char array based on request's content-length?

apparently you're not reading http headers before reading post body. thus, first 2 characters of content array \r , \n respectively , 2 last characters of body not read.

fix reading 2 newlines after last http header line.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -