Tim (visions) wrote in lj_win32,
Tim
visions

anyone?

i worked on http proxy support with ericnew (he was my proxy testing person) for 4.5 hours... then another hour on my own.

gah.

anyway, it's still broke, but much further... i ended up having to do the http connect manually and not use the library. the reason... MS's api is fucked. in more detail, anytime you use a CHttpfile and do a send request.. it prefixes it with a / if it isnt there, in other words.. when going through a proxy you get POST /http://www.blah.com/url/ HTTP/1.1

that is obviously broke. there is no way to shut that off either. GAH. maybe i should inherit that class and override that function... is that possible? hrm... maybe... anyone know for sure? i woul dhave to find the source for that function to figure out what it is doing though... im not sure if that is available and i am too tired to check at the moment... but i dont think it is.

hrm.

anyway

at app initialization...
// init sockets
AfxSocketInit();

in ljrequest...
if (proxy) {
	// recieve buffer
	char rcvbuf[1024];

	// new socket
	CSocket* pSocket = new CSocket;
	pSocket->Create();

	int p = 0;

	p = atoi(ljr->m_settings->m_prox_port);
	CString ljlog = "http://" + ljr->m_settings->m_server + ljr->m_settings->m_logurl;

	if (p == 0)
		p = 80;

	// connect
	pSocket->Connect(ljr->m_settings->m_prox_serv,INTERNET_PORT(p));

	// clear buffer
	::ZeroMemory(rcvbuf, sizeof(rcvbuf));

	// header
	CString send;
	send += "POST " + ljlog + " HTTP/1.1\r\n";
	send += "Content-type: application/x-www-form-urlencoded\r\n";
	send += "User-Agent: LiveJournal\r\n";
	send += "Host: " + ljr->m_settings->m_server + "\r\n";
	send += "Cache-Control: no-cache\r\n";
	send.Format("%sContent-Length: %d\r\n", send, postdata.GetLength());
	if (ljr->m_settings != NULL && ljr->m_settings->cookie) {
		send += "Cookie: ljfastserver=1\r\n";
	}
	send += "Authorization " + MIMEencode(ljr->m_settings->m_prox_user + ":" + ljr->m_settings->m_prox_pass) + "\r\n";
	send += "Proxy-Authorization: Basic " + MIMEencode(ljr->m_settings->m_prox_user + ":" + ljr->m_settings->m_prox_pass) + "\r\n";

	send += "\r\n";

	send += postdata;

	// send request
	pSocket->Send(send, send.GetLength());

	// receive stuff from server
	int ret;
	while ((ret = pSocket->Receive(rcvbuf,sizeof(rcvbuf)-1)) && ret != WSAECONNRESET) {
		response += rcvbuf;
	}

	// delete socket
	pSocket->Close();
	delete pSocket;

	int loc = 0;
	int newloc;
	while ((newloc = response.Find((TCHAR) '\n', loc)) != -1)
	{
		CString frag = response.Mid(loc, newloc-loc);
		if (frag == "\r") {
			response = response.Mid(loc+2);
			break;
		}
		if (loc == 0) {
			int start = frag.Find(' ');
			CString msg;
			msg.Format("frag = %s\ncode = %s", frag, frag.Mid(start+1, 3));
			if ((frag.Mid(start+1, 3)).CompareNoCase("200") != 0) {
				ljr->res["success"] = "FAIL";
				ljr->res["errmsg"] = "Server error.  Please try again shortly.";
				MessageBox(NULL, msg, "server failed with these codes", MB_OK);
				return 0;
			}
		}
		loc = newloc+1;
	}
}


anyone see why that would only work one time? something to do with threads perhaps? evan? :)
Subscribe

  • (no subject)

    For those of you having dll problems with oleacc.dll, grab the following file: oleacc.dll and use it instead. it is a dummy dll that returns success…

  • Using MediaPlayer 9?

    They released a "blogging" plugin that allows us to detect the playing song without the need to use the skin I released. You can get it at the…

  • (no subject)

    okay, there have been a ton of messages here asking for media player skins and such. someone was kind enough to add the function listed several posts…

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your IP address will be recorded 

  • 8 comments