Created
March 25, 2019 04:44
-
-
Save kdkanishka/49acbc0b0289947cd0de1d439eb528c3 to your computer and use it in GitHub Desktop.
Raw HTTP Request Using Sockets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.pagero.services.protocol.as2outbound.core.util.IOUtil; | |
import java.io.FileInputStream; | |
import java.io.InputStream; | |
import java.io.OutputStream; | |
import java.net.Socket; | |
public class TestSocket { | |
public static void main(String[] args) { | |
int SERVER_PORT = 31481; | |
try { | |
Socket conn = new Socket("dev.localhost",SERVER_PORT); | |
InputStream in = new FileInputStream("/home/kanishka/Downloads/data.txt"); | |
OutputStream out = conn.getOutputStream(); | |
IOUtil.copy(in , conn.getOutputStream()); | |
out.flush(); | |
out.close(); | |
in.close(); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
} | |
/** | |
Sample HTTP format for data.txt | |
POST /inbound/as2 HTTP/1.0 | |
X-Forwarded-Proto: https | |
Host: www.abc.com | |
Connection: close | |
Content-Length: 16403 | |
content-disposition: attachment; filename="smime.p7m" | |
AS2-From: A1 | |
Disposition-Notification-To: A1 | |
AS2-Version: 1.2 | |
content-type: application/pkcs7-mime; name="smime.p7m"; smime-type=enveloped-data | |
Message-ID: <123.abc@as2> | |
AS2-To: B1 | |
Disposition-Notification-Options: signed-receipt-protocol=optional, pkcs7-signature; signed-receipt-micalg=optional, sha-256, sha1, sha-224, sha-384, sha-512, md5 | |
Subject: AAAAA | |
Date: Fri, 22 Mar 2019 13:26:38 GMT | |
User-Agent: Apache-HttpClient/4.5.3 (Java/1.8.0_152) | |
Accept-Encoding: gzip,deflate | |
HTTP BODY | |
**/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment