/mcp/temp/src/minecraft/net/minecraft/src/PostHttp.java

https://bitbucket.org/vkorolik/twoleanfour-client · Java · 101 lines · 91 code · 7 blank · 3 comment · 6 complexity · 7264f7878a9beec45f3aa357513ee29f MD5 · raw file

  1. // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
  2. // Jad home page: http://www.kpdus.com/jad.html
  3. // Decompiler options: packimports(3) braces deadcode fieldsfirst
  4. package net.minecraft.src;
  5. import java.io.*;
  6. import java.net.*;
  7. import java.util.*;
  8. import java.util.logging.Level;
  9. import java.util.logging.Logger;
  10. public class PostHttp
  11. {
  12. private PostHttp()
  13. {
  14. }
  15. public static String func_52016_a(Map p_52016_0_)
  16. {
  17. StringBuilder stringbuilder = new StringBuilder();
  18. Iterator iterator = p_52016_0_.entrySet().iterator();
  19. do
  20. {
  21. if(!iterator.hasNext())
  22. {
  23. break;
  24. }
  25. java.util.Map.Entry entry = (java.util.Map.Entry)iterator.next();
  26. if(stringbuilder.length() > 0)
  27. {
  28. stringbuilder.append('&');
  29. }
  30. try
  31. {
  32. stringbuilder.append(URLEncoder.encode((String)entry.getKey(), "UTF-8"));
  33. }
  34. catch(UnsupportedEncodingException unsupportedencodingexception)
  35. {
  36. unsupportedencodingexception.printStackTrace();
  37. }
  38. if(entry.getValue() != null)
  39. {
  40. stringbuilder.append('=');
  41. try
  42. {
  43. stringbuilder.append(URLEncoder.encode(entry.getValue().toString(), "UTF-8"));
  44. }
  45. catch(UnsupportedEncodingException unsupportedencodingexception1)
  46. {
  47. unsupportedencodingexception1.printStackTrace();
  48. }
  49. }
  50. } while(true);
  51. return stringbuilder.toString();
  52. }
  53. public static String func_52018_a(URL p_52018_0_, Map p_52018_1_, boolean p_52018_2_)
  54. {
  55. return func_52017_a(p_52018_0_, func_52016_a(p_52018_1_), p_52018_2_);
  56. }
  57. public static String func_52017_a(URL p_52017_0_, String p_52017_1_, boolean p_52017_2_)
  58. {
  59. try
  60. {
  61. String s = p_52017_1_;
  62. HttpURLConnection httpurlconnection = (HttpURLConnection)p_52017_0_.openConnection();
  63. httpurlconnection.setRequestMethod("POST");
  64. httpurlconnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
  65. httpurlconnection.setRequestProperty("Content-Length", (new StringBuilder()).append("").append(s.getBytes().length).toString());
  66. httpurlconnection.setRequestProperty("Content-Language", "en-US");
  67. httpurlconnection.setUseCaches(false);
  68. httpurlconnection.setDoInput(true);
  69. httpurlconnection.setDoOutput(true);
  70. DataOutputStream dataoutputstream = new DataOutputStream(httpurlconnection.getOutputStream());
  71. dataoutputstream.writeBytes(s);
  72. dataoutputstream.flush();
  73. dataoutputstream.close();
  74. BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(httpurlconnection.getInputStream()));
  75. StringBuffer stringbuffer = new StringBuffer();
  76. String s1;
  77. while((s1 = bufferedreader.readLine()) != null)
  78. {
  79. stringbuffer.append(s1);
  80. stringbuffer.append('\r');
  81. }
  82. bufferedreader.close();
  83. return stringbuffer.toString();
  84. }
  85. catch(Exception exception)
  86. {
  87. if(!p_52017_2_)
  88. {
  89. Logger.getLogger("Minecraft").log(Level.SEVERE, (new StringBuilder()).append("Could not post to ").append(p_52017_0_).toString(), exception);
  90. }
  91. }
  92. return "";
  93. }
  94. }