Build the request document body.
7926
protected function build()
    {
        $operation = $this->buildOperation('DeleteProfile');

        $merchantID = $this->document->createElement(
            'merchantID',
            $this->merchantId
        );
        $operation->appendChild($merchantID);

        $customerId = $this->document->createElement(
            'customerID',
            $this->customerId
        );
        $operation->appendChild($customerId);

        if ($this->profileId) {
            $profileId = $this->document->createElement(
                'profileID',
                $this->profileId
            );
            $operation->appendChild($profileId);
        }
    }
995819
def build(self):
        '''
        
        '''
        header = self.build_header()
        body = self.build_body()
        tail = self.build_tail()
        return header + body + tail
111736
def create_body(action, params):
        """"""
        body = {}
        body['action'] = action
        if params is not None:
            body['params'] = params
        return body
543037
def prepare_body(self, data, files):
        """"""

        # Check if file, fo, generator, iterator.
        # If not, run through normal process.

        # Nottin' on you.
        body = None
        content_type = None
        length = None

        is_stream = all([
            hasattr(data, '__iter__'),
            not isinstance(data, (basestring, list, tuple, dict))
        ])

        try:
            length = super_len(data)
        except (TypeError, AttributeError, UnsupportedOperation):
            length = None

        if is_stream:
            body = data

            if files:
                raise NotImplementedError('Streamed bodies and files are mutually exclusive.')

            if length is not None:
                self.headers['Content-Length'] = builtin_str(length)
            else:
                self.headers['Transfer-Encoding'] = 'chunked'
        else:
            # Multi-part file uploads.
            if files:
                (body, content_type) = self._encode_files(files, data)
            else:
                if data:
                    body = self._encode_params(data)
                    if isinstance(data, basestring) or hasattr(data, 'read'):
                        content_type = None
                    else:
                        content_type = 'application/x-www-form-urlencoded'

            self.prepare_content_length(body)

            # Add content-type if it wasn't explicitly provided.
            if (content_type) and (not 'content-type' in self.headers):
                self.headers['Content-Type'] = content_type

        self.body = body
392185
protected function buildPDFRequest()
    {
        return (new Request(
            $this->getApplication(),
            $this->buildPDFURL(),
            Request::METHOD_GET
        ))->setHeader(
            Request::HEADER_ACCEPT,
            Request::CONTENT_TYPE_PDF
        );
    }
956248
def prepare(self):

        self.body_html = markdown(
            codecs.open(self.abspath, 'r').read(),
            extras=['fenced-code-blocks', 'hilite', 'tables', 'metadata'])

        self.header = self.body_html.metadata
        """"""
        if 'tags' in self.header:  # pages can lack tags
            self.header['tags'] = [t.strip().lower() for t in
                                   self.header['tags'].split(',')]

        else:
            self.header['tags'] = ("",)

        self.date = self.header.get('published', datetime.datetime.now())

        if isinstance(self.date, str):
            self.date = datetime.datetime.strptime(self.date, "%Y-%m-%d")

        for k, v in self.header.items():
            try:
                setattr(self, k, v)
            except AttributeError:
                pass

        if self.id:
            return

        rec = {'filename': self.path,
               'mtime': int(os.path.getmtime(self.abspath))}

        if self.header['kind'] == 'writing':
            _id = Entry.db.posts.insert(rec)

        elif self.header['kind'] == 'page':
            _id = Entry.db.pages.insert(rec)

        self.id = _id
1334348
def prepare(self):
        """"""
        p = PreparedRequest()
        p.prepare(
            method=self.method,
            url=self.url,
            headers=self.headers,
            files=self.files,
            data=self.data,
            params=self.params,
            auth=self.auth,
            cookies=self.cookies,
            hooks=self.hooks,
        )
        return p
1017572
protected function build()
    {
        $operation = $this->buildOperation('SelectPayment');

        $merchantID = $this->document->createElement('merchantID', $this->merchantId);
        $operation->appendChild($merchantID);

        $xmlMdxi = $this->document->createElement('mdxi', $this->mdxi);
        $operation->appendChild($xmlMdxi);
    }
706583
def _build_request(request):
    """"""
    msg = bytes([request['cmd']])
    if 'dest' in request:
        msg += bytes([request['dest']])
    else:
        msg += b'\0'
    if 'sha' in request:
        msg += request['sha']
    else:
        for dummy in range(64):
            msg += b'0'
    logging.debug("Request (%d): %s", len(msg), msg)
    return msg
1016826
def process_request(self, request_object):
        """"""
        resources = (request_object.entity_cls.query
                     .filter(**request_object.filters)
                     .offset((request_object.page - 1) * request_object.per_page)
                     .limit(request_object.per_page)
                     .order_by(request_object.order_by)
                     .all())
        return ResponseSuccess(Status.SUCCESS, resources)
1372553
function buildRequest(ts, doc, query, pos) {
    var files = [], offsetLines = 0, allowFragments = !query.fullDocs;
    if (!allowFragments) delete query.fullDocs;
    if (typeof query == "string") query = {type: query};
    query.lineCharPositions = true;
    if (query.end == null) {
      query.end = pos || doc.doc.getCursor("end");
      if (doc.doc.somethingSelected())
        query.start = doc.doc.getCursor("start");
    }
    var startPos = query.start || query.end;

    if (doc.changed) {
      if (doc.doc.lineCount() > bigDoc && allowFragments !== false &&
          doc.changed.to - doc.changed.from < 100 &&
          doc.changed.from <= startPos.line && doc.changed.to > query.end.line) {
        files.push(getFragmentAround(doc, startPos, query.end));
        query.file = "#0";
        var offsetLines = files[0].offsetLines;
        if (query.start != null) query.start = Pos(query.start.line - -offsetLines, query.start.ch);
        query.end = Pos(query.end.line - offsetLines, query.end.ch);
      } else {
        files.push({type: "full",
                    name: doc.name,
                    text: docValue(ts, doc)});
        query.file = doc.name;
        doc.changed = null;
      }
    } else {
      query.file = doc.name;
    }
    for (var name in ts.docs) {
      var cur = ts.docs[name];
      if (cur.changed && cur != doc) {
        files.push({type: "full", name: cur.name, text: docValue(ts, cur)});
        cur.changed = null;
      }
    }

    return {query: query, files: files};
  }
1358747
def from_body(cls, body):
        """"""
        # TODO: Check length
        request = cls()
        request.channel = body[1]
        request.seq = body[2]
        request.cemi = body[4:]
        return request
1003175
def _BuildResponse(self,
                     status,
                     rendered_data,
                     method_name=None,
                     headers=None,
                     content_length=None,
                     token=None,
                     no_audit_log=False):
    """"""

    # To avoid IE content sniffing problems, escape the tags. Otherwise somebody
    # may send a link with malicious payload that will be opened in IE (which
    # does content sniffing and doesn't respect Content-Disposition header) and
    # IE will treat the document as html and executre arbitrary JS that was
    # passed with the payload.
    str_data = json.Dump(
        rendered_data, encoder=JSONEncoderWithRDFPrimitivesSupport)
    # XSSI protection and tags escaping
    rendered_data = ")]}'\n" + str_data.replace("<", r"\u003c").replace(
        ">", r"\u003e")

    response = werkzeug_wrappers.Response(
        rendered_data,
        status=status,
        content_type="application/json; charset=utf-8")
    response.headers[
        "Content-Disposition"] = "attachment; filename=response.json"
    response.headers["X-Content-Type-Options"] = "nosniff"

    if token and token.reason:
      response.headers["X-GRR-Reason"] = utils.SmartStr(token.reason)
    if method_name:
      response.headers["X-API-Method"] = method_name
    if no_audit_log:
      response.headers["X-No-Log"] = "True"

    for key, value in iteritems(headers or {}):
      response.headers[key] = value

    if content_length is not None:
      response.content_length = content_length

    return response
813704
def build_request_body(header_params, form_params, body)
      # http form
      if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
          header_params['Content-Type'] == 'multipart/form-data'
        data = {}
        form_params.each do |key, value|
          case value
          when ::File
            data[key] = Faraday::UploadIO.new(value.path, MimeMagic.by_magic(value).to_s, key)
          when ::Array, nil
            data[key] = value
          else
            data[key] = value.to_s
          end
        end
      elsif body
        data = body.is_a?(String) ? body : body.to_json
      else
        data = nil
      end
      data
    end
885861
def build(self, **kwargs):
        """"""
        self.lexer = ply.lex.lex(object=self, **kwargs)
860086
def build_body(self, template_file=INDEX):
        

        if self.params['error'] == 'access_denied':
            message = docs.OAUTH_ACCESS_DENIED
        elif self.params['error'] is not None:
            message = docs.OAUTH_ERROR.format(error=self.params['error'])
        elif self.params['state'] is None or self.params['code'] is None:
            message = docs.OAUTH_INVALID
        else:
            message = docs.OAUTH_SUCCESS

        with codecs.open(template_file, 'r', 'utf-8') as fp:
            index_text = fp.read()

        body = string.Template(index_text).substitute(message=message)
        body = codecs.encode(body, 'utf-8')
        return body
83719
def build_base_parameters(request):
    """"""

    getParameters = {}
    postParameters = {}
    files = {}

    # Copy GET parameters, excluding ebuio_*
    for v in request.GET:
        if v[:6] != 'ebuio_':
            val = request.GET.getlist(v)

            if len(val) == 1:
                getParameters[v] = val[0]
            else:
                getParameters[v] = val

    # If using post, copy post parameters and files. Excluding ebuio_*
    if request.method == 'POST':
        for v in request.POST:
            if v[:6] != 'ebuio_':
                val = request.POST.getlist(v)

                if len(val) == 1:
                    postParameters[v] = val[0]
                else:
                    postParameters[v] = val

        for v in request.FILES:
            if v[:6] != 'ebuio_':
                files[v] = request.FILES[v]  # .chunks()

    return (getParameters, postParameters, files)