Ashwin
Ashwin

Reputation: 13547

Value starting with a "Space" in HttpURLConnection.add Request Property?

This is the code in the client:
connection.addRequestProperty("key", value);
This is the code in the server :

String user=req.getHeader("key");
System.out.println(user);


If the value is, for eg, "abcd xyz" in the client, printed value in the server is the same. But if the value is " abcd xyz", the value printed in the server is "abcd xyz" i,e the starting space is not there.
What is the problem here?

Upvotes: 0

Views: 221

Answers (1)

Julian Reschke
Julian Reschke

Reputation: 42065

In HTTP header field values, leading and trailing whitespace is not significant. Thus, they will be gone after parsing.

Upvotes: 1

Related Questions