今天调试一个http接口,调用端代码如下
URL url = new URL("http://www.AAA.com");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setDoOutput(true);
ObjectOutputStream out = new ObjectOutputStream(connection.getOutputStream());
Map map = new HashMap();
map.put("type", "ttt");
out.writeObject(map);
out.flush();
out.close();
服务端代码如下:
InputStream is = ####;
ObjectInputStream ois = new ObjectInputStream(is);//异常产生出
Map map = (Map) ois.readObject();
ois.close();
is.close();
服务端在异常产生出报invalid stream header异常,跟踪代码发现是ObjectInputStream(InputStream in)方法中会检查stream的头信息readStreamHeader(),头信息异常导致invalid stream header产生,检查调用端的代码发现没有设置Content-Type,因为是用序列号的二进制流,类型为application/xml,加上一句connection.setRequestProperty("Content-Type", "application/xml"),问题解决
分享到:
相关推荐
记一次异常解决:OAuth2获取token报错invalid stream header 在整合springcloud gateway、eureka、security、OAuth2的时候,采用授权码模式,用授权码去访问/oauth/token获取token时,遇到invalid stream header异常...
先阐述遇到的几个问题: 1、redis获取到的数据序列化后,转json,经常提示转换异常(并不是每次,只是时常)。 2、不想每种用户都书写一个redis操作方法(显得tai low)。 解决: 1、redis获取到的数据序列化后,转...
主要为大家详细介绍了Android多点触控技术实战,自由地对图片进行缩放和移动,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
序列化 (Serialization)是将对象的状态信息转换为可以存储或传输的形式的过程。一般将一个对象存储至一个储存媒介,例如档案或是记亿体缓冲等。在网络传输过程中,可以是字节或是XML等格式。而字节的或XML编码格式...
////header("Content-Type: application/octet-stream"); ////header("Content-Type: application/download"); ////header('Content-Disposition:inline;filename="'.$outputFileName.'"'); ////header(...
Behavior of freeing the ArchiveStream (compressed stream) has been modified. VCLZip will now no longer try to free ArchiveStream, you must free it yourself. This was due to a problem where it would ...
* fixed: h264 with missing framerate in 1st sequence header made eac3to crash * fixed: some AC3WAV files were not detected correctly * fixed: video frame count was not displayed when 2nd pass was ...
* @return BufferedImage representation of frame, or null if n is invalid. */ public BufferedImage getFrame(int n) { BufferedImage im = null; if ((n >= 0) && (n < frameCount)) { im = (...
#include "Header.h" #include "resource.h" ////////////////////////////////////////////////////////////////////////// //端口器扫描初始化 ///////////////////////////////////////////////////////////////...
a checksum for the header to ensure that it has not been corrupted (A checksum of a sequence of bits is calculated by counting the number of "1" bits in the stream. For example, the checksum for ...
The default behavior of this method is to return addHeader(String name, String value) on the wrapped response object. addHeader(String, String) - Method in interface javax.servlet....
Structure Dissect: If setting a name, it will also be shown in the header The symbolhandler can now deal with complex pointer notations Added support for single-ToPA systems for ultimap2 Added some ...
Provisional Policy with New Header API Other API Changes ftplib functools gc hmac http html imaplib inspect io itertools logging math mmap multiprocessing nntplib os pdb pickle ...
KEY_LOADED:"hlsKeyLoaded",STREAM_STATE_TRANSITION:"hlsStreamStateTransition"}},function(t,e,r){"use strict";r.d(e,"b",function(){return i}),r.d(e,"a",function(){return a});var i={NETWORK_ERROR:...