Re: HTTP POST
Re: HTTP POST
- Subject: Re: HTTP POST
- From: Dave Elsner <email@hidden>
- Date: Tue, 2 Nov 2004 12:08:42 +1100
Thanks Eugine,
ERXApplication.erxApplication().createRequest("POST", serverAction,httpVersion, null, contentData, null);
I take it ERXApplication a Class from Project Wonder ? is there another way to do it with out using wonder (I'm a bit scared of it at the moment) ? Or can I simply use just a simple class or two from wonder to get it to work ?
Thanks David
On 01/11/2004, at 7:33 PM, Eugene Khablov wrote:
Hi, Dave!
I use this code to create reqest with form values in CP1251 encoding and get
the response.
If anyone knows how to avoid resetting
com.webobjects.appserver._private.WOURLEncoder.WO_URL_ENCODING, it would be
great.
===
String host = "myhost.com";
int port = 80;
String serverAction = "http://"+host+"/action.cgi";
String httpVersion = "HTTP/1.1";
// create request
NSMutableDictionary formValues = new NSMutableDictionary();
formValues.setObjectForKey(new NSArray("1"),"Currency");
formValues.setObjectForKey(new NSArray("10.00"),"Amount");
com.webobjects.appserver._private.WOURLEncoder encoder = new
com.webobjects.appserver._private.WOURLEncoder();
com.webobjects.appserver._private.WOURLEncoder.WO_URL_ENCODING=_NSUtilities.
WindowsCP1251StringEncoding;
String encodedFormValues =
encoder.encodeAsCGIFormValues(formValues);
NSData contentData = new NSData(encodedFormValues.getBytes());
com.webobjects.appserver._private.WOURLEncoder.WO_URL_ENCODING=_NSUtilities.
UTF8StringEncoding;
WORequest request =
ERXApplication.erxApplication().createRequest("POST", serverAction,
httpVersion, null, contentData, null);
request.setContentEncoding(_NSUtilities.WindowsCP1251StringEncoding);
// create connection
WOHTTPConnection connection = new WOHTTPConnection(host, port);
connection.sendRequest(request);
WOResponse response = connection.readResponse();
===
On 11/1/04 4:17 AM, "Dave Elsner" <email@hidden> wrote:
Hi,
How can I manually/programatically add variables to a HTTP post which is going
to a 3rd parties server. I have tried setting doing
aResponse.setHeader(value,key) but that doesn't work. I have searches the
archives but with no luck, the only suggestion i found was to make a static
page then call javascript to automatically submit that page, which not really
what I'm looking for.
Thanks
Dave Elsner
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
---
Eugene Khablov
Software Engineer
Web: http://www.demax.ru
E-mail: email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden