Note that there are some explanatory texts on larger screens.

plurals
  1. POCurl sending blank header(testing Java web server)
    text
    copied!<p>I am testing my web server by sending it requests from cURL. When I send this command:</p> <pre><code>curl -H "_ADD_CLASS*21112*ab*https://somewebsite" 127.0.0.1:12345 </code></pre> <p>to my server, I get this in my Java Socket</p> <pre><code>GET / HTTP/1.1 User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5 Host: 127.0.0.1:12345 Accept: */* _ADD_CLASS*21112*ab*https://somewebsite </code></pre> <p>This is what I was expecting.</p> <p>When I send this request to my server using cURL though, it does not send the header for some reason:</p> <pre><code>curl -H "REMOVE_CLASS*21111*a" 127.0.0.1:12345 GET / HTTP/1.1 User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5 Host: 127.0.0.1:12345 Accept: */* "" (as shown in java) </code></pre> <p>Any idea why the second request is showing up as ""? Here is some code:</p> <pre><code>private static void handleRequest(Socket socket) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream())); String socketData = null; String[] commands; while (br.ready()) { socketData = br.readLine(); //parse command if (socketData.compareTo("") == 0) { //Log error break; }else { if (socketData.charAt(0) != '_') continue; commands = socketData.split("\\*"); if (commands[0].compareTo("_ADD_CLASS") == 0) { //syntax is ADD_CLASS*CRN*TOKEN*WEB_ADDRESS socket.close(); addClass(commands[1], commands[2], commands[3]); break; }else if(commands[0].compareTo("_REMOVE_CLASS") == 0) { //syntax is REMOVE_CLASS*CRN*TOKEN socket.close(); removeClass(commands[1], commands[2]); break; }else if(commands[0].compareTo("_UPDATE_TOKEN") == 0) { //syntax is UPDATE_TOKEN*OLD_TOKEN*NEW_TOKEN socket.close(); updateDeviceToken(commands[1], commands[2]); break; }else { //log error } } } socket.close(); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload