标签: httpresponse

# 字符似乎会导致 get 请求出现问题

我有一个查询字符串,我将其传递给 servlet 的 doGet() 方法,如下所示:

计数=9&preId0=-99&objId0=-99&preId1=-99&objId1=-99&preId2=69&objId2=16#!78&preId3=-99&objId3=-99&preId4=-99&objId4=-99&preId5=-99&objId5=-99&preId6=-99&objId6=-99&preId7=-9 9&objId7= -99&preId8=-99&objId8=-99

在 # 之后并包括 # 一切都是空的,所以我假设 # 有一些特殊的含义。这是真的?还有其他这样的角色会这样做吗?

get httpresponse httprequest

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

在新的 WebView 中显示 HttpResponse(来自处理程序的字符串)

我在表单的提交按钮 onClickListener 中有以下代码:

String action, user, pwd, user_field, pwd_field;

        action = "theURL";

        user_field = "id";
        pwd_field = "pw";
        user = "username";
        pwd = "password!!";

        List<NameValuePair> myList = new ArrayList<NameValuePair>();
        myList.add(new BasicNameValuePair(user_field, user)); 
        myList.add(new BasicNameValuePair(pwd_field, pwd));

        HttpParams params = new BasicHttpParams();
        HttpClient client = new DefaultHttpClient(params);
        HttpPost post = new HttpPost(action);
        HttpResponse end = null;
        String endResult = null;

        try {
            post.setEntity(new UrlEncodedFormEntity(myList));
        } catch (UnsupportedEncodingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } 

        try {
            HttpResponse response = client.execute(post); …
Run Code Online (Sandbox Code Playgroud)

android httpresponse webview android-intent

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

在 Java 中流式传输 HTTP 响应

我想将 HTTP 请求的响应写入文件。但是,我想将响应流式传输到物理文件,而无需等待加载整个响应。

我实际上将向 JHAT 服务器发出请求,以从转储中返回所有字符串。我的浏览器在响应完成之前挂起,因为有 70k 个这样的对象,我想将它们写入一个文件,以便我可以扫描。

提前致谢,

httpresponse fileinputstream

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

如何在 ZF2 中使用自定义(非标准)HTTP 状态代码

我正在尝试498 - Token Invalid在 Zend Framework 2 应用程序中使用自定义 http 状态代码发送响应。这显然不起作用,因为标准 Zend Response 类不允许自定义 http 代码。

所以我创建了自己的响应类来处理这个 http 代码并在我的操作中返回它:

$response = new CustomResponse();
$response->setStatusCode(498); //basic zend response objects throws InvalidArgumentException

return $response;
Run Code Online (Sandbox Code Playgroud)

虽然没有抛出异常,但浏览器说它返回了 500 错误。

如何让这个工作?

http httpresponse zend-framework2

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

Web API 异常包装器

我正在使用 WebAPI 调用一些第三方方法:

public class SessionsController : ApiController
{
    public DataTable Get(int id)
    {
        return Services.TryCall(es => es.GetSessionList(id).Tables[0]);
    }
}
Run Code Online (Sandbox Code Playgroud)

我正在包装此服务的所有调用:

internal static class Services
{
    internal static IExternalService ExternalService { get; set; }

    internal static T TryCall<T>(Func<IExternalService,T> theFunction)
    {
        try
        {
            return theFunction(ExternalService);
        }
        catch (FaultException<MyFaultDetail> e)
        {
            var message = new HttpResponseMessage(HttpStatusCode.NotImplemented);
            message.Content = new StringContent(e.Detail.Message);
            throw new HttpResponseException(message);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

当抛出异常时,它会被捕获并准备好消息。通过重新抛出,我收到一条新的错误消息:

处理 HTTP 请求导致异常。有关详细信息,请参阅此异常的 'Response' 属性返回的 HTTP 响应。

如何在没有 Visual Studio 抱怨的情况下正确返回此异常?当我跳过错误时,浏览器会得到 501 错误结果。该方法Request.CreateResponse()在我的包装方法中不可用。

c# exception-handling httpresponse asp.net-web-api

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

如何从响应头中隐藏或删除"X-ATG-Version"?

我正在使用ATG平台,无法弄清楚如何隐藏或删除响应标题"X-ATG-Version:xxxxxxx"的部分.我正在使用JBoss,我已经想出如何删除标题的"X-powered-by"部分,但ATG部分没有运气.我出于安全目的试图完成此操作.

security atg header httpresponse jboss-4.2.x

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

确保任何浏览器都不会缓存 django 模板

我有一个基于类的 django 模板DetailView。我已经覆盖了 的get_context_data方法DetailView,使用它来传递context我在模板中显示的一些必需变量(本质上是一个图像)。这就是我所做的一切。

我如何确保我的这个特定的 django 模板永远不会被任何浏览器缓存?通过各种渠道涉水告诉我,我需要过骑HttpResponsedispatch实现无缓存的方法?

据我所知,我需要设置Cache-ControlPragmaExpiry等我只是一直无法作出关于是否要前进(或如何)过度乘坐调度方法。有人可以给我一个简单的说明性示例,说明他们将如何为这样的模板实现无缓存?

python django httpresponse django-views

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

Jersey ContainerRequestFilter:抛出“ abortWith”且状态被禁止后得到404(403)

带有令牌身份验证+基于角色的授权的Jersey 2.22 API(我保护API的方式基于本文的公认答案:使用JAX-RS和Jersey进行基于REST令牌身份验证的最佳实践。最好在阅读之前阅读它试图理解我的问题):

这是我的web.xml

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:applicationContext.xml</param-value>
</context-param>

<!-- LISTENERS -->
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<servlet>
    <servlet-name>JerseySpringServlet</servlet-name>
    <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
    <init-param>
        <param-name>jersey.config.server.provider.packages</param-name>
        <param-value>ca.toto.api.filters</param-value>
    </init-param>
    <init-param>
        <param-name>jersey.config.server.provider.packages</param-name>
        <param-value>ca.toto.api.restapi</param-value>
    </init-param>

    <init-param>
        <param-name>jersey.config.server.provider.classnames</param-name>
        <param-value>ca.toto.api.filters.AuthenticationFilter;ca.toto.api.filters.AuthorizationFilter;com.toto.api.restapi.TaskRestService</param-value>
    </init-param>

    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>JerseySpringServlet</servlet-name>
    <url-pattern>/filters/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>JerseySpringServlet</servlet-name>
    <url-pattern>/restapi/*</url-pattern>
</servlet-mapping>
Run Code Online (Sandbox Code Playgroud)

当我调用任务 Web服务时,流程毫无问题地进入第一个过滤器(AuthenticationFilter)(@Priority(Priorities.AUTHENTICATION)),验证我的令牌,从解码的令牌中获取用户,然后将其注册为委托人然后传入第二个过滤器AuthorizationFilter@Priority(Priorities.AUTHORIZATION)),在这里我从安全上下文中获取用户,获取其角色,然后检查他是否有权进行调用。如果是,请正常退出过滤器(如果否),请使用javax.ws.rs.container.ContainerRequestContextabortWith方法发送状态为403的响应:

@Secured
@Provider
@Priority(Priorities.AUTHORIZATION)
public class AuthorizationFilter implements ContainerRequestFilter {

    ...
try {
        boolean isAllowed = false;
        // Check if the …
Run Code Online (Sandbox Code Playgroud)

java rest restful-authentication httpresponse jersey-2.0

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

如何使用 python 瓶从 FormsDict 检索数据?

我无法打印结果。如果我使用,这在烧瓶上工作正常,result= request.form然后print(result). 这会在烧瓶上打印字典。但使用瓶子不起作用。当我使用type(result)它时说<class 'bottle.FormsDict'>

x.py 文件:

from bottle import request, template,route,run,post

@route('/')
def index():
    return template('val.html')

@post('/result')
def result():
    result=request.forms
    print(result)       #Unable to print 

if __name__ == '__main__':
    run(host='localhost',port=8080,debug='True',reloader='True')
Run Code Online (Sandbox Code Playgroud)

val.html 文件:

<!DOCTYPE html>
<html>
<body>

<form action="http://localhost:8080/result" method = "POST">
Select a time:
<input type="time" name="usr_time">
<br> <br>
<input type="checkbox" name="A" value="A is on" >A </input>
<br>
<input type="checkbox" name="B" value="B is on" >B </input>
<br>
<input type="checkbox" name="C" value="C is on" >C …
Run Code Online (Sandbox Code Playgroud)

python httpresponse request bottle python-3.x

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

如何在 .NET Core 3.1.x 上写入 HttpContext.Response.Body

我一直在尝试编写或设置 HttpContext.Response.Body 但无济于事。我发现的大多数示例都使用 Body.WriteAsync 但参数与示例不同。我尝试将我的字符串转换为 byte[],但文本没有显示在我的 Response.Body 上。

httpresponse asp.net-core asp.net-core-webapi

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