Re: [twsocket] THttpCli POST issue with v7 Commit 317
Re-reading your initial message, it looks like you have to simply send AnsiString since this looks like what the receiving program is awaiting. This is what the original BCB5 program was sending if nothing special has been done there. Now with BCB2009, strings are now UnicodeString instead of AnsiString. -- francois.pie...@overbyte.be The author of the freeware multi-tier middleware MidWare The author of the freeware Internet Component Suite (ICS) http://www.overbyte.be - Original Message - From: "Peter Van Hove" To: Sent: Tuesday, April 14, 2009 8:13 PM Subject: [twsocket] THttpCli POST issue with v7 Commit 317 >I just converted a piece of code to CB2009 (coming from BCB5), not > originally written by myself, so it's a bit searching what is what, but I > believe I run into a component issue. Meanwhile I created the same app in > BCB5 and there is works OK, using the same code. > > I used HEAD version v7, checked out yesterday evening. > > Can somebody confirm, possibly fix if it's an issue ? > > The Problem: > On the receiving end (webpage) the the POST variable doesn't arrive > intact. > Only the first letter. In this example case only "t" arrives (so "t = > test" > instead of "test = test" > As suggested, the value arrives intact (in this case "test") > > The essence I believe is the following > > {code} > > String PostData = "test=test" ; > > THttpCli *HttpCli; > TMemoryStream *DataOut=NULL; > DataOut=new TMemoryStream; > #ifdef _DELPHI_STRING_UNICODE > DataOut->Write(&PostData[1], PostData.Length()*2); // CB2009 > #else > DataOut->Write(&PostData[1], PostData.Length()); // BCB 5 > #endif > DataOut->Seek(0,soFromBeginning); > HttpCli->SendStream=DataOut; > try > { >HttpCli->Post(); >DataSuccessFullyDownloaded=true; > } __except (TRUE) > { > > RawDataStringList->Add("ERROR_CODE="+IntToStr(HttpCli->StatusCode)); >RawDataStringList->Add("ERROR_MESSAGE="+HttpCli->ReasonPhrase); > } > delete DataOut; DataOut=NULL; > } > > > {/code} > > Any ideas ? > Can you repeat ? > > -- > To unsubscribe or change your settings for TWSocket mailing list > please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket > Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] THttpCli POST issue with v7 Commit 317
>>> The Problem: >>> On the receiving end (webpage) the the POST variable doesn't arrive >>> intact. Only the first letter. In this example case only "t" arrives >>> (so "t = test" instead of "test = test" >>> As suggested, the value arrives intact (in this case "test") > >> It's no bug. The component user is responsible to format >> posted data properly. > >> Most likely you have to convert the Unicode string to Ansi or >> UTF-8 first. > > Interesting !!! > So POST and GET data, when sent to a host, are not unicode ? > And so what I provide to the component when I do a GET, in unicode, is > converted in the component to something else (UTF 8 ?) > before it's sent out ? HTTP like many if not all TCP/IP protocols are ASCII (not even ANSI, but ASCII). Everything else than ASCII has to be converted. Frequently, ANSI is also OK provided the sender and receiver are using the same code page. Otherwise, ANSI accented characters becomes corrupted. -- francois.pie...@overbyte.be The author of the freeware multi-tier middleware MidWare The author of the freeware Internet Component Suite (ICS) http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] THttpCli POST issue with v7 Commit 317
Arno Garrels wrote: > With POST requests however the send stream is sent as is and the > component user is responsible to format and encode the stream content > properly. Posted data may, for example, contain multple parts all with > a different Charset and Content-Transfer-Encoding part-header. The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) http://www.joelonsoftware.com/articles/Unicode.html -- Arno Garrels -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] THttpCli POST issue with v7 Commit 317
Peter Van Hove wrote: >>> The Problem: >>> On the receiving end (webpage) the the POST variable doesn't arrive >>> intact. Only the first letter. In this example case only "t" >>> arrives (so "t = test" instead of "test = test" >>> As suggested, the value arrives intact (in this case "test") > >> It's no bug. The component user is responsible to format >> posted data properly. > >> Most likely you have to convert the Unicode string to Ansi or >> UTF-8 first. > > Interesting !!! > So POST and GET data, when sent to a host, are not unicode ? They are not sent as UTF-16 Unicode, correct. > And so what I provide to the component when I do a GET, in unicode, is > converted in the component to something else (UTF 8 ?) Yes, in V7 a GET request is converted to UTF-8 first the URL-encoded, so the component user must not care about the encoding (see functions UrlEncode/UrlDecode in OverbyteIcsUrl.pas), in V5 and V6 the AnsiString with current system code page was URL-encoded as is. With POST requests however the send stream is sent as is and the component user is responsible to format and encode the stream content properly. Posted data may, for example, contain multple parts all with a different Charset and Content-Transfer-Encoding part-header. -- Arno Garrels -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] THttpCli POST issue with v7 Commit 317
>> The Problem: >> On the receiving end (webpage) the the POST variable doesn't arrive >> intact. Only the first letter. In this example case only "t" arrives >> (so "t = test" instead of "test = test" >> As suggested, the value arrives intact (in this case "test") > It's no bug. The component user is responsible to format > posted data properly. > Most likely you have to convert the Unicode string to Ansi or > UTF-8 first. Interesting !!! So POST and GET data, when sent to a host, are not unicode ? And so what I provide to the component when I do a GET, in unicode, is converted in the component to something else (UTF 8 ?) before it's sent out ? Ok, I will do a conversion and test again. Thanks. -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] THttpCli POST issue with v7 Commit 317
Peter Van Hove wrote: > Can somebody confirm, possibly fix if it's an issue ? It's no bug. The component user is responsible to format posted data properly. > > The Problem: > On the receiving end (webpage) the the POST variable doesn't arrive > intact. Only the first letter. In this example case only "t" arrives > (so "t = test" instead of "test = test" > As suggested, the value arrives intact (in this case "test") > > The essence I believe is the following > > {code} > > String PostData = "test=test" ; > > THttpCli *HttpCli; > TMemoryStream *DataOut=NULL; > DataOut=new TMemoryStream; > #ifdef _DELPHI_STRING_UNICODE > DataOut->Write(&PostData[1], PostData.Length()*2); // CB2009 Most likely you have to convert the Unicode string to Ansi or UTF-8 first. -- Arno Garrels -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be