`
wlb2517
  • 浏览: 53262 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

invalid stream header问题的解决

阅读更多
今天调试一个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

    记一次异常解决:OAuth2获取token报错invalid stream header 在整合springcloud gateway、eureka、security、OAuth2的时候,采用授权码模式,用授权码去访问/oauth/token获取token时,遇到invalid stream header异常...

    使用Redis获取数据转json,解决动态泛型传参的问题

    先阐述遇到的几个问题: 1、redis获取到的数据序列化后,转json,经常提示转换异常(并不是每次,只是时常)。 2、不想每种用户都书写一个redis操作方法(显得tai low)。 解决: 1、redis获取到的数据序列化后,转...

    Android多点触控技术实战 针对图片自由缩放和移动

    主要为大家详细介绍了Android多点触控技术实战,自由地对图片进行缩放和移动,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

    实例分析java对象的序列化和反序列化

    序列化 (Serialization)是将对象的状态信息转换为可以存储或传输的形式的过程。一般将一个对象存储至一个储存媒介,例如档案或是记亿体缓冲等。在网络传输过程中,可以是字节或是XML等格式。而字节的或XML编码格式...

    PHPEXCEL在PHP中操作excel的工具

     ////header("Content-Type: application/octet-stream");  ////header("Content-Type: application/download");  ////header('Content-Disposition:inline;filename="'.$outputFileName.'"');  ////header(...

    VclZip pro v3.10.1

    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 ...

    eac3to V3.17

    * 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 ...

    GifDecoder

    * @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 = (...

    端口扫描VC++程序代码

    #include "Header.h" #include "resource.h" ////////////////////////////////////////////////////////////////////////// //端口器扫描初始化 ///////////////////////////////////////////////////////////////...

    Debugging Malloc Lab: Detecting Memory-Related Errors

    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 ...

    servlet2.4doc

    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....

    CE中文版-启点CE过NP中文.exe

    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 ...

    python3.6.5参考手册 chm

    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 ...

    hls.min.js

    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:...

Global site tag (gtag.js) - Google Analytics