All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.webpieces.httpclientx.impl.StreamWriterImpl Maven / Gradle / Ivy

Go to download

HTTP/2 client that talks HTTP/1.1 in case you want to convert from HTTP/2 to HTTP/1.1 without changing code

There is a newer version: 2.1.109
Show newest version
package org.webpieces.httpclientx.impl;

import org.webpieces.util.futures.XFuture;

import org.webpieces.http2translations.api.Http2ToHttp11;
import org.webpieces.httpclient11.api.HttpDataWriter;
import org.webpieces.httpparser.api.dto.HttpData;
import org.webpieces.httpparser.api.dto.HttpRequest;

import com.webpieces.http2.api.dto.lowlevel.DataFrame;
import com.webpieces.http2.api.dto.lowlevel.lib.StreamMsg;
import com.webpieces.http2.api.streaming.StreamWriter;

public class StreamWriterImpl implements StreamWriter {

	private HttpDataWriter dataWriter;
	private HttpRequest req;

	public StreamWriterImpl(HttpDataWriter dataWriter, HttpRequest req) {
		this.dataWriter = dataWriter;
		this.req = req;
	}

	@Override
	public XFuture processPiece(StreamMsg data) {
		if(!(data instanceof DataFrame))
			throw new IllegalArgumentException("You must feed in http1_1 compatible http2 payloads like DataFrame.  this is not http1_1 compatible="+data.getClass());
		HttpData chunk = Http2ToHttp11.translate((DataFrame)data, req);
		return dataWriter.send(chunk);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy