0

The following code statement works properly, I am expecting it does not work properly since "GET /index.html HTTP/1.0\n\n" text has to be send first then other parameters have to be send in correct scenario.

Is there any streaming reverse order policy? However I invoke flush at each write operation?

private DataOutputStream  output; 

     output.write("Host: 10.254.55.27".getBytes());
     output.write("\r\n".getBytes());
     output.flush();
     output.write("Authorization: Basic YWRtaW46TmV0YXMxMjM=".getBytes());
     output.write("\r\n".getBytes());
     output.flush();
     output.write("GET /index.html HTTP/1.0\n\n".getBytes());
Ahmet Karakaya
  • 9,899
  • 23
  • 86
  • 141
  • 1
    Look at what's happening at the network level - I strongly suspect that you happen to be running into a lax web server. The data *will* be written in the order that you've specified. – Jon Skeet Oct 04 '13 at 09:29
  • You are correct. It shouldn't work. So don't do it. – user207421 Oct 04 '13 at 10:20
  • Actually the machine to which message is sent is cisco handphone. – Ahmet Karakaya Oct 04 '13 at 10:50
  • It doesn't matter what it is. Don't do this. If you never do it, you never have to worry about which machines accept it. Stick to HTTP as defined in the RFC. I am struggling to see the actual point of this question. – user207421 Oct 04 '13 at 12:43
  • I am trying to fully understand what is going on when sending stream data through DataOutputStream. Otherview as you stated that I obey the rule of RFC, – Ahmet Karakaya Oct 04 '13 at 13:36
  • What is going on is that you are violating the HTTP protocol. I don't know what is so mysterious about 'DataOutputStream'. It sends what you write, in the order you write it, which is incorrect. Don't. – user207421 Oct 05 '13 at 07:49
  • that is the point, if it is incorrect, it should not work. However it works properly. Does not it weird? – Ahmet Karakaya Oct 05 '13 at 10:49

0 Answers0