Try to Mock calls with Content -Type : Application/PDF

609 views
Skip to first unread message

Anurag Vaidhya

unread,
Apr 26, 2018, 8:17:15 PM4/26/18
to mountebank-discuss
Hi Team,

I am trying to mock scenario in which i need to send a PDF file  . I am able to get the file but it is blank . Has anybody face any scenario like this? If yes please suggest a better or best way to do it . 


Thanks
Anurag

Brandon Byars

unread,
Apr 29, 2018, 9:14:35 PM4/29/18
to Anurag Vaidhya, mountebank-discuss
Hi there,
I suspect this requires a new feature, as I think we'll have to add an "attachments" field to the http response JSON structure. I haven't verified, but I think the HTTP libraries are interpreting the headers to say there's an attachment coming, but abstracting the attachment in a field that's currently not exposed. I'll add a feature request.
-Brandon

--
You received this message because you are subscribed to the Google Groups "mountebank-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mountebank-discuss+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

PK

unread,
May 11, 2019, 12:02:14 AM5/11/19
to mountebank-discuss
Give a try with below, it works if the pdf is encoded in base64 but not as Binary. If the client accepts base64 it will suffice the requirement.

{
"name": "attachPDF",
"port": 30009,
"protocol": "http",
"stubs": [{
"responses": [{
"is": {
"statusCode": 200,
"headers": {
"HTTP-Response-Code": 200,
"HTTP-Response-Code-Text": "OK",
"X-Backside-Transport": "OK OK,OK OK,OK OK",
"Connection": "Keep-Alive",
"X-Global-Transaction-ID": "a5df1c57540d",
"Content-Type": "application/xml",
"LittleEndian" : "false",
"ByteAlign" : "true",
"Content-Type": "Multipart/Related; boundary=MIME_boundary",
"MIME-Version" : "1.0",
"Content-Description" : "Value"
},
"body": "<%- stringify(filename, 'payload/attachPDF.txt') %>"
}
}],
"predicates": [{
"contains": {
"method": "POST",
"path": "/path"
}
}]
}]
}




attachPDF.txt

--MIME_boundary
Content-Type: text/xml; charset=UTF-8
Content-Transfer-Encoding: 8bit
Content-ID: <mycla...@ca.com>

<XML or Wrappers if any>

--MIME_boundary
Content-Type: application/octet-stream
Content-Transfer-Encoding: base64
Content-ID: <mycla...@ca.com>

<encoded base64 string>

--MIME_boundary--

Thanks,
PK
Reply all
Reply to author
Forward
0 new messages