|
Dude
I think you are just missing the Content-Length specification in your POST request header. This is needed so the server knows when the content-data ends (\r\n\r\n is only the terminator for the header). Try sending something like this to the server:
POST /logon HTTP/1.1
Host: peer200:6002
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax)
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: https://peer200:6002/logon
Content-Type: application/x-www-form-urlencoded
Content-Length: 54
USERNAME=Administrator&PASSWORD=xxxxxxxx&SUBMIT=SUBMIT
...here the length of the content data (USERNAME ....SUBMIT is exactly 54 bytes). Hope this helps !
Thanks,
Neil Humphreys.
|
|
|
|
|
Thanks for the replies, all of you.
Neil, your headers worked beautifully if I sent them as-is. However, whenever I try to do something complicated like asking the user to type in his name and then change the Content-Length parameter accordingly, the server sends back a 0...
Here is the new snippet I have been adding:
connect(MySocket, (struct sockaddr*)&Server, sizeof(struct sockaddr));
string Send("POST /Test.php HTTP/1.1\r\nHost: tdlgames.com:80\r\nUser-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax)\r\nAccept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\nAccept-Language: en-us,en;q=0.5\r\nAccept-Encoding: gzip,deflate\r\nAccept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\nKeep-Alive: 300\r\nConnection: keep-alive\r\nContent-Type: application/x-www-form-urlencoded\r\n");
cout << "Enter your name: ";
string Name;
getline(cin, Name);
char Content[100];
sprintf(Content, "Content-Length: %d\r\n\r\n", Name.length());
Send += Content;
Send += "Name=";
Send += Name;
send(MySocket, Send.c_str(), Send.length(), 0);
...
The receive code has not changed. Please help me a bit more - I am grateful for all the answers.
Thank you,
Peter.
Visit
http://www.tdlsoftware.com
|
|
|
|
|
Hi Peter,
Looks like you may have forgotten to account for "Name=" in the Content-Length. Name.length() is actually the length of your content minus the length of the string "Name=".
Hope this helps...
Thanks,
Neil Humphreys.
|
|
|
|
|
I use vc++ 6
I have set an Enviornment variable MyDir. I want to use it as search path for
1.*.h
2 *.cpp (in #include only)
3. *.dsw(for sub or dependent project)
I dont want it to be added in VC++ directory dialog. Is there some other way
. so that nothing is hardcoded
|
|
|
|
|
I have an edit box that does nothing but display information. I have been wondering how to change the position of the text cursor to always go to the bottom of the text that appears. Right now, the cursor goes back to the top everytime text is added. The scroll bars will only automaticly scroll down if the user inputs data. Basicly I need to make sure the view of the text is always at the bottom when new data is added. I am not using MFC. Anyone know how I should do this?
|
|
|
|
|
See CEdit::SetSel, or if you are feeling hardcorde, SendMessage(IDC_EDIT,EM_SETSEL..
onwards and upwards...
|
|
|
|
|
I used SendMessage.
And it works great!
|
|
|
|
|
There are macros to encapsulate some useful windows messages in the WindowsX.H file.
What with everything built on a 'foundation' or 'template' library of some sort these days, I think people tend to forget about WindowsX.H
|
|
|
|
|
hiho@ll
i need to login into a website, controlled by my c++ prog
for example i have a menu-button "Login to website"
my prog knows the username and password
and i need to login with standard browser or internet explorer in the website?
i've tried with http://user:pass@www.mytestlogin.com
but it didn't work
i just get the login site, where i have to fill out the HTML-Forms and submit it
may i can generate the needed HttpRequest and let the Internet Explorer Read the HttpResponse? (how can i do that?)
are there any topics in the forum i haven't found about this subject?
thx@ll
|
|
|
|
|
You could just submit the login form programatically by examining the site's login page HTML. See this[^] section for code samples.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
i just can send the HTTP Request, but how do i tell Internet Explorer (i mean i need a new Internet Explorer Window, not a window which is part of my application) to receive the Request?
So, i need to open a new Internet Explorer window and the user is in the member area of the website i opened
how can i handle the http request/responses to do that?
thx
|
|
|
|
|
Ah. I misunderstood your question - sorry.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
The problem is almost cetainly because the site is expecting a POST of the username and password, which can't just be stuffed on the end of the URL.
A post looks something like this (the exact names of the fields USERNAME and PASSWORD could maybe be determined by viewing the source of your particular web page).
POST /logon HTTP/1.1
Host: peer200:6002
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax)
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: https://peer200:6002/logon
Content-Type: application/x-www-form-urlencoded
Content-Length: 54
USERNAME=Administrator&PASSWORD=xxxxxxxx&SUBMIT=SUBMIT
Thanks,
Neil Humphreys.
|
|
|
|
|
What I want to do sounds quite simple. I'm firing off a new process from my application, and want to be able to set the color of the new process windows' top-bar (where the title and the minimize/maximise/close buttons are) from my process.
I've spent weeks combing the MSDN docs to do this, with no luck.
The closest I've found is the SetSysColors which allows me to set the topbar color, but for the whole system. Is there an equivalent function that takes in a hwnd handle? Alternately, what are my options? From my research it seems like I could hijack the messaging events to the window, and fudge the paint callbacks, but that seems way too drastic. I've found plenty of functions to move windows around, change the title text, etc... Are there any to control the color?
Thanks in advance.
|
|
|
|
|
The only thing that I can think to do here is API hooking, you can hook the GetSysColors function for that application and return the values you want. I don't know if this will work for the top level window or not, but probably. It still seems like a bit of work, but there are reasons this stuff is done at the global level, users should be able to set their colors to whatever they want and not have applications changing them.
-- Rocky Dean Pulley
|
|
|
|
|
an app (A) create a sub-process (B) and they communicate each other.
A uses ReadFile() in threads to read stdout and stderr from B.
but function ReadFile() blocks there even B was terminated.
is it just this way or something wrong?
how to solve the problem?
thx
includeh10
|
|
|
|
|
my app retrieves a file path from command line by double-clicking the file in Windows explorer.
Unfortunately, the file path is in 8.3 format.
my questions:
1) how to pass full-path to app when double-clicking the file? e.g. set register in other ways.
2) if 1) is impossible, how to change 8.3 format to full-path? as i tested, the function GetFullPathName() still returns a 8.3 path.
thx
includeh10
|
|
|
|
|
Have you looked at GetLongPathName() and GetShortPathName()
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
hi,
thx.
i don't know the function.
i read vc doc for it, vc doc says the function works for win98 and above, but our target is for all windows (incl. 95) - this is company's policy.
any other solutions?
(modify: it works very well on Win98)
includeh10
|
|
|
|
|
I'm curious why your program would care whether it was 8.3 or LFN. Most file I/O functions will work with LFN and all of them will work with 8.3 format.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
You should wrap the %1 in the registration data in quote marks. You should also put your program's path in quote marks. For example:
"C:\Program Files\IncludeProg\MyProgName.exe" "%1"
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
that is why i got the trouble.
u sure it passes full-path to app other than 8.3 format?
includeh10
|
|
|
|
|
Hello,
I have a GUI application where the user can set the background color for a plotting control.
My question is how to select a foreground(text) color that will "contrast" with the user selected background?
COLORREF bg = GetUserPlotColor();
COLORREF fg = F(bg);
That is, what is the code for the F() body?
TIA.
-- Ricky Marek (AKA: rbid)
-- "Things are only impossible until they are not" --- Jean-Luc Picard
My articles
|
|
|
|
|
I'm no colour expert, but I did encounter this while writing a custom-drawn tree control a while back.
Have a look at this[^] article that should point you in the right direction.
However, in the end I think I settled for a simple XOR technique, where I XOR'ed my selection colour with white (#FFFFFF), to get the corresponding contrasting text colour. This is definitely the easy route, and will probably give unsatisfactory results on certain colours, but it works for me.
By the way, I found this[^] little web applet useful.
I Dream of Absolute Zero
|
|
|
|
|
I have played around a bit with inverting frame-grabbed images, and I found that the XOR technique usually works nicely.
Where it will not work well is with grey-scales which are close to mid-range, for example, if you have RGB-15 (5-bits of each colour, high order bit unused), where the R, G, and B values are all half-range = 15 decimal, i.e. the pixel is 0011 1101 1110 1111, XORing will give 1100 0010 0001 0000, i.e R, G, and B are all 10000 binary = 16 decimal.
For cases like this, the XORed text will be very difficult to make out.
To get around this, you could saturate (force to maximum or minimum) each colour component, then XOR / invert the result. For my example, the 15 decimal component values are forced to 0, then inverted to give 11111 binary, which should be visible.
|
|
|
|
|