Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread wrong leading space at the result of Request.ResponseHeaders.Values['SomeKey']
Wed, Aug 31 2016 7:29 AMPermanent Link

Bernd Schaaf


ServerSide ie Indy HTTP-Server:
AResponseInfo.CustomHeaders.Values['SomeKey'] := 'ABCDE';

EWB:
Request.ResponseHeaders.Values['SomeKey'] -> the Result has an leading space character: ' ABCDE'

I must always use trim(Request.ResponseHeaders.Values['SomeKey']) to get the correct anwer.

I think this is a liitle bug Smile

best regards

Bernd
Wed, Aug 31 2016 7:38 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Bernd,

<< ServerSide ie Indy HTTP-Server:
AResponseInfo.CustomHeaders.Values['SomeKey'] := 'ABCDE';

EWB:
Request.ResponseHeaders.Values['SomeKey'] -> the Result has an leading space character: ' ABCDE'

I must always use trim(Request.ResponseHeaders.Values['SomeKey']) to get the correct anwer. >>

Hmm, this is a tough one.  The problem is down to how the headers are formatted:

Header:<space>Value

EWB splits the header/value pairs on the : (colon) character, so any spaces after it are included in the value.  However, I'm not sure if it's right for us to automatically trim this off.  At first glance it seems like it would be okay, and I can't *think* of any cases where it wouldn't be, but.....

Anyone else see anything wrong with just trimming these values ?

Tim Young
Elevate Software
www.elevatesoft.com
Wed, Aug 31 2016 7:41 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Bernd,

Never mind - I actually *can't* trim these, even if I wanted to.  The trimming would have to occur in the TStrings functionality, and I can't perform automatic trimming there.

So, unfortunately, you're going to have to stick with your existing Trim() calls.

Tim Young
Elevate Software
www.elevatesoft.com
Wed, Aug 31 2016 9:58 AMPermanent Link

Matthew Jones

Tim Young [Elevate Software] wrote:

> Bernd,
>
> Never mind - I actually can't trim these, even if I wanted to.  The
> trimming would have to occur in the TStrings functionality, and I
> can't perform automatic trimming there.
>
> So, unfortunately, you're going to have to stick with your existing
> Trim() calls.

I've had a quick zoom around at how this is normally done, and it does
look like it is common to filter on the ': ' rather than the plain ':'.
Presumably the relevant line is

FResponseHeaders.Text:=FHttpRequest.getAllResponseHeaders;

and could be post-processed by looping around the list and adjusting
it? But that would take time that might not be needed, particularly if
only one or zero headers is ever read. Can the "user code" alter the
headers and process it themselves? If so, I'd say leave as is. If it
has to be in the TRequest, then I'd suggest a separate procedure that
someone can call to get them all done.

But at the end of the day, a Trim isn't going to hurt if it is needed,
when it is needed. The alternative is a lot of processing for
potentially no purpose.


--

Matthew Jones
Tue, Sep 6 2016 7:57 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

<< and could be post-processed by looping around the list and adjusting it? >>

Yeah, that could be done.  I'm not exactly sure why I didn't think of this when I originally answered, so I'll have to think about this some more to make sure that I'm not forgetting an edge case.

Tim Young
Elevate Software
www.elevatesoft.com
Image