473,785 Members | 2,435 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Complete header control with curl

2 New Member
I am using curl to do a post request to a server. The request contains xml data, the standard post headers sent by curl do not work. I have tried using the custom_request option with the whole post request inside it, but then curl adds a header after the custom_request portion.
Expand|Select|Wrap|Line Numbers
  1. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $header);
^^^ the above produces a correct request, except it adds an additional set of headers after it.


I have tried sending the data in the CURLOPT_POSTFIE LDS, along with setting header values in the CURLOPT_HTTPHEA DER, but curl still sends the header values that it considers to be correct for a post request.

The following:
Expand|Select|Wrap|Line Numbers
  1. $header  = array("Content-type"=>"application/PTI26",
  2.   "Content-length"=>strlen($xml),
  3.   "Content-transfer-encoding"=>"text",
  4.   "Request-number"=>"1",
  5.   "Document-type"=>"Request",
  6.   "Interface-Version"=>"Test 1.4",
  7.   "Connection"=>"close");
  8.  
  9. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  10.  curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
  11.  
produces this request:
Expand|Select|Wrap|Line Numbers
  1.  POST / HTTP/1.1
  2. Host: www.foobar.org
  3. Pragma: no-cache
  4. Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
  5. Content-Length: 993
  6. Content-Type: application/x-www-form-urlencoded
  7.  
Is there some way to get more control of the header?
or
Is there another option besides curl that can handle a custom ssl certificate?

Thanks
Andrew
Oct 4 '07 #1
4 7282
Atli
5,058 Recognized Expert Expert
Hi Andrew. Welcome to The Scripts!

I haven't personally had much experience with cUrl so I'm afraid I can't help you much there. (I'm sure many of the other experts can, however)

But, you could always use sockets to send HTTP requests, giving you full control over the entire process. Check out the second example in that link.
Oct 4 '07 #2
herbivore
2 New Member
Thanks for your reply,

I would like to use sockets, but I do not know if/how the following portion can be done:
Expand|Select|Wrap|Line Numbers
  1. curl_setopt($ch, CURLOPT_SSLCERTTYPE, "PEM"); 
  2. curl_setopt($ch, CURLOPT_SSLCERT, $clientcertpath); 
  3. curl_setopt($ch, CURLOPT_SSLCERTPASSWD, $clientcertpassword); 
  4.  
Never mind, now I see under the streams section that I can use fsockopen() and supply that certificate info. The second example here is somewhat close to what I need.

Thanks, wouldn't of found it wothout you.
Oct 4 '07 #3
Atli
5,058 Recognized Expert Expert
I'm glad I could help :)

Don't hesitate to post again if you have any more questions or problems we can help with.
Oct 4 '07 #4
pbmods
5,821 Recognized Expert Expert
Heya, Andrew.

Please use CODE tags when posting source code:

[CODE=php]
PHP code goes here.
[/CODE]
Oct 4 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2934
by: Haluk Durmus | last post by:
Hello I checked out openssl,mm,apr,apr-util,apache 2,curl,libxml and php from cvs. php couse an ERROR I did the following steps:
3
6332
by: Chris Fortune | last post by:
# uname -a Linux stargate.mxc-online.net 2.4.20-021stab022.2.777-smp #1 SMP Wed Jul 28 17:12:37 MSD 2004 i686 i686 i386 GNU/Linux I recompiled PHP with mcrypt, openssl, and curl phpinfo(): http://www.canadiandropshipping.com/hello.php3 Does anyone know why this ssl curl test fails? http://www.canadiandropshipping.com...t/diag_curl.php
3
5087
by: Hans | last post by:
Hi everybody, I am desperately trying to log into my account at godaddy.com with PHP and Curl and just cannot make it happen. Has anybody written a script for this purpose? Here is what I tried but the result is always the login page. $curl=curl_init(); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
0
3736
by: Dean Hallman | last post by:
Hello, I am developing a BHO that should add a custom HTTP header on a specific domain only. Don't want the header globally, otherwise I could just add a registry key. So, on BEFORENAVIGATE2, I am canceling the current navigation and renavigating with the new custom header using Navigate2. This usually works fine, but in some cases (particularly when selecting a link that starts a new window), the Navigate2 call fails.
0
5860
by: nfhm2k | last post by:
I've been trying to find a solution to this for quite some time now... I even took a look at existing scripts... Including this one... http://groups.google.co.uk/group/comp.lang.php/browse_thread/thread/2e052386da903425/b03ec83ac55273a2?lnk=st&q=&rnum=1#b03ec83ac55273a2 Everyone on that post seems to say its to do with the cookie's, yet if infact they had tried this script they would have found that even with the cookies enabled this...
2
2592
by: sundar22in | last post by:
Hi, I want to access a part of file in PHP(Instead of whole file). I understood HTTP Range header is the solution. How do we implement HTTP Range header in PHP??? Iam using fopen() method to access a remote file by providing the URL. Any related links?? How it can be implemented?? Kindly Help
4
8048
by: zorro | last post by:
Hello there, I can't figure out why is it that when i use an array for my postfields it doesn't work : this works curl_setopt($curl, CURLOPT_POSTFIELDS, "clown=bozo" ); this doesn't curl_setopt($curl, CURLOPT_POSTFIELDS, array('clown'=>'bozo') );
0
1591
by: jsherk | last post by:
I've spent HOURS searching the net for an answer to this, but can't find it... I trying to send data using the POST method and also have the control of the browser be turned over to the website that's receiving the POST data (note that this is NOT the same as sending the data via POST method and then redirecting to the website after). I need it to work exactly like hitting the submit button on an html form, and I need it to work from PHP. It...
1
2532
by: jeddiki | last post by:
I am using curl and DOMDocument to extract the links from my website. This is my script: require("my_functions.php"); $target_url = "http://www.support-focus.com/customer-service-software.html"; $userAgent = 'Googlebot/2.1 (http://www.googlebot.com/bot.html)';
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10091
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.