GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 09-Sep-2008, 07:54
thisisme thisisme is offline
New Member
 
Join Date: Sep 2008
Posts: 2
thisisme is on a distinguished road

Saving http responses in a file


hi! I am having some trouble saving the http get response in a file.

I am using telnet for http get requests. since this is in dos, i want to save the http response in a file. I am at a loss on how to implement this in c language.

do you know of any function or commands in c that i can use to store the response to a file?

I plan to use http get to get the file from a server so that i will have my own copy of the file. I am able to receive successful responses from my http requests but I am at a lost on what command to use to save the response in a file.

worst of all, is this really possible using c language?

thanks for your help!
  #2  
Old 09-Sep-2008, 10:55
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 5,303
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: saving http responses in a file


Quote:
Originally Posted by thisisme
...
I am using telnet for http get requests. since this is in dos...

Is it really DOS??? Or is it from a command-line window in something like Windows XP?

If you are using the Microsoft Telnet client, you can try the following (here's a session from my Windows XP box):

Invoke telnet to log on to the remote computer.

Code:
F:\home\dave> telnet 192.168.16.141 CentOS release 5.2 (Final) Kernel 2.6.18-92.1.10.el5.centos.plus on an i686 login: dave Password: Last login: Tue Sep 9 08:31:57 from (name suppressed here to protect the innocent)
This is followed by the Linux prompt on my particular target system.
Now:
Hit ctrl-] to get the telnet prompt and use the "set logfile" telnet command.
Here's what I see:

Code:
Welcome to Microsoft Telnet Client Escape Character is 'CTRL+]' Microsoft Telnet> set logfile telnet_session.txt Log file : telnet_session.txt Client logging on Microsoft Telnet>
Now, hit 'Enter' to return to the session with the connected machine (You see the prompt from the connected computer.)

When you end the telnet session, the log file whose name you used in the "set logfile" command will have the stuff that went to your "DOS" window during the telnet session. (Obviously, you can use any legal file name that you want in the "set logfile" command.)

If you ever use Linux (or cygwin/GNU telnet client on Windows), use the "script" command before you start the telnet session. The GNU telnet client doesn't have (or need) the "set logfile" telnet command, since system utilities can take care of it.

If you are using some third-party telnet client (not Microsoft's) on a Windows (or DOS) platform, maybe it has a mechanism similar to the "set logfile" that I showed. Check the documentation for your program. Maybe it even has a help file.

Quote:
Originally Posted by thisisme
...is this really possible using c language?

Well, you could write your own telnet client, or you could try various implementation-dependent inter-process communications techniques (pipes or some such thing), but I would start by trying to use the features of the given telnet client program and/or operating system.

Regards,

Dave
  #3  
Old 09-Sep-2008, 21:01
thisisme thisisme is offline
New Member
 
Join Date: Sep 2008
Posts: 2
thisisme is on a distinguished road
Thumbs up

Re: Saving http responses in a file


thanks dave! finally! i was able to save the response to a file.

however, the http request and headers are included in the file. I only want to save the contents of the request and eliminate the headers. Is there an easy way to do this? Is there a command that I can use directly or should i make a parser inorder to get the contents?
 
 

Recent GIDBlogProblems with the Navy (Officers) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Airport Log program using 3D linked List : problem reading from file batrsau C Programming Language 11 29-Feb-2008 08:44
After execution - Error cannot locate /Skin File? WSCH C++ Forum 1 05-Mar-2005 21:03
CD burner wont burn!! robertli55 Computer Hardware Forum 1 18-Jun-2004 11:53
Yet another CD burner problem: Lite-On LSC-24082K Erwin Computer Hardware Forum 1 22-May-2004 12:28
CD Buring Failed skanth2000 Computer Hardware Forum 1 15-Nov-2003 04:52

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 16:14.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.