小编Ath*_*ran的帖子

java:Tomcat 9 状态码 200 但响应消息为空

我有一个 http 客户端,它向 RESTful Web 服务发送请求并接收响应。它在 Tomcat 8 中部署时运行成功。但是当我尝试在 Tomcat 8.5 及更高版本中部署相同的客户端和服务器时,服务器收到的响应代码为 200,但响应消息为空而不是 OK。

下面是我的客户端代码片段

        httpclient = HttpClientBuilder.create().build();
        postrequest.setEntity(new UrlEncodedFormEntity(urlParameters));
        HttpResponse response = httpclient.execute(postrequest);
        
        HttpEntity entity = response.getEntity();
        System.out.println("Response from server ");
        System.out.println(response.getStatusLine().getStatusCode());
        System.out.println(response.getStatusLine().getReasonPhrase());
Run Code Online (Sandbox Code Playgroud)

我的服务器响应代码片段是

@POST
@Path("/download/{filename}")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response getFile(@PathParam("filename") String file)
{
    try
    {               
        File downloadfile = new File("/home/upload/"+file);

        ResponseBuilder response = Response.ok((Object) downloadfile);
        response.header("Content-Disposition", downloadfile.getName());
        
        return response.build();
            
    }
    catch(Exception e)
    {
        logger.error("Error is : "+e);
        e.printStackTrace();
    }
    
    
}
Run Code Online (Sandbox Code Playgroud)

我得到的输出只是

来自服务器的响应

200

其实应该是

来自服务器的响应

200

好的

java rest tomcat http

6
推荐指数
1
解决办法
5784
查看次数

在 C 中的位域结构中添加了额外的位

我正在尝试为 CAPWAP 协议创建客户端 C 代码。我尝试使用位域结构实现 CAPWAP 标头。但是在使用 sendto() 通过套接字发送这个结构之后,当我使用 wireshark 嗅探数据包时,我发现在它们之间添加了一些额外的位。我不知道这是从哪里来的。请求帮助。提前致谢。

线鲨

我尝试评论结构的最后几个成员以使其 4 字节对齐。问题仍然存在。

这是原始标题

struct cw_header
{
unsigned preamble : 8;
unsigned hlen : 5;
unsigned rid : 5;
unsigned wbid : 5;
unsigned t : 1;
unsigned f : 1;
unsigned l : 1;
unsigned w : 1;
unsigned m : 1;
unsigned k : 1;
unsigned flags : 3;
unsigned fragment_id : 16;
unsigned fragment_offset : 13;
unsigned reserved : 3;
uint32_t mac_length : 8;
uint32_t mac_addr[6]; …
Run Code Online (Sandbox Code Playgroud)

c struct wireshark bit-fields struct-member-alignment

1
推荐指数
1
解决办法
133
查看次数

标签 统计

bit-fields ×1

c ×1

http ×1

java ×1

rest ×1

struct ×1

struct-member-alignment ×1

tomcat ×1

wireshark ×1