• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: HTTP POST
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: HTTP POST


  • Subject: Re: HTTP POST
  • From: Eugene Khablov <email@hidden>
  • Date: Mon, 01 Nov 2004 11:33:07 +0300

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

  • Follow-Ups:
    • Re: HTTP POST
      • From: Dave Elsner <email@hidden>
  • Next by Date: Re: When (not) to use session().defaultEditingContext()
  • Next by thread: Re: HTTP POST
  • Index(es):
    • Date
    • Thread