httprequest

SessionAware design in Struts 2

微笑、不失礼 提交于 2019-12-11 03:48:02
问题 I have been working with Struts 2 for a long time. In case of implementing SessionAware interface to our action class we will get SessionMap but not HttpSession object. In case of ServletRequestAware and ServletResposeAware we get HttpServletRequest and HttpServletResponse object but not wrapper objects like SessionMap in case of SessionAware . My question is, if Struts is giving us SessionMap instead of HttpSession to decouple our action classes from Servlet API and Http protocol,then why it

Python request using ast.literal_eval error Invalid syntax?

ⅰ亾dé卋堺 提交于 2019-12-11 02:49:52
问题 i am new to python and trying to get request data using ast.literal_eval resulting in "invalid syntax" error. It prints data i send that is format like, 192.156.1.0,8181,database,admin,12345 In python i display it but get error while reading it my code is, print str(request.body.read()) datas = request.body.read() data=ast.literal_eval(datas) dbname = data['dbname'] username = data['uname'] ip = data['ip'] port = data['port'] pwd = data['pwd'] Invalid syntax error on line data=ast.literal

Detect the end of an HTTP Request in Java

自古美人都是妖i 提交于 2019-12-11 01:55:11
问题 Im trying to design a Java proxy program, but my java program has issues reading an entire HTTP request. I used the InputStream object isObj to try to obtain data: isObj.read(byteBuff) But this often results in the data not getting read completely. i.e in case of a POST request, sometimes, the HTTP headers alone are read while the POST data is not read. So, I tried to use the below to read the data fully. ByteArrayOutputStream baos=new ByteArrayOutputStream(); while((len=isObj.read(tempBuff))

Mocked HttpRequest loses the QueryString

元气小坏坏 提交于 2019-12-11 00:09:13
问题 I need to test an helper class which manage complex querystring. I use this helper method to mock the HttpContext : public static HttpContext FakeHttpContext(string url, string queryString) { var httpRequest = new HttpRequest("", url, queryString); var stringWriter = new StringWriter(); var httpResponse = new HttpResponse(stringWriter); var httpContext = new HttpContext(httpRequest, httpResponse); var sessionContainer = new HttpSessionStateContainer("id", new SessionStateItemCollection(), new

How to successfully pass string array as parameter alamofire

孤者浪人 提交于 2019-12-10 23:04:09
问题 I have an endpoint that accepts a string array as parameter but I can't get it working with alamofire. I test my endpoint with postman and it works fine, even in the browser, but with alamofire it fails and just returns the whole thing (as if I didn't put any parameter). func getQuotes(String url){ //THIS CALL IS NOT WORKING. PARAMETERS ARE NOT SENT PROPERLY - FIX let stringArray : [String] = ["4250_XSAU", "Test"] let getQuoteParameters : Parameters = [ //"internal_symbols":

Copying cookies from first response to next request

馋奶兔 提交于 2019-12-10 22:58:59
问题 I'm sending a first HTTP request out using HttpRequest->send(), and I receive a 302 response with the following Set-Cookie headers: Set-Cookie: SESSION_SCOPE=1; path=/ Set-Cookie: III_EXPT_FILE=aa2171; path=/; domain=.example.com Set-Cookie: III_SESSION_ID=193a3ce5aaadea85937c25cd0430332f; domain=.example.com; path=/ When I use HttpRequest->getResponseCookies(), this is what the extracted content looks like: Array ( - [0] => stdClass Object ( [cookies] => Array ( [SESSION_SCOPE] => 1 )

Keep connection open and read data till it is forcefully closed

不打扰是莪最后的温柔 提交于 2019-12-10 22:03:57
问题 When my activity loads, I am connecting to a web service. As and when I get the response from service, I again call then service and so on. @Override protected void onCreate(Bundle savedInstanceState) { …. callWebMethod(); } // Called on getting response @Override public void run(String value) { …. callWebMethod(); } This is how I am connecting to service HttpGet request = new HttpGet(url + combinedParams); HttpClient client = new DefaultHttpClient(httpParameters); HttpResponse httpResponse;

testing a curl request with jmeter

∥☆過路亽.° 提交于 2019-12-10 21:33:47
问题 I have a curl request and i don't know how to transform it in jmeter : curl -H application-id:my-app-id -H secret-key:my-secret-key -H Content-Type:"multipart/form-data" -H application-type:REST --form upload=@/logo.jpg -X POST -v http://localhost:8080/api/v1/files/Photos/logo.jpg What is the best way of doing this? 回答1: Option 1: Record the request In JMeter: File -> Templates -> Recording -> Create Workbench -> HTTP(S) Test Script Recorder -> Start In console: curl -x localhost:8888 -H

POST Base64 encoded data in PHP

强颜欢笑 提交于 2019-12-10 20:28:07
问题 I need to POST some data to a PHP page using cURL, and the request contains three parameters: Two of them are regular text values One is a Base64 encoded file I've noticed that the Base64 value is corrupted during the transmission. This is the code that's sending the request: $filename = "img2.jpg"; //A sample image file $handle = fopen($filename, "r"); $data = fread($handle, filesize($filename)); $base64 = base64_encode($data); $postData = "id=1234&sometext=asdasd&data=" . $base64; $ch =

Http_Request2 POST request not working

﹥>﹥吖頭↗ 提交于 2019-12-10 19:49:35
问题 Good morning fellows. I'm doing some work with Http_Request2 lib and I'm facing this situation. Im trying to make a POST request to certain URL. If I add the parameters on the query string of the url, i.e. $request->setUrl('127.0.0.1/something.php?parm1=x&parm2=y'); $request->setMethod(HTTP_Request2::METHOD_POST); It works fine, but I want to set the parameters with the addPostParameter method: $request->setUrl('127.0.0.1:8888/something.php'); $request->addPostParameter('parm1', $somevariable