HTTP Error 415 Unsupported media type - upload

I am still on the same problem as:
Upload binary data with HTTP PUT with jersey jaxrs-ri-2.01
But I am one step further. Now I am testing my data upload with this tool:
I'm Only Resting
The problem, and I don't know if it's a client or a server problem is that when I'm testing, I get HTTP 415 - Unsupported Media Type
In the client:
I have checked the PUT method
In the body I have put one blank line (return) and in the second line i wrote test
In the server, It was working until I added this parameter
#FormDataParam("file") InputStream pBodyDataStream
and this code:
try {
OutputStream lOutputStream = new FileOutputStream(new File("F:/test.bin"));
int read = 0;
byte[] bytes = new byte[fragmentSize];
while ((read = pBodyDataStream.read(bytes)) != -1) {
lOutputStream.write(bytes, 0, read);
}
lOutputStream.close();
pBodyDataStream.close();
} catch (IOException e) {
// fragment reception error
// HTTP 500 error
lOutput = xmlError("Upload error while transferring fragment");
e.printStackTrace();
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(lOutput).build();
}
Here is a screenshot of the test tool with the parameters:
Here is the cURL investigation:
The command line:
curl -v -H "application/octet-stream" -K params_curl.txt
The cURL parameters file:
url = "localhost:8080/ServeurWS/softplus/biens/arts/2345412/images?user=wow&pass=wow&taille=100&numfrag=1&taillefrag=10&md5=d6aa97d33d459ea3670056e737c99a3d&md6=5da8aa7126701c9840f99f8e9fa54976"
request="PUT"
upload-file="f:/vcredist.bmp"
output = "output.html"
user-agent = "superagent/1.0"
The headers I see, thanks to the -v option:
C:\Users\Dev\Desktop>curl -v -I -H "application/octet-stream" -K params_curl.txt
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying ::1...
* Connected to localhost (::1) port 8080 (#0)
> PUT /ServeurWS/softplus/biens/arts/2345412/images?user=wow&pass=wow&taille=100&numfrag=1&taillefrag=10&md5=d6aa97d33d459ea3670056e737c99a3d&md6=5da8aa7126701
c9840f99f8e9fa54976 HTTP/1.1
> Host: localhost:8080
> User-Agent: superagent/1.0
> Accept: */*
> Content-Length: 5686
> Expect: 100-continue
>
< HTTP/1.1 100 Continue
} [5686 bytes data]
* We are completely uploaded and fine
< HTTP/1.1 415 Type de Support Non Supporté
< Server: Apache-Coyote/1.1
< Content-Type: text/html;charset=utf-8
< Content-Length: 1108
< Date: Wed, 02 Dec 2015 13:56:07 GMT
<
{ [1108 bytes data]
100 6794 100 1108 100 5686 11080 56860 --:--:-- --:--:-- --:--:-- 63177
* Connection #0 to host localhost left intact
The output.html file:
HTTP/1.1 100 Continue
HTTP/1.1 415 Type de Support Non Supporté
Server: Apache-Coyote/1.1
Content-Type: text/html;charset=utf-8
Content-Length: 1108
Date: Wed, 02 Dec 2015 13:56:07 GMT
<html><head><title>Apache Tomcat/6.0.44 - Rapport d'erreur</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>Etat HTTP 415 - Unsupported Media Type</h1><HR size="1" noshade="noshade"><p><b>type</b> Rapport d'état</p><p><b>message</b> <u>Unsupported Media Type</u></p><p><b>description</b> <u>Le serveur a refusé cette requête car l'entité de requête est dans un format non supporté par la ressource demandée avec la méthode spécifiée.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/6.0.44</h3></body></html>
And there is no error in the Eclipse console...

Related

HTTPS Post Request with ESP8266

I'm trying to send an HTTPS POST request with a ESP8266. I can make the request just fine with python and cURL just when I try it with the ESP it doesn't work. A segment of my code is below
const char *host = "api.pushbullet.com";
const int httpsPort = 443;
const char fingerprint[] PROGMEM = "4C 70 C5 AE F3 30 E8 29 D1 9C 18 C6 2F 08 D0 6A A9 AA 19 0F";
Link = "/post";
httpsClient.print(String("POST ") + Link + " HTTP/1.1\r\n" +
"Host: " + host + "/v2/pushes" + "\r\n" +
"Access-Token: *************"+ "\r\n" +
"Content-Type: application/json"+ "\r\n" +
"Content-Length: 20"+ "\r\n" +
"body: Hello World" + "\r\n\r\n");
Serial.println("request sent");
The request I'm trying to make is below. This works just fine in python
import requests
headers = {
'Access-Token': '***********',
'Content-Type': 'application/json',
}
data = '{"body":"Hello World","title":"Hi","type":"note"}'
response = requests.post('https://api.pushbullet.com/v2/pushes', headers=headers, data=data)
And in cURL:
curl --header 'Access-Token: **********' --header 'Content-Type: application/json' --data-binary '{"body":"Hello World","title":"Hi","type":"note"}' --request POST https://api.pushbullet.com/v2/pushes
When I make the request with the Arduino code it returns "Error 411 (Length Required)!!".
This is probably due to some stupid mistake I've made but if anyone could help me fix my Arduino code I'd be very grateful. Thanks
There are a few mistakes in your code.
your http POST format are incorrect in a)host name, b)uri, and c)header/body separation;
your http body is not a valid json object.
Here is an example on sending the http (without using String):
const char *host = "api.pushbullet.com";
const char *uri = "/post/v2/pushes/";
const char *body ="{\"body\": \"Hello World\"}"; // a valid jsonObject
char postStr[40];
sprintf(postStr, "POST %s HTTP/1.1", uri); // put together the string for HTTP POST
httpsClient.println(postStr);
httpsClient.print("Host: "); httpsClient.println(host);
httpsClient.println("Access-Token: *************");
httpsClient.println("Content-Type: application/json");
httpsClient.print("Content-Length: "); httpsClient.println(strlen(body));
httpsClient.println(); // extra `\r\n` to separate the http header and http body
httpsClient.println(body);
General advice: when you use cURL always use --verbose to see the full HTTP exchange.
In your case it should be
httpsClient.print(String("POST ") + "/v2/pushes" + Link + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Access-Token: *************"+ "\r\n" +
"Content-Type: application/json"+ "\r\n" +
"Content-Length: 20"+ "\r\n" +
"body: Hello World" + "\r\n\r\n");
Note how
the path is "/v2/pushes/" plus identifier ("Link" in your case?)
Host is just "api.pushbullet.com"
Side notes:
make sure you send correct values for Content-Length
consider using HTTPClient if you are not confident with low-level HTTP programming

Reading UIDs of NFC Cards in iOS 13

I would like to retrive the UID of MiFare cards. I'm using an iPhone X, Xcode 11 and iOS 13.
I'm aware this wasn't possible (specifically reading the UID) until iOS 13 according to this website: https://gototags.com/blog/apple-expands-nfc-on-iphone-in-ios-13/ and this guy: https://www.reddit.com/r/apple/comments/c0gzf0/clearing_up_misunderstandings_and/
The phones NFC reader is correctly detecting the card however the unique identifier is always returned as empty or nil. I can read the payload however and irrelvant to iOS but I can do this in Android (confirms the card isn't faulty or just odd)
Apple Sample Project: https://developer.apple.com/documentation/corenfc/building_an_nfc_tag-reader_app
func tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag]) {
if case let NFCTag.miFare(tag) = tags.first! {
session.connect(to: tags.first!) { (error: Error?) in
let apdu = NFCISO7816APDU(instructionClass: 0, instructionCode: 0xB0, p1Parameter: 0, p2Parameter: 0, data: Data(), expectedResponseLength: 16)
tag.queryNDEFStatus(completionHandler: {(status: NFCNDEFStatus, e: Int, error: Error?) in
debugPrint("\(status) \(e) \(error)")
})
tag.sendMiFareISO7816Command(apdu) { (data, sw1, sw2, error) in
debugPrint(data)
debugPrint(error)
debugPrint(tag.identifier)
debugPrint(String(data: tag.identifier, encoding: .utf8))
}
}
}
}
I'm aware these sorts of hacks: CoreNFC not reading UID in iOS
But they are closed and only apply to iOS 11 for a short time in the past.
Ok I have an answer.
tag.identifier isn't empty -- per se -- if you examine from Xcodes debugger it appears empty (0x00 is the value!). It's type is Data and printing it will reveal the length of the Data but not how it's encoded. In this case it's a [UInt8] but stored as a bag of bits, I don't understand why Apple have done it this way -- it's clunky -- I'm sure they have good reasons. I would have stored it as a type String -- after all the whole point of a high level language like Swift is to abstract us away from such hadware implementation details.
The following code will retrive the UID from a MiFare card:
if case let NFCTag.miFare(tag) = tags.first! {
session.connect(to: tags.first!) { (error: Error?) in
let apdu = NFCISO7816APDU(instructionClass: 0, instructionCode: 0xB0, p1Parameter: 0, p2Parameter: 0, data: Data(), expectedResponseLength: 16)
tag.sendMiFareISO7816Command(apdu) { (apduData, sw1, sw2, error) in
let tagUIDData = tag.identifier
var byteData: [UInt8] = []
tagUIDData.withUnsafeBytes { byteData.append(contentsOf: $0) }
var uidString = ""
for byte in byteData {
let decimalNumber = String(byte, radix: 16)
if (Int(decimalNumber) ?? 0) < 10 { // add leading zero
uidString.append("0\(decimalNumber)")
} else {
uidString.append(decimalNumber)
}
}
debugPrint("\(byteData) converted to Tag UID: \(uidString)")
}
}
}
I know you have said that it returns nil but for clarity for future readers:
Assuming it is not a Felica tag, it should be on the identifier field when it is detected:
func tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag]) {
if case let NFCTag.miFare(tag) = tags.first! {
print(tag.identifier as NSData)
}
}
But in your case, it's empty (see edit below). For most tags the APDU to get the UID of a tag is
0xff // Class
0xca // INS
0x00 // P1
0x00 // P2
0x00 // Le
so you could try using tag.sendMiFareCommand to send that command manually.
Edit: Response from OP, it wasn't empty but was unclear because printing Data in Swift doesn't show in console
In iOS13 I was able read the Tag.identifier value for various MIFARE family's DESfire and UltraLight tags same as #scott-condron's answer, but for various MIFARE Classic ICs (the unknown family member?) my Console shows different error types.
Perhaps private framework APIs similar to the iOS11 work-around in the hack you mentioned would be helpful in these cases, e.g. to intercept and amend the discovery polling routine, but I wouldn't know which ones or how to use them.
Below you can find some test results for MIFARE Classic 4K (emulation) tags, as also reported in this github thread and this MIFARE support thread. Following Table 6 of Application Note #10833, the Select Acknowledge (SAK) value of 0x38 of the emulation tags below translates into 0 0 1 1 1 0 0 0 for bits 8..1, i.e. bits 6, 5, and 4 are 1, and therefore these SAK values classify as Smart MX with CLASSIC 4K as per Figure 3 of Application Note #10834.
an Infineon Classic 4k Emulation successfully logs 1 tags found with the correct UID (31:9A:2F:88), ATQA (0x0200), SAK (detects 0x20, i.e. ISO 14443-4 protocol, and 0x18, i.e. MIFARE 4K, both part of the expected value: 0x38) and respective tag type (both Generic 4A and MiFare classified correctly), but then throws a Stack Error:
error 14:48:08.675369 +0200 nfcd 00000001 04e04390 -
[NFDriverWrapper connectTag:]:1436 Failed to connect to tag:
<NFTagInternal: 0x104e05cd0>-{length = 8, bytes = 0x7bad030077180efa}
{ Tech=A Type=Generic 4A ID={length = 4, bytes = 0x319a2f88}
SAK={length = 1, bytes = 0x20} ATQA={length = 2, bytes = 0x0200} historicalBytes={length = 0, bytes = 0x}}
:
error 14:48:08.682881 +0200 nfcd 00000001 04e04390 -
[NFDriverWrapper connectTag:]:1436 Failed to connect to tag:
<NFTagInternal: 0x104e1d600>-{length = 8, bytes = 0x81ad0300984374f3}
{ Tech=A Type=MiFare ID={length = 4, bytes = 0x319a2f88}
SAK={length = 1, bytes = 0x18} ATQA={length = 2, bytes = 0x0200} historicalBytes={length = 0, bytes = 0x}}
:
default 14:48:08.683150 +0200 nfcd 00000001 04e07470 -
[_NFReaderSession handleRemoteTagsDetected:]:445 1 tags found
default 14:48:08.685792 +0200 nfcd 00000001 04e07470 -
[_NFReaderSession connect:callback:]:507 NFC-Example
:
error 14:48:08.693429 +0200 nfcd 00000001 04e04390 -
[NFDriverWrapper connectTag:]:1436 Failed to connect to tag:
<NFTagInternal: 0x104e05cd0>-{length = 8, bytes = 0x81ad0300984374f3}
{ Tech=A Type=MiFare ID={length = 4, bytes = 0x319a2f88}
SAK=(null) ATQA=(null) historicalBytes={length = 0, bytes = 0x}}
:
error 14:48:08.694019 +0200 NFC-Example 00000002 802e2700 -
[NFCTagReaderSession _connectTag:error:]:568 Error
Domain=NFCError Code=100 "Stack Error" UserInfo={NSLocalizedDescription=Stack Error, NSUnderlyingError=0x2822a86c0
{Error Domain=nfcd Code=15 "Stack Error" UserInfo={NSLocalizedDescription=Stack Error}}}
an NXP SmartMX (Classic 4k emulation) with UID CF:3E:40:04 is discovered initially, but a reception error during ISO 14443-4A presence check (Proc Iso-Dep pres chk ntf: Receiption failed) continuously restarts the discovery polling until the session finally expires, possibly preventing the other SAK value 0x18 (for MIFARE 4K tag type) to be received:
error 10:44:50.650673 +0200 nfcd Proc Iso-Dep pres chk ntf: Receiption failed
:
error 10:44:50.677470 +0200 nfcd 00000001 04e04390 -
[NFDriverWrapper disconnectTag:tagRemovalDetect:]:1448 Failed to disconnect tag:
<NFTagInternal: 0x104f09930>-{length = 8, bytes = 0x07320d00f3041861}
{ Tech=A Type=Generic 4A ID={length = 4, bytes = 0xcf3e4004}
SAK={length = 1, bytes = 0x20} ATQA={length = 2, bytes = 0x0200} historicalBytes={length = 0, bytes = 0x}}
default 10:44:50.677682 +0200 nfcd 00000001 04e04390 -
[NFDriverWrapper restartDiscovery]:1953
an actual NXP Classic 4k with UID 2D:FE:9B:87 remains undetected and throws no error. The discovery polling session for this tag simply times out after 60 seconds and logs the last 128 discovery messages transmitted (Tx) and received (Rx), among which the following pattern is repeated (which does include the expected UID: 2D FE 9B 87):
error 11:42:19.511354 +0200 nfcd 1571305339.350902 Tx '21 03 07 03 FF 01 00 01 01 01 6F 61'
error 11:42:19.511484 +0200 nfcd 1571305339.353416 Rx '41 03 01'
error 11:42:19.511631 +0200 nfcd 1571305339.353486 Rx '00 F6 89'
error 11:42:19.511755 +0200 nfcd 1571305339.362455 Rx '61 05 14'
error 11:42:19.511905 +0200 nfcd 1571305339.362529 Rx '01 80 80 00 FF 01 09 02 00 04 2D FE 9B 87 01 18 00 00 00 00 2D 11'
error 11:42:19.512152 +0200 nfcd 1571305339.362734 Tx '21 06 01 00 44 AB'
error 11:42:19.512323 +0200 nfcd 1571305339.363959 Rx '41 06 01'
error 11:42:19.512489 +0200 nfcd 1571305339.364028 Rx '00 1D 79'
error 11:42:19.512726 +0200 nfcd 1571305339.364300 Rx '61 06 02'
error 11:42:19.512914 +0200 nfcd 1571305339.364347 Rx '00 00 EB 78'

Get RTMP uri to Youtube LiveStream video

Can I get RTMP uri of Youtube live-stream using live-stream ID with Youtube Data API v3? For example, for this channel: https://www.youtube.com/watch?v=4YKR-rEwOr8
When I try to do this using "try" page https://developers.google.com/youtube/v3/live/docs/liveStreams/list (part = "status,cdn", id = "4YKR-rEwOr8") I got empty list:
200 OK
- Hide headers -
Cache-Control: private, max-age=0, must-revalidate, no-transform
Content-Encoding: gzip
Content-Length: 183
Content-Type: application/json; charset=UTF-8
Date: Mon, 27 Oct 2014 11:10:54 GMT
Etag: "PSjn-HSKiX6orvNhGZvglLI2lvk/HzQflIssFHeC_PS9MZIweemMYZg"
Expires: Mon, 27 Oct 2014 11:10:54 GMT
Server: GSE
{
"kind": "youtube#liveStreamListResponse",
"etag": "\"PSjn-HSKiX6orvNhGZvglLI2lvk/HzQflIssFHeC_PS9MZIweemMYZg\"",
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 0
},
"items": [
]
}
What I do wrong? I really don't understand.

HTTP 302 - Not found parameter GSessionID - Google Calendar

I need help .
I want to create events on google calendar with a desktop application , when the parameters sent
url = 'https://www.google.com/calendar/feeds/emaill%40gmail.com/private/full';
and then add xml where this event to create
createXML := '<?xml version=''1.0'' encoding=''UTF-8''?>'#13#10 +
'<entry xmlns=''http://www.w3.org/2005/Atom'''#13#10 +
'xmlns:gd=''http://schemas.google.com/g/2005''>'#13#10 +
'<category scheme=''http://schemas.google.com/g/2005#kind'''#13#10 +
'term=''http://schemas.google.com/g/2005#event''></category>'#13#10 +
'<title type=''text''>' + title + '</title>'#13#10 +
'<content type=''text''>' + content + '</content>'#13#10 +
'<gd:transparency'#13#10 +
'value=''http://schemas.google.com/g/2005#event.opaque''>'#13#10 +
'</gd:transparency>'#13#10 +
'<gd:eventStatus'#13#10 +
'value=''http://schemas.google.com/g/2005#event.confirmed''>'#13#10 +
'</gd:eventStatus>'#13#10 +
'<gd:where valueString=''' + location + '''></gd:where>'#13#10 +
'<gd:when startTime=''' + EventStartTime + ''''#13#10 +
'endTime=''' + EventEndTime + '''></gd:when>'#13#10 +
'</entry>';
When I do the POST process the next header appears
HTTP/1.0 302 Moved Temporarily
Expires: Wed, 30 April 2014 17:37:17 GMT
Date: Wed, 30 April 2014 17:37:17 GMT
Set- Cookie: T=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx;
Expires = Tue, 13 -May- 2014 10:32:28 GMT;
SecureLocation : https://www.google.com:443/calendar/feeds/default/private/full?t=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Content- Type: text / html ; charset = UTF -8
Cache- Control: private , max -age = 0
X -Content -Type -Options : nosniff
X -Frame -Options : SAMEORIGIN
X -XSS -Protection : 1; mode = block
Server : GSE
Alternate -Protocol : 443: quic
In the manual, Google listed me I need a variable called " GSessionID " but does not appear to me,
I would please help me with this problem .
I have two projects with authentication: ClientLogin and OAuth 2.0
as I get to get this parameter?
Thanks a lot.
Us Google Translator
It has to work to retrieve the newly loaded gsessionID condition Realize post procedure twice, the second in the exception
try
idHTTP2.Post(URL,XML);
except on E: EIdHTTPProtocolException do
idHTTP2.Post(URL,XML);
end;
Thanks for your time.

Http connection using apache.DefaultHttpClient goes into TIME_WAIT not getting reused

We have a pool(GenericObjectPool) of HttpClient(apache.DefaultHttpClient) objects. HttpPost objects are put into for execution through these clients may Post request are sent simultaneously. The protocol used is: HTTP/1.1 with keepalive.
Observed during load testing through netstat that new socket connections are indiscriminately created and old connections goes to TIME_WAIT.
Log Excerpts:-
[Worker-2] org.apache.http.impl.conn.Wire 63 - >> "POST /INBOX/4504a09e-13c0-3853-a285-9e2b9a22f65e/1e1e5a20-a8c1-11e2-99b8-7c19e9129271 HTTP/1.1[\r][\n]"
[Worker-2] org.apache.http.impl.conn.Wire 63 - >> "Content-Type: application/json; charset=UTF-8[\r][\n]"
[Worker-2] org.apache.http.impl.conn.Wire 63 - >> "Content-Length: 117[\r][\n]"
[Worker-2] org.apache.http.impl.conn.Wire 63 - >> "Host: rwcdtgxb0402:15010[\r][\n]"
[Worker-2] org.apache.http.impl.conn.Wire 63 - >> "Connection: Keep-Alive[\r][\n]"
[Worker-2] org.apache.http.impl.conn.Wire 63 - >> "User-Agent: Apache-HttpClient/4.2.1 (java 1.5)[\r][\n]"
[Worker-2] org.apache.http.impl.conn.Wire 63 - >> "[\r][\n]"
[Worker-2] org.apache.http.impl.conn.Wire 63 - << "HTTP/1.1 200 OK[\r][\n]"
[Worker-2] org.apache.http.impl.conn.Wire 63 - << "Content-Length: 0[\r][\n]"
[Worker-2] org.apache.http.impl.conn.Wire 63 - << "[\r][\n]"
[Worker-2] org.apache.http.impl.conn.DefaultClientConnection 254 - Receiving response: HTTP/1.1 200 OK
[Worker-2] org.apache.http.impl.conn.DefaultClientConnection 257 - << HTTP/1.1 200 OK
[Worker-2] org.apache.http.impl.conn.DefaultClientConnection 260 - << Content-Length: 0
[Worker-2] org.apache.http.impl.client.DefaultRequestDirector 540 - Connection can be kept alive indefinitely
**[Worker-2] org.apache.http.impl.conn.DefaultClientConnection 154 - Connection 0.0.0.0:51211<->192.168.88.172:15010 shut down**
[Worker-2] org.apache.http.impl.conn.BasicClientConnectionManager 189 - Releasing connection org.apache.http.impl.conn.ManagedClientConnectionImpl#12f65ce5
Is DefaultClientConnection.shutdown (Connection 0.0.0.0:51210<->192.168.88.172:15010 shut down) closing the connection from Client end? How is it getting invoked?
In code after receiving the response (200OK) from server httpPost.releaseConnection() is only executed in client side code.
What should I do to keep the connections in ESTABLISHED state and reuse them instead of creating the connection for every request and they going into TIME_WAIT.
Any help will be highly appreciated. Thank you.
Note calling EntityUtils.consume(entity) does a bit more and should be used:
/**
* Ensures that the entity content is fully consumed and
* the content stream, if exists, is closed.
*
* #param entity the entity to consume.
* #throws IOException if an error occurs reading the input stream
*
* #since 4.1
*/
public static void consume(final HttpEntity entity) throws IOException {
if (entity == null) {
return;
}
if (entity.isStreaming()) {
final InputStream inStream = entity.getContent();
if (inStream != null) {
inStream.close();
}
}
}
Got the problem resolved few days back.
Mistake: calling releaseConnection() on the HttpClient object. BUT, avoiding it did not solve the problem either.
Correction:
The action to be taken for keeping the connections alive (in state ESTABLISHED) was through following sample code:
HttpClient client = new org.apache.http.impl.client.DefaultHttpClient();
...
org.apache.http.HttpResponse response = client.executed(HttpPost) ;
org.apache.http.HttpEntity en = response.getEntity();
if (en != null) {
en.getContent().close();
}
Once the HttpResponse is received, in order to reuse and maintain the created connection it is necessary to close only the InputStream (en.getContent()) on the http-response. Do not call any other release method on HttpPost or Client objects.
Tested this handling with JMeter load and found it working. Haven't observed any side effects yet!

Resources