コード例 #1
0
ファイル: xhtmltest.py プロジェクト: ShriramK/miro
    def test(self):
        vars = {
                'foo': u'123',  # unicode string
        }

        files = {
            'baz': {"filename":"binarydata.zip",
                 "mimetype":"application/octet-stream",
                 "handle": StringIO('\xf8'), 
             } # baz has invalid unicode data
        }

        boundary, data = xhtmltools.multipart_encode(vars, files)
コード例 #2
0
ファイル: xhtmltest.py プロジェクト: zjmmjzzjm/miro
    def test(self):
        vars = {
            'foo': u'123',  # unicode string
        }

        files = {
            'baz': {
                "filename": "binarydata.zip",
                "mimetype": "application/octet-stream",
                "handle": StringIO('\xf8'),
            }  # baz has invalid unicode data
        }

        boundary, data = xhtmltools.multipart_encode(vars, files)
コード例 #3
0
    def _setup_post(self, handle, out_headers):
        data = None
        if self.post_files is not None:
            (data, boundary) = multipart_encode(self.post_vars,
                                                self.post_files)
            content_type = 'multipart/form-data; boundary=%s' % boundary
            out_headers['content-type'] = content_type
            out_headers['content-length'] = len(data)
            out_headers['expect'] = ''
        elif self.post_vars is not None:
            data = url_encode_dict(self.post_vars)

        if data is not None:
            handle.setopt(pycurl.POSTFIELDS, data)
            # Bind the post data to a instance varible so that it doesn't get
            # garbage collected while libcurl is reading it (#14631)
            self.post_data = data
            self.post_length = len(data)
コード例 #4
0
ファイル: httpclient.py プロジェクト: adarshr/miro
    def _setup_post(self, handle, out_headers):
        data = None
        if self.post_files is not None:
            (data, boundary) = multipart_encode(self.post_vars,
                    self.post_files)
            content_type = 'multipart/form-data; boundary=%s' % boundary
            out_headers['content-type'] = content_type
            out_headers['content-length'] = len(data)
            out_headers['expect'] = ''
        elif self.post_vars is not None:
            data = url_encode_dict(self.post_vars)

        if data is not None:
            handle.setopt(pycurl.POSTFIELDS, data)
            # Bind the post data to a instance varible so that it doesn't get
            # garbage collected while libcurl is reading it (#14631)
            self.post_data = data
            self.post_length = len(data)