Java Http Requests


/ Published in: Java
Save to your folder(s)

Http Requests
for any langauge really but i used em in java :P


Copy this code and paste it in your HTML
  1. static String path = "/some/post/form.php"
  2. static String domain = "www.somedomain.com"
  3.  
  4. out.write("POST " + path +"
  5. ");
  6. //Post requires Content-length then the data to be URLEncoder.encode("data=value");
  7. OR
  8. out.write("GET " + path + "
  9. ");
  10. //Get requires the full path to the form
  11. out.write("Host: " + domain + "
  12. ");
  13. out.write("Content-length: " + data.length() + "
  14. ");
  15. out.write("User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
  16. ");
  17. out.write("Accept:
  18. ");
  19. out.write("
  20. ");
  21. out.flush();

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.