region PayloadRequestSender
328661
@Override
	public HttpRequest createPayloadSendRequest(PayloadData payload, HttpRequest.Listener<HttpRequest> listener) {
		if (payload == null) {
			throw new IllegalArgumentException("Payload is null");
		}

		HttpRequest request = createPayloadRequest(payload);
		request.addListener(listener);
		return request;
	}
1157906
private Message messageFromBuffer(ByteBuffer request) throws InternalException {
    if (request != null) {
      Message m;
      try {
        m = parser.createMessage(request);
        return m;
      }
      catch (AvpDataException e) {
        throw new InternalException("Failed to decode message.", e);
      }
    }
    return null;
  }
812768
protected int addPayload(RequestBuilder builder, String payload) {
    if (payload == null || payload.length() == 0) {
      return 0;
    }


    builder.setHeader(HttpHeaders.CONTENT_TYPE, contentType.getMimeType());
    builder.setEntity(new StringEntity(payload, contentType));
    return payload.length();
  }
880305
private String getPayLoad(Key key, Application app) {
        if (app == null) {
            return EMPTY_PAYLOAD;
        }

        EncoderWrapper encoderWrapper = serverCodecs.getEncoder(key.getType(), key.getEurekaAccept());
        try {
            return encoderWrapper.encode(app);
        } catch (Exception e) {
            logger.error("Failed to encode the payload for application {}", app.getName(), e);
            return "";
        }
    }
1187212
def _read_payload(self, maxlen=None):
        

        client_address_str = "{}:{}".format(self.client_address[0], self.client_address[1])

        # check length
        read_len = self.headers.get('content-length', None)
        if read_len is None:
            log.error("No content-length given from {}".format(client_address_str))
            return None

        try:
            read_len = int(read_len)
        except:
            log.error("Invalid content-length")
            return None

        if maxlen is not None and read_len >= maxlen:
            log.error("Request from {} is too long ({} >= {})".format(client_address_str, read_len, maxlen))
            return None

        # get the payload
        request_str = self.rfile.read(read_len)
        return request_str
254347
public void setRespondToPayloadType(String respondToPayloadType) throws UnsupportedPayloadType {
    // Sanity check on the payload type values. Should be XML or JSON
    // If the probe goes out with a bad value here, then the Responder may have
    // problems
    if (respondToPayloadType == null || respondToPayloadType.isEmpty() || (!respondToPayloadType.equals(ProbeWrapper.JSON) && !respondToPayloadType.equals(ProbeWrapper.XML)))
      throw new UnsupportedPayloadType("Attempting to set payload type to: " + respondToPayloadType + ". Cannot be null or empty and must be " + ProbeWrapper.JSON + " or " + ProbeWrapper.XML);

    _probe.setRespondToPayloadType(respondToPayloadType);
  }
768595
private void handleSerialApiGetInitDataResponse(
			SerialMessage incomingMessage) {
		logger.debug(String.format("Got MessageSerialApiGetInitData response."));
		this.isConnected = true;
		int nodeBytes = incomingMessage.getMessagePayloadByte(2);
		
		if (nodeBytes != NODE_BYTES) {
			logger.error("Invalid number of node bytes = {}", nodeBytes);
			return;
		}

		int nodeId = 1;
		
		// loop bytes
		for (int i = 3;i < 3 + nodeBytes;i++) {
			int incomingByte = incomingMessage.getMessagePayloadByte(i);
			// loop bits in byte
			for (int j=0;j<8;j++) {
				int b1 = incomingByte & (int)Math.pow(2.0D, j);
				int b2 = (int)Math.pow(2.0D, j);
				if (b1 == b2) {
					logger.info(String.format("Found node id = %d", nodeId));
					// Place nodes in the local ZWave Controller 
					this.zwaveNodes.put(nodeId, new ZWaveNode(this.homeId, nodeId, this));
					this.getNode(nodeId).advanceNodeStage();
				}
				nodeId++;
			}
		}
		
		logger.info("------------Number of Nodes Found Registered to ZWave Controller------------");
		logger.info(String.format("# Nodes = %d", this.zwaveNodes.size()));
		logger.info("----------------------------------------------------------------------------");
		
		// Advance node stage for the first node.
	}
256630
private ClientNotificationArea getInboxIfAvailable(int clientID, JSONConverter converter) {
        final ClientNotificationArea inbox = inboxes.get(clientID);

        if (inbox == null) {
            throw ErrorHelper.createRESTHandlerJsonException(new RuntimeException("The requested clientID is no longer available because it timed out."),
                                                             converter,
                                                             APIConstants.STATUS_GONE);
        }

        return inbox;
    }
707006
public void processResponseEvent(HttpClientNIOResponseEvent event, HttpClientNIORequestActivityImpl activity) {

        HttpClientNIORequestActivityHandle ah = new HttpClientNIORequestActivityHandle(activity.getId());

        if (tracer.isFineEnabled())
            tracer.fine("==== FIRING ResponseEvent EVENT TO LOCAL SLEE, Event: " + event + " ====");

        try {
            resourceAdaptorContext.getSleeEndpoint().fireEvent(ah, fireableEventType, event, null, null, EVENT_FLAGS);
        } catch (Throwable e) {
            tracer.severe(e.getMessage(), e);
        }
    }
1036044
void handleRequest(ByteBuf buffer) {
    long requestId = buffer.readLong();

    try {
      Object request = readRequest(buffer);
      HandlerHolder handler = handlers.get(request.getClass());
      if (handler != null) {
        handler.context.executor().execute(() -> handleRequest(requestId, request, handler));
      } else {
        handleRequestFailure(requestId, new SerializationException("unknown message type: " + request.getClass()), this.context);
      }
    } catch (SerializationException e) {
      handleRequestFailure(requestId, e, this.context);
    } finally {
      buffer.release();
    }
  }
687835
@Programmatic
    @Override
    public Object serialize(EventMetadata metadata, EventPayload payload) {
        final RendererContext rendererContext = new EventSerializerRendererContext(baseUrl, Where.OBJECT_FORMS);

        final JsonRepresentation payloadRepr = asPayloadRepr(rendererContext, payload);
        final JsonRepresentation eventRepr = asEventRepr(metadata, payloadRepr);

        return jsonFor(eventRepr);
    }
478144
function (token, path, payload, contentFormat) {
            return new Promise((resolve,reject)=>{

                let zh = NewZestHeader();
                zh.code = 2;
                zh.token = token;
                zh.tkl = token.length;
                zh.payload = payload;
                zh.oc = 3;
                zh.options.push(NewZestOptionHeader(11,path,path.length));
                let hostname = os.hostname();
                zh.options.push(NewZestOptionHeader(3,hostname,hostname.length));
                zh.options.push(NewZestOptionHeader(12,contentFormatToInt(contentFormat),2)); //uint32

                let msg = MarshalZestHeader(zh)
                sendRequestAndAwaitResponse(this.ZMQsoc,msg)
                .then((resp)=>{
                    handleResponse(resp,(zh)=>{resolve(zh.payload)},reject);
                })
                .catch((err)=>{
                    reject(err);
                });
            });
        }
312839
@Override
    public void enrichRequest(HttpRequest request, RequestPayload payload) {

        if (WarpCommons.debugMode()) {
            System.out.println("                (W) " + request.getUri());
        }

        if (log.isLoggable(Level.FINE)) {
            log.fine("Warp request: " + request.getUri());
        }

        try {
            String requestEnrichment = SerializationUtils.serializeToBase64(payload);
            long serialId = payload.getSerialId();
            remoteOperationService().execute(new RegisterPayloadRemotely(requestEnrichment));

            io.netty.handler.codec.http.HttpRequest nettyHttpRequest = ((HttpRequestWrapper) request).unwrap();
            nettyHttpRequest.headers().set(WarpCommons.ENRICHMENT_REQUEST, Arrays.asList(Long.toString(serialId)));
        } catch (Throwable originalException) {
            Throwable cause = Rethrow.getOriginalCause(originalException);
            ClientWarpExecutionException explainingException =
                new ClientWarpExecutionException("enriching request failed; caused by:\n"
                    + cause.getClass().getName() + ": " + cause.getMessage(), originalException);
            warpContext().pushException(explainingException);
        }
    }
728617
function payload( )
    {
        $contentType = $this->ContentType;
        // accommodate re-serializing content after we got a forced content-type
        if ( $pos = strpos( $contentType, ';' ) !== false )
        {
            $contentType = substr( $contentType, 0, $pos );
        }
        if ( $contentType == '' )
        {
            $contentType = $this->defaultContentType;
        }

        if ( $this->IsFault )
        {
            // default representation of an error, hand picked
            $value = array( 'faultCode' => $this->FaultCode, 'faultString' => $this->FaultString );
            // send an HTTP error code, since there is no other way to make sure
            // that the client can tell apart error responses from valid array responses
            // try some meaningful mapping (it's REST, baby!)
            switch( $this->FaultCode )
            {
                case ggWebservicesServer::INVALIDMETHODERROR:
                    header( $_SERVER['SERVER_PROTOCOL'].' 404 Not Found' );
                    break;
                case ggWebservicesServer::INVALIDPARAMSERROR:
                case ggWebservicesServer::INVALIDCOMPRESSIONERROR:
                case ggWebservicesServer::INVALIDREQUESTERROR:
                    header( $_SERVER['SERVER_PROTOCOL'].' 400 Bad Request' );
                    break;
                case ggWebservicesServer::INVALIDAUTHERROR:
                    header( $_SERVER['SERVER_PROTOCOL'].' 403 Forbidden' );
                    break;
                default:
                    header( $_SERVER['SERVER_PROTOCOL'].' 500 Internal Server Error' );
            }
        }
        else
        {
            $value = $this->Value;
        }

        switch( $contentType )
        {
            case 'php':
            case 'application/x-httpd-php':
                return var_export( $value );
            case 'phps':
            case 'application/vnd.php.serialized':
                return serialize( $value );
            case 'application/json':
                $json = json_encode( $value, JSON_FORCE_OBJECT );
                if ( $this->JsonpCallback != false )
                {
                    $json = $this->JsonpCallback . '(' . $json . ')';
                }
                return $json;
            case 'text/plain':
                return is_string( $value ) ? $value : var_export( $value, true );
            case 'text/html':
                // in theory both html and body tags are not mandatory. But getting here is just a case of bad coding anyway
                return is_string( $value ) ? $value : '<html><body>' . htmlspecialchars( print_r( $value, true ) ) . '</body></html>';
            default:
                header('HTTP/1.1 406 Not Acceptable');
                // two 'non standard but existing' mimetype defs for php code and serialized
                return "REST responses cannot be serialized as '$contentType'. Currently supported: application/json, application/x-httpd-php, application/vnd.php.serialized";
        }

    }
1219442
def send_payload(self, params):
        """"""
        data = dumps({
            'jsonrpc': self.version,
            'method': self.service_name,
            'params': params,
            'id': str(uuid.uuid1())
        }).encode('utf-8')
        headers = {
            'Content-Type': 'application/json-rpc',
            'Accept': 'application/json-rpc',
            'Content-Length': len(data)
        }
        try:
            req = urllib_request.Request(self.service_url, data, headers)
            resp = urllib_request.urlopen(req)
        except IOError as e:
            if isinstance(e, urllib_error.HTTPError):
                if e.code not in (
                        401, 403
                ) and e.headers['Content-Type'] == 'application/json-rpc':
                    return e.read().decode('utf-8')  # we got a jsonrpc-formatted respnose
                raise ServiceProxyException(e.code, e.headers, req)
            else:
                raise e
        return resp.read().decode('utf-8')
746810
@Override
    public ResourceSet<Payload> read(final TwilioRestClient client) {
        return new ResourceSet<>(this, client, firstPage(client));
    }
261894
protected void afterSend(RpcInternalContext context, SofaRequest request) {
        currentRequests.decrementAndGet();
        int cost = context.getStopWatch().tick().read();
        context.setAttachment(RpcConstants.INTERNAL_KEY_REQ_SERIALIZE_TIME, cost);
        if (EventBus.isEnable(ClientAfterSendEvent.class)) {
            EventBus.post(new ClientAfterSendEvent(request));
        }
    }