Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for saving header values to properties #24

Open
GoogleCodeExporter opened this issue Apr 2, 2015 · 5 comments
Open

Add support for saving header values to properties #24

GoogleCodeExporter opened this issue Apr 2, 2015 · 5 comments

Comments

@GoogleCodeExporter
Copy link

It would be welcome to have the ability to save specific header values to 
properties.

In particular, we'd like to save cookies and re-send them in subsequent 
responses; that is, to save the value(s) of the Set-Cookie: header(s) from a 
response, so we can send them in Cookie: header(s) in subsequent requests. 

See related Issue 21 for further discussion.

Original issue reported on code.google.com by [email protected] on 19 Aug 2011 at 5:54

@GoogleCodeExporter
Copy link
Author

This issue should likely be identified as Project-ant-http and Type-Enhancement.

Original comment by [email protected] on 19 Aug 2011 at 5:58

  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

Sounds like a good idea, but I'm open to suggestions before coding anything.  
At first I thought it'd be straight foward, but as you pointed out there are 
headers which can be used > 1 time, specifically the one which you are looking 
to use.

Since Ant lacks any type of procedural concepts, it becomes difficult to work 
with this type of scenario, in fact near impossible without extra libs like 
ant-contrib I would think.

I've solved complex problems using ant-contrib in the past, like taking a 
property or a properties file and using foreach 
(http://ant-contrib.sourceforge.net/tasks/tasks/foreach.html) to iterate over 
them.

However, I don't want to code something that will require everyone to use 
another third party library; especially since is only a problem for headers 
which can repeat.

Due to Ant's simplistic nature, I'm tempted to do something like this:

<http ...>
  <saveHeader name="Response" prop="response.prop"/>
  <saveHeader name="Set-Cookie" prop="set.cookie.prop" multivalueDelimieter="###,,###"/>
</http>

So when a header with multiple values is encountered, they would all end up  in 
a single property, delimited with the specified delimiter.  

That's about the best I can think of doing with core Ant functionality, but 
what it does it let you use something like ant-contrib foreach and split the 
multi values on the delimiter, invoking a specified target for each value


Original comment by [email protected] on 19 Aug 2011 at 12:29

  • Changed state: Accepted
  • Added labels: Milestone-1.1.4, Type-Enhancement
  • Removed labels: Type-Defect

@GoogleCodeExporter
Copy link
Author

Original comment by [email protected] on 19 Aug 2011 at 12:51

  • Added labels: Project-ant-http
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

You said wanted to save Set-Cookie and re-issue it right?  It now makes sense 
that this would work:

<property name="delim" value='!!!!,,!!!!"/>

<http ...>
  <saveHeader name="Set-Cookie" prop="set.cookie" multivalueDelimeter="${delim}"/>
</http>

and re-issue:

<http ...>
  <header name="Cookie" value="${set.cookie}" multivalueDelimiter="${delim}"/>
</http>

Where the existing header node would just be enhanced to split on the delim and 
put in multiple headers if the resulting array was length > 1

Would that work for you?

Original comment by [email protected] on 19 Aug 2011 at 12:58

  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

On its face, this looks great!

Original comment by [email protected] on 19 Aug 2011 at 1:45

  • Added labels: ****
  • Removed labels: ****

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant