Bugfix for NETCONF 1.1 where XML header was entered twice

Change-Id: Id8c9fa2ba71ea746637c691488c8811746506fce
diff --git a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfSessionMinaImpl.java b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfSessionMinaImpl.java
index dfb82ca..99f79cd 100644
--- a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfSessionMinaImpl.java
+++ b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfSessionMinaImpl.java
@@ -578,7 +578,7 @@
      * @return XML RPC message
      */
     private String formatXmlHeader(String request) {
-        if (!request.startsWith(XML_HEADER)) {
+        if (!request.contains(XML_HEADER)) {
             //FIXME if application provides his own XML header of different type there is a clash
             if (request.startsWith(LF + HASH)) {
                 request = request.split("<")[0] + XML_HEADER + request.substring(request.split("<")[0].length());
diff --git a/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/impl/NetconfSessionImplTest.java b/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/impl/NetconfSessionImplTest.java
index e0386f7..51bf91c 100644
--- a/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/impl/NetconfSessionImplTest.java
+++ b/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/impl/NetconfSessionImplTest.java
@@ -667,7 +667,7 @@
                     Pattern.DOTALL);
 
     public static final Pattern HELLO_REQ_PATTERN_1_1 =
-            Pattern.compile("(<\\?xml).*"
+            Pattern.compile("(<\\?xml version=\"1.0\" encoding=\"UTF-8\"\\?>)\\R?"
                             + "(<hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">)\\R?"
                             + "( *)(<capabilities>)\\R?"
                             + "( *)(<capability>urn:ietf:params:netconf:base:1.0</capability>)\\R?"
@@ -677,7 +677,7 @@
                     Pattern.DOTALL);
 
     public static final Pattern EDIT_CONFIG_REQ_PATTERN =
-            Pattern.compile("(<\\?xml).*"
+            Pattern.compile("(<\\?xml version=\"1.0\" encoding=\"UTF-8\"\\?>)\\R?"
                     + "(<rpc message-id=\")[0-9]*(\") *(xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">)\\R?"
                     + "(<edit-config>)\\R?"
                     + "(<target>\\R?((<" + DatastoreId.CANDIDATE.toString() + "/>)|"
@@ -689,7 +689,7 @@
 
 
     public static final Pattern LOCK_REQ_PATTERN =
-            Pattern.compile("(<\\?xml).*"
+            Pattern.compile("(<\\?xml version=\"1.0\" encoding=\"UTF-8\"\\?>)\\R?"
                     + "(<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" "
                     + "message-id=\")[0-9]*(\">)\\R?"
                     + "(<lock>)\\R?"
@@ -699,7 +699,7 @@
                     + "(</lock>)\\R?(</rpc>)\\R?", Pattern.DOTALL);
 
     public static final Pattern UNLOCK_REQ_PATTERN =
-            Pattern.compile("(<\\?xml).*"
+            Pattern.compile("(<\\?xml version=\"1.0\" encoding=\"UTF-8\"\\?>)\\R?"
                     + "(<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" "
                     + "message-id=\")[0-9]*(\">)\\R?"
                     + "(<unlock>)\\R?"
@@ -709,7 +709,7 @@
                     + "(</unlock>)\\R?(</rpc>)\\R?", Pattern.DOTALL);
 
     public static final Pattern COPY_CONFIG_REQ_PATTERN =
-            Pattern.compile("(<\\?xml).*"
+            Pattern.compile("(<\\?xml version=\"1.0\" encoding=\"UTF-8\"\\?>)\\R?"
                     + "(<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\")[0-9]*(\">)\\R?"
                     + "(<copy-config>)\\R?"
                     + "(<target>\\R?"
@@ -730,7 +730,7 @@
                     + "(</copy-config>)\\R?(</rpc>)\\R?", Pattern.DOTALL);
 
     public static final Pattern GET_CONFIG_REQ_PATTERN =
-            Pattern.compile("(<\\?xml).*"
+            Pattern.compile("(<\\?xml version=\"1.0\" encoding=\"UTF-8\"\\?>)\\R?"
                     + "(<rpc message-id=\")[0-9]*(\"  xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">)\\R?"
                     + "(<get-config>)\\R?" + "(<source>)\\R?((<"
                     + DatastoreId.CANDIDATE.toString()
@@ -743,7 +743,7 @@
 
 
     public static final Pattern GET_REQ_PATTERN =
-            Pattern.compile("(<\\?xml).*"
+            Pattern.compile("(<\\?xml version=\"1.0\" encoding=\"UTF-8\"\\?>)\\R?"
                     + "(<rpc message-id=\")[0-9]*(\"  xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">)\\R?"
                     + "(<get>)\\R?"
                     + "(<filter type=\"subtree\">).*(</filter>)\\R?"