Sending multi-part MIME package via HTTP-POST

squishywaffle at gmail.com squishywaffle at gmail.com
Mon Oct 13 21:25:52 CEST 2008


This has got me somewhat stumped, so I'll throw it up here in hopes
that someone has ran into this before. I'm trying to send a MIME
package to Esko Backstage. I'm a bit confused as to how to send this
to the server in a manner that it'll be able to get and de-code the
MIME package in a valid way.

The big question is does this entire mime package belong in the
headers section of an HTTP request? If not, what is the best Pythonic
way to send this thing. I'm using 2.5's email package to create the
package and was trying to use its as_string() method to pump this
through httplib, but I'm getting a very vague server error message
that seems to indicate a malformed package. Here is the broken code:

        hcon = httplib.HTTPConnection(JMF_GATEWAY)
        hcon.putrequest('POST', JMF_GATEWAY_PATH)
        hcon.endheaders()
        hcon.send(msg.as_string())

I've pasted the string representation of the MIME package I'm trying
to send below. Any ideas would be greatly appreciated.

Content-Type: multipart/related;
boundary="===============1845688244=="
MIME-Version: 1.0
start: cid:beginning

--===============1845688244==
Content-Type: application/vnd.cip4-jmf+xml
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-ID: beginning

<?xml version="1.0" ?><JMF SenderID="QMon" Version="1.2"><Command
ID="Link1290_5" Type="SubmitQueueEntry"><QueueSubmissionParams
Hold="false" Priority="50" URL="cid:aJDF_1"/></Command></JMF>
--===============1845688244==
Content-Type: application/vnd.cip4-jdf+xml
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-ID: aJDF_1

<?xml version="1.0" ?>
<JDF DescriptiveName="StepRepeatTab and RIP" ID="n0001"
Status="Waiting" Type="ProcessGroup" Version="1.2" xmlns="http://
www.CIP4.org/JDFSchema_1_1" xmlns:eg="http://www.esko-graphics.com/
EGschema1_0">
        <ResourcePool>
                <RunList Class="Parameter" DescriptiveName="1-up"
ID="SourceFileList" PartIDKeys="Run" Status="Available">
                        <RunList Run="Run0001">
                                <LayoutElement>
                                        <FileSpec URL="/archive/49297
PEPPINOS/49297-1 DMT-20.pdf"/>
                                </LayoutElement>
                        </RunList>
                </RunList>
        </ResourcePool>
        <JDF DescriptiveName="RIP1up" ID="n0003" Status="Waiting"
Type="eg:BackStageTask" Version="1.2" xmlns="http://www.CIP4.org/
JDFSchema_1_1" xmlns:eg="http://www.esko-graphics.com/EGschema1_0">
                <NodeInfo JobPriority="50"/>
                <ResourcePool>
                        <eg:BackStageTaskParams Class="Parameter"
ID="TaskParamLink" Status="Available" eg:Hold="false" eg:TicketName="/
fripfile_s.file_sModel1.grx/XXXPROOFTICKETXXX"/>
                </ResourcePool>
                <ResourceLinkPool>
                        <eg:BackStageTaskParamsLink Usage="Input"
rRef="TaskParamLink"/>
                        <RunListLink Usage="Input"
rRef="SourceFileList"/>
                        <RunListLink Usage="Output" rRef="TIFFList"/>
                </ResourceLinkPool>
        </JDF>
</JDF>

--===============1845688244==--




More information about the Python-list mailing list