记一次produces引发的404

发现有个服务快应用过来的请求突然都404(no mapping found )了,但是自己用postman/curl调用或者浏览器都正常

开始怀疑是url中有乱码,加了个Filter, 这个是正常的,参数什么的也正常,按理是一样的

最后实在没招了,想到可能是Header的问题,如果打印出所有的Header,对比快应用与postman的请求

请求头Accept跟请求消息体Content-type居然都是application/x-protobuf, 

而自己的@RequestMapping又设置了produces="application/json"

这个确实不应该,其他服务都是走的pb协议,这个服务是普通的web服务走的json, 确认不是客户端加的,那是哪里,想到了网关,果不奇然,网关Accept/Content-type都是application/x-protobuf

两边匹配不上,

顺便翻了下spring的内容协商机制代码,这块是在AbstractMessageConverterMethodProcessor的writeWithMessageConverters中处理的

        } else {
            HttpServletRequest request = inputMessage.getServletRequest();
            //客户端可接受的
            List<MediaType> acceptableTypes = this.getAcceptableMediaTypes(request);
            //服务端所能提供的
            List<MediaType> producibleTypes = this.getProducibleMediaTypes(request, valueType, (Type)targetType);
            if (body != null && producibleTypes.isEmpty()) {
                throw new HttpMessageNotWritableException("No converter found for return value of type: " + valueType);
            }

            List<MediaType> mediaTypesToUse = new ArrayList();
            Iterator var15 = acceptableTypes.iterator();

            MediaType mediaType;
            while(var15.hasNext()) {
                mediaType = (MediaType)var15.next();
                Iterator var17 = producibleTypes.iterator();

                while(var17.hasNext()) {
                    MediaType producibleType = (MediaType)var17.next();
                    if (mediaType.isCompatibleWith(producibleType)) {
                        mediaTypesToUse.add(this.getMostSpecificMediaType(mediaType, producibleType));
                    }
                }
            }

            if (mediaTypesToUse.isEmpty()) {
                if (body != null) {
                    throw new HttpMediaTypeNotAcceptableException(producibleTypes);
                }

                if (this.logger.isDebugEnabled()) {
                    this.logger.debug("No match for " + acceptableTypes + ", supported: " + producibleTypes);
                }

                return;
            }

            MediaType.sortBySpecificityAndQuality(mediaTypesToUse);
            var15 = mediaTypesToUse.iterator();

            while(var15.hasNext()) {
                mediaType = (MediaType)var15.next();
                if (mediaType.isConcrete()) {
                    selectedMediaType = mediaType;
                    break;
                }

                if (mediaType.isPresentIn(ALL_APPLICATION_MEDIA_TYPES)) {
                    selectedMediaType = MediaType.APPLICATION_OCTET_STREAM;
                    break;
                }
            }

            if (this.logger.isDebugEnabled()) {
                this.logger.debug("Using '" + selectedMediaType + "', given " + acceptableTypes + " and supported " + producibleTypes);
            }
        }

 

 

The term **"produces"** is often used in technical contexts to describe the output or result generated by a system, process, algorithm, or device. Below is its definition and technical usage based on relevant fields: ### Definition of Produces In general terms, "produces" refers to creating, generating, or yielding something as an outcome from a given operation or procedure. In specific domains like computer science, finance, or engineering, it may have more precise meanings depending on context. For instance: - Within the scope of card acceptance devices described earlier[^1], "produces" could refer to actions such as generating transaction data after reading magnetic stripes or chips. - Regarding recurrent neural networks (RNNs)[^2], when discussing their functionality, one might say they produce predictions about future elements within sequences using accumulated states over time steps. Thus, technically speaking across various disciplines including but not limited to those mentioned above,"produce" implies delivering tangible results derived via computational processes involving inputs transformed into meaningful outputs according to predefined rulesets implemented either physically through hardware components(e.g.,card readers)or logically inside software algorithms(such as deep learning models). ```python def example_producing_function(input_data): processed_output = perform_operations_on_input(input_data) return processed_output # This function 'produces' some form of output based upon provided input. ``` §§Related Questions§§ 1. How does a card acceptor specifically generate authorization requests during transactions? 2. What types of outputs do Recurrent Neural Networks typically create while handling sequential datasets? 3. Can you provide examples where producing outcomes differ significantly between different machine-learning architectures compared against traditional methods? 4. Is there any distinction made regarding what constitutes production versus transformation under certain standards governing financial technologies? 5. When designing systems meant primarily for producing structured responses out unstructured sources how important becomes choice architecture utilized ?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值