I have to use C# Socket class to do Post request. I can successfully create the POST request required to make the post.
The problem I'm having now is, once I recive the response its coms like this
§♥♥ ☻☻2
the code:
public static void Post(string host,string proxyip,int proxyport,string headers)
{
try{
string page = "";
string c = "CONNECT "+host+":443 HTTP/1.1\r\nHost: i.instagram.com:443\r\n\r\n";
Socket s = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
IPEndPoint proxy = new IPEndPoint(IPAddress.Parse(proxyip),proxyport);
s.ReceiveTimeout = 5000;
Console.WriteLine(IPAddress.Parse(proxyip));
s.Connect(proxy);
Console.WriteLine("Connected");
// convert to bytes
Byte[] bytesSent = Encoding.ASCII.GetBytes(c);
s.Send(bytesSent);
Byte[] bytesReceived = new Byte[256];
int bytes = 0;
bytes = s.Receive(bytesReceived, bytesReceived.Length, 0);
page = Encoding.ASCII.GetString(bytesReceived, 0, bytes);
if (page.Contains("HTTP/1.1 200")){
Console.WriteLine("ok");
Byte[] header = Encoding.ASCII.GetBytes(headers);
s.Send(header);
Byte[] HeadersReceived = new Byte[256];
bytes = 0;
bytes = s.Receive(bytesReceived, bytesReceived.Length, 0);
page = Encoding.ASCII.GetString(bytesReceived, 0, bytes);
Console.WriteLine(page);
}else{
Console.WriteLine("not ok");
}
}
catch(Exception e){
Console.WriteLine(e);
}
}
How i can get it right?