Posts

Showing posts with the label header

HTTP in Java socket

HTTP in Java socket I want to send a JSON to an already written server (not from me). My problem is that I have an HTTP problem and need to convert it to HTTP. Server message: 2018-06-29 20:02:30.532:WARN:oejh.HttpParser:qtp245475541-15: badMessage: 400 No URI for HttpChannelOverHttp@2bb4ec27{r=0,c=false,a=IDLE,uri=} 2018-06-29 20:03:24.206:WARN:oejh.HttpParser:qtp245475541-18: badMessage: 400 No URI for HttpChannelOverHttp@866a0c9{r=0,c=false,a=IDLE,uri=} Code: public class client { public static void main(String args) { JsonObject js = new JsonObject(); js.addProperty("action","auth"); js.addProperty("type","android"); js.addProperty("token","lalalalalalalalala"); try { Socket ss = new Socket("localhost",3000); PrintWriter out = new PrintWriter(ss.getOutputStream(), true); BufferedReader in = ...