NutzCN Logo
问答 Http 工具类 解析数据问题
发布于 2623天前 作者 Rekoe 2323 次浏览 复制 上一个帖子 下一个帖子
标签:
		int id = 622;
		String url = "http://www.allcast.is/stream.php?id=" + id + "&width=100%&height=100%&stretching=uniform";
		Response response = Http.post3(url, null, Header.create().set("Referer", "http://showsport-tv.com/embedplayer.php?ch=bein1&server=1").set("content-encoding", "gzip"), 6000);
		if (response.isOK()) {
			String content = response.getContent();
			System.out.println(content);
		

控制台错误

Exception in thread "main" java.lang.RuntimeException: java.util.zip.ZipException: Corrupt GZIP trailer
	at org.nutz.lang.Lang.wrapThrow(Lang.java:184)
	at org.nutz.lang.Streams.readAndClose(Streams.java:293)
	at org.nutz.http.Response.getContent(Response.java:150)
	at org.nutz.http.Response.getContent(Response.java:143)
	at com.anawin.hls.Beins.main(Beins.java:15)
Caused by: java.util.zip.ZipException: Corrupt GZIP trailer
	at java.util.zip.GZIPInputStream.readTrailer(GZIPInputStream.java:225)
	at java.util.zip.GZIPInputStream.read(GZIPInputStream.java:119)
	at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
	at java.io.BufferedInputStream.read1(BufferedInputStream.java:286)
	at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
	at java.io.BufferedInputStream.read1(BufferedInputStream.java:284)
	at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
	at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)
	at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)
	at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
	at java.io.InputStreamReader.read(InputStreamReader.java:184)
	at java.io.Reader.read(Reader.java:140)
	at org.nutz.lang.Streams.read(Streams.java:316)
	at org.nutz.lang.Streams.read(Streams.java:274)
	at org.nutz.lang.Streams.readAndClose(Streams.java:290)
	... 3 more

5 回复

设置了gzip,但服务器实际返回的内容不是gzip

int id = 622;
		String url = "http://www.allcast.is/stream.php?id=" + id + "&width=100%&height=100%&stretching=uniform";
		Response response = Http.post3(url, null, Header.create().set("Referer", "http://showsport-tv.com/embedplayer.php?ch=bein1&server=1"), 6000);
		if (response.isOK()) {
			String content = response.getContent();
			System.out.println(content);
		}

这样设置也是不行的

直接postman 请求是没问题 是不是nutz http类的bug
@wendal

Accept-Encoding:gzip, deflate

设置一下 Request的header的Accept-Encoding, 设置成deflate

添加回复
请先登陆
回到顶部