Trying to send an HTTP request through sockets

I'm having trouble sending a simple HTTP request using an ActionScript 3 Socket () object. My onConnect listener is below:

function sConnect(e:Event):void {
    trace('connected');
    s.writeUTFBytes('GET /outernet/client/rss/reddit-feeds HTTP/1.1\r\n');
    s.writeUTFBytes('Host: 208.43.71.50:8080\r\n');
    s.writeUTFBytes('Connection: Keep-alive\r\n');
    s.flush();
}

Using the packet sniffer, I see that the request is indeed sent to the server, but the packet sniffer does not identify the protocol as HTTP, as it does with other HTTP services. When I run this, the server eventually disconnects me. I tried connecting to other simple Apache servers and just getting the wrong request error.

What am I missing here?

+1
source share
5 answers

You need to write another "\ r \ n" in the stream before the flash to tell the HTTP server that you have finished sending the headers.

+12

, HTTP- . :

function sConnect(e:Event):void {
    trace('connected');
    s.writeUTFBytes('GET /outernet/client/rss/reddit-feeds HTTP/1.1\r\n');
    s.writeUTFBytes('Host: 208.43.71.50:8080\r\n');
    s.writeUTFBytes('Connection: Keep-alive\r\n\r\n');
    s.flush();
}

\r\n writeUTFBytes. , .

: .

+1

UTF ANSI/ASCII. .

0

, , -, โ€‹โ€‹ Flash 10 Linux writeMultiByte(). writeMultiByte().

, .

0

Source: https://habr.com/ru/post/1696871/


All Articles