org.eclipse.jetty.websocket.api.extensions.ExtensionConfig Java Examples

The following examples show how to use org.eclipse.jetty.websocket.api.extensions.ExtensionConfig. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JettyWebSocketSession.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Override
public void initializeNativeSession(Session session) {
	super.initializeNativeSession(session);

	this.id = ObjectUtils.getIdentityHexString(getNativeSession());
	this.uri = session.getUpgradeRequest().getRequestURI();

	this.headers = new HttpHeaders();
	this.headers.putAll(getNativeSession().getUpgradeRequest().getHeaders());
	this.headers = HttpHeaders.readOnlyHttpHeaders(headers);

	this.acceptedProtocol = session.getUpgradeResponse().getAcceptedSubProtocol();

	List<ExtensionConfig> source = getNativeSession().getUpgradeResponse().getExtensions();
	this.extensions = new ArrayList<WebSocketExtension>(source.size());
	for (ExtensionConfig ec : source) {
		this.extensions.add(new WebSocketExtension(ec.getName(), ec.getParameters()));
	}

	if (this.user == null) {
		this.user = session.getUpgradeRequest().getUserPrincipal();
	}
}
 
Example #2
Source File: JettyWebSocketSession.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public void initializeNativeSession(Session session) {
	super.initializeNativeSession(session);

	this.uri = session.getUpgradeRequest().getRequestURI();

	HttpHeaders headers = new HttpHeaders();
	headers.putAll(session.getUpgradeRequest().getHeaders());
	this.headers = HttpHeaders.readOnlyHttpHeaders(headers);

	this.acceptedProtocol = session.getUpgradeResponse().getAcceptedSubProtocol();

	List<ExtensionConfig> jettyExtensions = session.getUpgradeResponse().getExtensions();
	if (!CollectionUtils.isEmpty(jettyExtensions)) {
		List<WebSocketExtension> extensions = new ArrayList<>(jettyExtensions.size());
		for (ExtensionConfig jettyExtension : jettyExtensions) {
			extensions.add(new WebSocketExtension(jettyExtension.getName(), jettyExtension.getParameters()));
		}
		this.extensions = Collections.unmodifiableList(extensions);
	}
	else {
		this.extensions = Collections.emptyList();
	}

	if (this.user == null) {
		this.user = session.getUpgradeRequest().getUserPrincipal();
	}
}
 
Example #3
Source File: JettyWebSocketSession.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public void initializeNativeSession(Session session) {
	super.initializeNativeSession(session);

	this.uri = session.getUpgradeRequest().getRequestURI();

	HttpHeaders headers = new HttpHeaders();
	headers.putAll(session.getUpgradeRequest().getHeaders());
	this.headers = HttpHeaders.readOnlyHttpHeaders(headers);

	this.acceptedProtocol = session.getUpgradeResponse().getAcceptedSubProtocol();

	List<ExtensionConfig> jettyExtensions = session.getUpgradeResponse().getExtensions();
	if (!CollectionUtils.isEmpty(jettyExtensions)) {
		List<WebSocketExtension> extensions = new ArrayList<>(jettyExtensions.size());
		for (ExtensionConfig jettyExtension : jettyExtensions) {
			extensions.add(new WebSocketExtension(jettyExtension.getName(), jettyExtension.getParameters()));
		}
		this.extensions = Collections.unmodifiableList(extensions);
	}
	else {
		this.extensions = Collections.emptyList();
	}

	if (this.user == null) {
		this.user = session.getUpgradeRequest().getUserPrincipal();
	}
}
 
Example #4
Source File: JettyRequestUpgradeStrategy.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
public WebSocketHandlerContainer(JettyWebSocketHandlerAdapter handler, String protocol, List<WebSocketExtension> extensions) {
	this.handler = handler;
	this.selectedProtocol = protocol;
	if (CollectionUtils.isEmpty(extensions)) {
		this.extensionConfigs = null;
	}
	else {
		this.extensionConfigs = new ArrayList<ExtensionConfig>();
		for (WebSocketExtension e : extensions) {
			this.extensionConfigs.add(new WebSocketToJettyExtensionConfigAdapter(e));
		}
	}
}
 
Example #5
Source File: EventServlet.java    From barge with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(WebSocketServletFactory factory) {
  factory.setCreator((req, resp) -> {

    // remove all compressions extensions that might be requested by the browser...
    resp.setExtensions(Collections.<ExtensionConfig>emptyList());

    return new EventSocket(events);
  });
}
 
Example #6
Source File: JettyRequestUpgradeStrategy.java    From spring-analysis-note with MIT License 4 votes vote down vote up
public List<ExtensionConfig> getExtensionConfigs() {
	return this.extensionConfigs;
}
 
Example #7
Source File: JettyRequestUpgradeStrategy.java    From java-technology-stack with MIT License 4 votes vote down vote up
public List<ExtensionConfig> getExtensionConfigs() {
	return this.extensionConfigs;
}
 
Example #8
Source File: JettyRequestUpgradeStrategy.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
public List<ExtensionConfig> getExtensionConfigs() {
	return this.extensionConfigs;
}