Skip to content

Instantly share code, notes, and snippets.

@kaito834
Created June 27, 2015 06:10
Show Gist options
  • Save kaito834/12244be613c6e6b1c59a to your computer and use it in GitHub Desktop.
Save kaito834/12244be613c6e6b1c59a to your computer and use it in GitHub Desktop.
send a HTTP request which Content-Type is 'multipart/mixed' by cURL
@echo off
REM http://curl.haxx.se/docs/manpage.html#-F
REM http://curl.haxx.se/mail/archive-2010-03/0049.html
REM cURL installed with msysgit is used on this batch.
REM Output of "curl -V" is below
REM curl 7.41.0 (i386-pc-win32) libcurl/7.41.0 OpenSSL/0.9.8zf zlib/1.2.8
REM Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smtp smtps telnet tftp
REM Features: AsynchDNS IPv6 Largefile SSPI Kerberos SPNEGO NTLM SSL libz
set curlPath="C:\Program Files (x86)\Git\bin\curl.exe"
set traceFilePath=tracefile.txt
REM I would like to delete Content-Disposition header on multipart body.
REM I will delete or replace by local proxy tool; for example, Burp Suite.
%cURLPath% -X POST -H "Content-Type: multipart/mixed" -F [email protected];type=application/json -F [email protected];type=image/jpeg --trace-ascii %traceFilePath% http://127.0.0.1/
$>type sample.json
{
"id": 123,
"objects": [
{
"str1": "hoge",
"str2": "fuga"
},
{
"str1": "fuga",
"str2": "hoge",
}
]
}
$>type sample.jpg
sample jpeg
$>curl_multipart-mixed_samaple.bat
<html><body><h1>POST!</h1></body></html>
$>type tracefile.txt
== Info: Trying 127.0.0.1...
== Info: Connected to 127.0.0.1 (127.0.0.1) port 80 (#0)
=> Send header, 199 bytes (0xc7)
0000: POST / HTTP/1.1
0011: User-Agent: curl/7.41.0
002a: Host: 127.0.0.1
003b: Accept: */*
0048: Content-Length: 496
005d: Expect: 100-continue
0073: Content-Type: multipart/mixed; boundary=------------------------
00b3: 0f7574abc885565b
00c5:
== Info: Done waiting for 100-continue
=> Send data, 147 bytes (0x93)
0000: --------------------------0f7574abc885565b
002c: Content-Disposition: form-data; name="name"; filename="sample.js
006c: on"
0071: Content-Type: application/json
0091:
=> Send data, 148 bytes (0x94)
0000: {. "id": 123,. "objects": [. {. "str1": "hoge",.
0040: "str2": "fuga". },. {. "str1": "fuga",. "str2":
0080: "hoge",. }. ].}.
=> Send data, 142 bytes (0x8e)
0000:
0002: --------------------------0f7574abc885565b
002e: Content-Disposition: form-data; name="name"; filename="sample.jp
006e: g"
0072: Content-Type: image/jpeg
008c:
=> Send data, 11 bytes (0xb)
0000: sample jpeg
=> Send data, 48 bytes (0x30)
0000:
0002: --------------------------0f7574abc885565b--
== Info: HTTP 1.0, assume close after body
<= Recv header, 17 bytes (0x11)
0000: HTTP/1.0 200 OK
<= Recv header, 35 bytes (0x23)
0000: Server: BaseHTTP/0.6 Python/3.4.3
<= Recv header, 37 bytes (0x25)
0000: Date: Sat, 27 Jun 2015 06:07:09 GMT
<= Recv header, 25 bytes (0x19)
0000: Content-type: text/html
<= Recv header, 2 bytes (0x2)
0000:
<= Recv data, 40 bytes (0x28)
0000: <html><body><h1>POST!</h1></body></html>
== Info: Closing connection 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment