Thread: Help with porting some Perl code to C

  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    2

    Help with porting some Perl code to C

    I have this perl script that sends some headers and sends basic authentication to a url and then gets an xml file. I need to port this code to C, but i am unsure of how to send a GET http request with headers and basic authentication

    Here is the PERL code

    Code:
     # Set up the header information for the request
    my $headers = new HTTP::Headers
     'Header 1'                =>      $client_retsver,
    'Header 1' =>      "Digest ".$client_retsauth;
    
    my $ua = LWP::UserAgent->new;
    $ua->agent($client_agent);
    
    #my $request = HTTP::Request->new(GET => 'http://www.url.com', $headers);
    
    $request->authorization_basic($user_userid,$user_password);
    
    my $response = $ua->request($request);
    Anyone have any ideas on how to port this over to C - is sockets the answer?

  2. #2
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    Yes, sockets is a way forward. I warn you, perl is an ideal language for a task like this, while C will be a real pain in comparison. I hope you have a good reason for porting.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  3. #3
    Registered User
    Join Date
    Jan 2006
    Posts
    2
    Quote Originally Posted by adrianxw
    Yes, sockets is a way forward. I warn you, perl is an ideal language for a task like this, while C will be a real pain in comparison. I hope you have a good reason for porting.
    Well what i am doing is modifying a CGI already written in C - this is just a small portion but highly important part that needs modifying. This is my reason. I realize that perl would be the ideal language, but i can not rewrite the software in perl....i havent done much with sockets...any idea how i can setup a socket and then send the headers, do authentication and then recieve the file from the url?

  4. #4
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    869
    Have a read through http://beej.us/guide/bgnet/

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 03-21-2006, 07:52 AM
  2. Updated sound engine code
    By VirtualAce in forum Game Programming
    Replies: 8
    Last Post: 11-18-2004, 12:38 PM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. Replies: 4
    Last Post: 01-16-2002, 12:04 AM